Fix all 38 CodeQL quality alerts and gate CodeQL locally in check.sh#104
Merged
Conversation
Resolve everything on the repo's code-scanning *quality* tab (reproduced locally with the same python/actions/javascript code-quality suites the CodeQL workflow uploads; js+actions were already clean): - py/file-not-closed (the one real bug): silence_stdout leaked the devnull fd after dup2 — close it in a finally; test asserts the close. - py/ineffectual-statement (31): Protocol stub `...` bodies become one-line docstrings; the non-None-returning stubs gain @AbstractMethod so mypy/pyright strict still accept the empty body, with no never-executed line for the patch-coverage gate to miss. - py/unreachable-statement (3): raise via a _raise() helper inside the multi-manager `with pytest.raises(...), telemetry.track(...)` blocks so the trailing assertions are visibly reachable to CodeQL's CFG. - py/empty-except: explain why share's Ctrl-C handler is a no-op. - py/repeated-import / py/import-and-import-from: drop duplicate local imports in tests. Then make the alerts un-regressable: a new check.sh stage (scripts/codeql_gate.py) runs the exact security + quality suites over a python/actions/javascript db-cluster and fails on any finding. Self-skips without the CodeQL bundle on PATH (codeql.yml stays the CI enforcement, so PRs aren't double-scanned); the web session-start hook now provisions the bundle, pinned in gate_tool_pins.sh. https://claude.ai/code/session_01DW3ZQmfbnKsgjrA4PnsF8U
| ) -> str: ... | ||
| def text(self, title: str, *, default: str | None = None) -> str: ... | ||
| ) -> str: | ||
| """Pick one value from `options` (label, value) pairs.""" |
There was a problem hiding this comment.
Prompter.select docstring says options are (label, value), but implementations treat them as (value, label), so callers following the documented contract will pass swapped data and get wrong behavior.
Suggested change
| """Pick one value from `options` (label, value) pairs.""" | |
| """Pick one value from `options` (value, label) pairs.""" |
Details
✨ AI Reasoning
The protocol method documentation now describes options in an order that conflicts with how the runtime code interprets it. This creates an impossible-to-satisfy assumption for callers trying to follow the documented contract, leading to mismatched labels/values and incorrect selections.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolve everything on the repo's code-scanning quality tab (reproduced
locally with the same python/actions/javascript code-quality suites the
CodeQL workflow uploads; js+actions were already clean):
devnull fd after dup2 — close it in a finally; test asserts the close.
...bodies becomeone-line docstrings; the non-None-returning stubs gain @AbstractMethod
so mypy/pyright strict still accept the empty body, with no
never-executed line for the patch-coverage gate to miss.
multi-manager
with pytest.raises(...), telemetry.track(...)blocks sothe trailing assertions are visibly reachable to CodeQL's CFG.
imports in tests.
Then make the alerts un-regressable: a new check.sh stage
(scripts/codeql_gate.py) runs the exact security + quality suites over a
python/actions/javascript db-cluster and fails on any finding. Self-skips
without the CodeQL bundle on PATH (codeql.yml stays the CI enforcement,
so PRs aren't double-scanned); the web session-start hook now provisions
the bundle, pinned in gate_tool_pins.sh.
https://claude.ai/code/session_01DW3ZQmfbnKsgjrA4PnsF8U