Skip to content

test(hmac): assert the plain-HTTP warning argument exactly - #275

Merged
MarTrepodi merged 1 commit into
developfrom
test/codeql-hmac-warning-assert
Nov 23, 2026
Merged

MarTrepodi merged 1 commit into
developfrom
test/codeql-hmac-warning-assert

Conversation

@MarTrepodi

Copy link
Copy Markdown
Collaborator

What changed

CodeQL flagged two high-severity py/incomplete-url-substring-sanitization alerts on the v2.9.0 release PR, at tests/unit/test_hmac_plain_http.py:68-69. They are false positives: the test checked each host with "comlink.example.com" in records[0].getMessage(), and the rule reads a host substring test as URL sanitisation. Code scanning still blocks the merge into main.

  • test_one_warning_when_both_urls_are_remote now asserts the log record's formatting argument exactly: ("http://comlink.example.com:3000 and http://stats.example.com:3223",). This is stricter than before, because it also pins both URLs and their order.
  • One parametrised case used a LAN-style host name. It now uses the neutral comlink.internal, which is still a non-loopback host, so the case tests the same thing.

Test-only change. No library code changed.

Type of change

  • Tests

Checklist

  • This PR targets the develop branch
  • Commits follow the Conventional Commits convention
  • CHANGELOG.md not edited by hand
  • Tests pass
  • Ruff linter and formatter pass
  • No unrelated changes

Verification

  • uv run pytest tests/unit/test_hmac_plain_http.py -q: 48 passed
  • uv run ruff check / ruff format --check on the file: passed
  • CodeQL runs only on PRs into main, so the alerts are confirmed cleared when the release PR is refreshed from develop.

🤖 Generated with Claude Code

The two-URL case checked each host with a substring test on the log
message. CodeQL reads `"<host>" in message` as incomplete URL
sanitisation (py/incomplete-url-substring-sanitization) and raised two
high alerts. Compare the record's formatting argument instead, which is
also stricter: it pins both URLs and their order.

Use a neutral non-loopback host name in the parametrised cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MarTrepodi
MarTrepodi merged commit f7a27ff into develop Nov 23, 2026
12 checks passed
@MarTrepodi
MarTrepodi deleted the test/codeql-hmac-warning-assert branch November 23, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant