Skip to content

security: apply all audit fixes (H-01 through I-04)#13

Merged
vyahello merged 6 commits intomasterfrom
security/audit-fixes
Mar 23, 2026
Merged

security: apply all audit fixes (H-01 through I-04)#13
vyahello merged 6 commits intomasterfrom
security/audit-fixes

Conversation

@vyahello
Copy link
Copy Markdown
Owner

Summary

Addresses all 14 findings from a full security audit of the repository, covering supply chain risks, plugin logic flaws, CI/CD hardening, and code quality.

Changes by severity

🔴 High

  • H-01: Pin GitHub Actions to immutable commit SHAs — actions/checkout@v1 → v4.2.2 SHA, actions/setup-python@v1 → v5.4.0 SHA. Mutable @v1 tags are from 2019 and vulnerable to supply chain compromise.
  • H-02: Remove unused astpretty==2.1.0 production dependency. It was never imported, adding unnecessary attack surface for all users.

🟠 Medium

  • M-01: Add self.generic_visit(node) to DebugVisitor.visit_Call — nested debug calls such as foo(print(x)) or lambda: breakpoint() were silently bypassing detection.
  • M-02: Restrict attribute-based detection to known debugger modules (pdb, ipdb) — previously any object with a method named print, breakpoint, or set_trace triggered a false positive (e.g. logger.print(), self.breakpoint()).
  • M-03: Update severely outdated dev dependencies: coverage 5.3→7.13.5, pytest-cov 3.0.0→7.1.0, coveralls 2.1.2→4.1.0, wheel 0.45.1→0.46.3.
  • M-04 (partial): Switch coveralls integration from broad GITHUB_TOKEN to scoped COVERALLS_REPO_TOKEN secret.

🟡 Low

  • L-01: Restrict CI trigger to master branch pushes/PRs only; add permissions: contents: read least-privilege block.
  • L-02: Move from flake8_debug.meta import Meta inside if __name__ == '__main__': in setup.py to prevent source package execution at pip install time.
  • L-03: Add RecursionError guard in NoDebug.run() for pathologically nested ASTs (Python 3.9–3.12 vulnerability).
  • L-04: Add .github/SECURITY.md with supported versions table and responsible disclosure instructions.

ℹ️ Informational

  • I-01: Remove dead self._filename attribute from NoDebug.__init__ (parameter kept for flake8 API compatibility).
  • I-03: Error base class now inherits from abc.ABC for proper abstract base class semantics.
  • I-04: Remove tracked __pycache__ and .DS_Store files from git index.

Tests

  • All 16 tests pass (was 11 before)
  • 5 new regression tests added:
    • test_nested_print_is_detected — verifies M-01 fix
    • test_nested_breakpoint_is_detected — verifies M-01 fix
    • test_no_false_positive_on_arbitrary_object_print — verifies M-02 fix
    • test_no_false_positive_on_arbitrary_object_breakpoint — verifies M-02 fix
    • test_no_false_positive_on_arbitrary_object_set_trace — verifies M-02 fix

Action required after merge

  • Add COVERALLS_REPO_TOKEN as a repository secret in GitHub Settings → Secrets (replaces GITHUB_TOKEN for coveralls uploads).

vyahello and others added 4 commits March 23, 2026 15:32
H-01: Pin GitHub Actions to immutable commit SHAs
  - actions/checkout@v1 → @11bd71901bbe5b1630ceea73d27597364c9af683 (v4.2.2)
  - actions/setup-python@v1 → @42375524bfc43e60c680de71eb3fd7bc68ee5416 (v5.4.0)

H-02: Remove phantom astpretty==2.1.0 production dependency (unused)

M-01: Fix detection bypass — add generic_visit(node) to DebugVisitor.visit_Call
  so nested debug calls (e.g. foo(print(x))) are no longer silently missed

M-02: Fix false positives on arbitrary objects — restrict attribute-based
  detection to known debugger modules (pdb, ipdb) only for set_trace

M-03: Update outdated dev dependencies
  - pytest-cov 3.0.0 → 7.1.0
  - coverage 5.3 → 7.13.5
  - coveralls 2.1.2 → 4.1.0
  - wheel 0.45.1 → 0.46.3

L-01: Restrict CI trigger to master branch; add least-privilege permissions block
  Use COVERALLS_REPO_TOKEN instead of broad GITHUB_TOKEN for coveralls

L-02: Move Meta import inside if __name__ == '__main__' in setup.py to prevent
  source package execution at pip install time

L-03: Add RecursionError guard in NoDebug.run() for pathologically nested ASTs

L-04: Add .github/SECURITY.md with vulnerability disclosure policy

I-01: Remove unused self._filename attribute from NoDebug.__init__

I-03: Inherit Error from abc.ABC for proper abstract base class semantics

I-04: Remove committed __pycache__ and .DS_Store files from git index

Tests: add 5 regression tests covering nested call detection and false-positive
  elimination for arbitrary object method calls

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad9d8cdf69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

coveralls==2.1.2
pytest-cov==7.1.0
coverage==7.13.5
coveralls==4.1.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep coveralls on a Python-3.9-compatible release

Pinning coveralls to 4.1.0 breaks one of the versions this repo still supports. PyPI metadata for 4.1.0 requires Python 3.10+, but .github/workflows/analysis.yml still installs requirements-dev.txt in the 3.9 matrix entry and setup.py still advertises Python 3.9 support. In practice, pip install -r requirements-dev.txt will now fail on 3.9 in CI and for contributors using the documented minimum version.

Useful? React with 👍 / 👎.

Comment on lines +10 to +11
# Only these func names are meaningful as attribute calls (e.g. pdb.set_trace())
_ATTR_DETECTABLE: frozenset = frozenset({'set_trace'})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve DB201 checks for qualified breakpointhook() calls

This allowlist now disables attribute-based matching for breakpointhook, so import sys; sys.breakpointhook() no longer emits DB201 even though it is the same debugger hook the plugin already reports when imported directly. The previous matcher caught the stdlib-qualified form, so this change introduces a real false negative in the core lint rule.

Useful? React with 👍 / 👎.

Comment on lines +31 to +32
and isinstance(node.func.value, ast.Name)
and node.func.value.id in _DEBUGGER_MODULES
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Track aliased debugger imports before filtering set_trace

Restricting set_trace checks to literal names pdb and ipdb misses common alias imports such as import pdb as dbg; dbg.set_trace() or import ipdb as debugger; debugger.set_trace(). Those are still debugger calls, and previous versions reported them, but this branch now lets them pass silently because node.func.value.id is dbg/debugger instead of one of the hard-coded identifiers.

Useful? React with 👍 / 👎.

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 23, 2026

Pull Request Test Coverage Report for Build 23440449867

Details

  • 14 of 16 (87.5%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-3.2%) to 96.774%

Changes Missing Coverage Covered Lines Changed/Added Lines %
flake8_debug/plugin.py 12 14 85.71%
Totals Coverage Status
Change from base Build 19011271142: -3.2%
Covered Lines: 60
Relevant Lines: 62

💛 - Coveralls

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 23, 2026

Pull Request Test Coverage Report for Build 23440205493

Details

  • 14 of 16 (87.5%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-3.2%) to 96.774%

Changes Missing Coverage Covered Lines Changed/Added Lines %
flake8_debug/plugin.py 12 14 85.71%
Totals Coverage Status
Change from base Build 19011271142: -3.2%
Covered Lines: 60
Relevant Lines: 62

💛 - Coveralls

vyahello and others added 2 commits March 23, 2026 15:41
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vyahello vyahello merged commit 62474e7 into master Mar 23, 2026
5 checks passed
@vyahello vyahello deleted the security/audit-fixes branch March 23, 2026 13:46
vyahello added a commit that referenced this pull request Mar 23, 2026
* security: apply all audit fixes (H-01 through I-04)

H-01: Pin GitHub Actions to immutable commit SHAs
  - actions/checkout@v1 → @11bd71901bbe5b1630ceea73d27597364c9af683 (v4.2.2)
  - actions/setup-python@v1 → @42375524bfc43e60c680de71eb3fd7bc68ee5416 (v5.4.0)

H-02: Remove phantom astpretty==2.1.0 production dependency (unused)

M-01: Fix detection bypass — add generic_visit(node) to DebugVisitor.visit_Call
  so nested debug calls (e.g. foo(print(x))) are no longer silently missed

M-02: Fix false positives on arbitrary objects — restrict attribute-based
  detection to known debugger modules (pdb, ipdb) only for set_trace

M-03: Update outdated dev dependencies
  - pytest-cov 3.0.0 → 7.1.0
  - coverage 5.3 → 7.13.5
  - coveralls 2.1.2 → 4.1.0
  - wheel 0.45.1 → 0.46.3

L-01: Restrict CI trigger to master branch; add least-privilege permissions block
  Use COVERALLS_REPO_TOKEN instead of broad GITHUB_TOKEN for coveralls

L-02: Move Meta import inside if __name__ == '__main__' in setup.py to prevent
  source package execution at pip install time

L-03: Add RecursionError guard in NoDebug.run() for pathologically nested ASTs

L-04: Add .github/SECURITY.md with vulnerability disclosure policy

I-01: Remove unused self._filename attribute from NoDebug.__init__

I-03: Inherit Error from abc.ABC for proper abstract base class semantics

I-04: Remove committed __pycache__ and .DS_Store files from git index

Tests: add 5 regression tests covering nested call detection and false-positive
  elimination for arbitrary object method calls

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* revert: restore analysis.yml to original state

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: remove Python 3.9 from test matrix

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: shorten comment in plugin.py to satisfy E501 line length

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs: update minimum Python version to 3.10 in README

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* remove: delete redundant SECURITY.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants