Skip to content

Test: Require TLS 1.2 in Gerrit TLS test server - #527

Merged
ModeSevenIndustrialSolutions merged 1 commit into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-526
Nov 2, 2026
Merged

ModeSevenIndustrialSolutions merged 1 commit into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-526

Conversation

@lf-releng-code-monkey-bot

Copy link
Copy Markdown
Contributor

Closes #526

Authored by an AI agent; human review required
Command Exit
uv run pytest tests/test_gerrit_rest_client.py -q 1
uv run pytest tests/test_gerrit_rest_client.py -q --no-cov 0
uv run pytest -q 0
prek run --files tests/test_gerrit_rest_client.py 0
aislop scan --changes --json 0
git commit -s (pre-commit and commit-msg hooks) 0

The github-code-monkey-bot workflow opened this pull request.
Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds; a maintainer must act on any finding that remains after that, and reviews every round before merge.


What changed

The tls_server fixture in tests/test_gerrit_rest_client.py built its server context with ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) and set no minimum protocol version, so the test server still accepted TLSv1 and TLSv1.1. CodeQL reports this as alert 482 (py/insecure-protocol, high).

The fixture now sets context.minimum_version = ssl.TLSVersion.TLSv1_2 right after it builds the context and before load_cert_chain. The fixture then matches what the client under test is expected to negotiate. The alert is fixed in the code. It is not dismissed or suppressed.

A grep for SSLContext( across src/ and tests/ finds no other construction, so no other file needed this change.

Validation

  • uv run pytest tests/test_gerrit_rest_client.py -q --no-cov: all tests pass, including the 15 uses of the tls_server fixture. Without --no-cov, the targeted run fails only on the project-wide 65% coverage gate, because one file covers 16%.
  • uv run pytest -q (full suite): passes, with 76.40% coverage.
  • prek run --files tests/test_gerrit_rest_client.py: all hooks pass. The commit-time hooks, gitlint included, also pass.
  • aislop scan --changes --json, with the project venv on PATH so the lint and format engines run: empty diagnostics, and no engine skipped. This repository does not include scripts/agents/aislop-gate.sh, so the scan ran directly.

For reviewers

  • This changes test code only. The client under test uses the default requests/urllib3 context, which already requires TLS 1.2, so the TLS tests still negotiate the same way.

The tls_server fixture built its server context with
ssl.PROTOCOL_TLS_SERVER and no minimum version, so it still accepted
TLSv1 and TLSv1.1. CodeQL flags this as py/insecure-protocol (alert
482). Set the context's minimum version to TLSv1.2 before loading the
certificate chain, matching what the client under test negotiates.

This is the only ssl.SSLContext construction in the repository.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the test-fixture change requiring TLS 1.2 or newer, with production code unchanged.

No open issues 🎉

What changed in this PR

Explicitly requires TLS 1.2 or newer in the Gerrit REST client’s TLS test server fixture, addressing the insecure-protocol alert tracked in #526. Production code is unchanged.

Changes:

  • Sets the server context’s minimum TLS version immediately after construction, before loading its certificate chain.
File Description
tests/​test_gerrit_rest_client.py Sets tls_server’s minimum protocol version to TLS 1.2.

Review effort: Balanced

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit 677880b into lfreleng-actions:main Nov 2, 2026
34 checks passed
@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions deleted the code-monkey/issue-526 branch November 2, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-quality Updates to code-quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test: Require TLS 1.2 in the Gerrit TLS test server

2 participants