Skip to content

Fix remediation for transitive pip dependency alerts#52

Merged
groovecoder merged 5 commits into
mainfrom
debug-remediate
May 27, 2026
Merged

Fix remediation for transitive pip dependency alerts#52
groovecoder merged 5 commits into
mainfrom
debug-remediate

Conversation

@groovecoder
Copy link
Copy Markdown
Member

Summary

  • When a pip transitive dependency (e.g. idna via requests) has no direct pin, detect the repo's lock tool (uv/poetry/pipenv) and run uv lock --upgrade-package (or equivalent) to create a bump PR. Previously the script gave up with action=noop.
  • Fix verdict extraction when CLAUDE_VERBOSE=true. The --output-format json wraps Claude's text in a JSON event array; the regex for VERDICT_JSON blocks never matched the escaped strings.
  • Fetch the patched version from the Dependabot alert API when ALERT_PATCHED_VERSION is empty (e.g. manual workflow dispatch).

Changes

  • scripts/post_alert_action.pydetect_pip_lock_tool() checks for lock files via the GitHub API. fetch_patched_version() fills in missing patched version from the alert. Also searches pyproject.toml for direct pins.
  • scripts/pip-lock-bump.sh — New script mirroring npm-bump.sh: commits lock file changes via API and opens a PR.
  • .github/workflows/investigate-security-alert.yml — New pip_lock_bump steps between npm bump and private fork sections.
  • scripts/extract_alert_verdict.py — Parses JSON session logs to extract assistant text before searching for verdict blocks.
  • scripts/alert_report.py — Added pip_lock_bump action label.

Test plan

groovecoder and others added 4 commits May 27, 2026 10:20
…tive deps

When create_bump_pr() can't find a dependency pin (e.g. idna via
requests), enable automated security fixes on the repo so Dependabot
will attempt the update. Also search pyproject.toml for pip pins.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When CLAUDE_VERBOSE=true, run-claude.sh uses --output-format json.
The verdict text is inside a JSON string, so the regex for
```VERDICT_JSON blocks never matched. Now extract_alert_verdict.py
parses the JSON event array first and searches the assistant text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a pip transitive dependency has no direct pin, detect the repo's
lock tool (uv/poetry/pipenv) and run the upgrade in CI. Replaces the
request_dependabot_update fallback which did nothing for lock files.

New scripts/pip-lock-bump.sh mirrors the npm-bump.sh pattern: upgrade
the lock file, commit via API, and open a PR.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When ALERT_PATCHED_VERSION is empty (e.g. manual workflow dispatch),
post_alert_action.py now fetches it from the alert API before giving up.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread .github/workflows/investigate-security-alert.yml
Comment thread scripts/pip-lock-bump.sh
Comment thread tests/scripts/test_post_alert_action.py Outdated
Comment thread tests/scripts/test_post_alert_action.py Outdated
Parametrize TestDetectPipLockTool to make priority order obvious
(uv > poetry > pipenv). Extract shared pip env setup into
_run_pip_main helper to reduce boilerplate in TestPipLockBumpFlow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@groovecoder groovecoder merged commit e14f652 into main May 27, 2026
9 checks passed
@groovecoder groovecoder deleted the debug-remediate branch May 27, 2026 19:58
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.

1 participant