Skip to content

fix(ci): follow-up for CodeQL alerts #1 and #12 - #91

Merged
krassx merged 2 commits into
mainfrom
fix/code-scanning-followup
Oct 26, 2026
Merged

krassx merged 2 commits into
mainfrom
fix/code-scanning-followup

Conversation

@krassx

@krassx krassx commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #90, which cleared #2–#10. Two alerts remained or appeared after the rescan:

  • ci(deps): bump the github-actions group across 1 directory with 2 updates #1 py/path-injection (scripts/e2e_flows.py): os.path.basename was safe but isn't a sanitizer CodeQL recognizes. cappath now resolves the path with realpath and raises if it escapes the capture dir.
  • chore(deps): bump zip from 7.2.0 to 8.6.0 #12 actions/untrusted-checkout (npm-publish.yml): the checkout now uses workflow_run.head_sha (the exact commit the Release built) instead of the tag name, so a force-pushed tag can't redirect a job that runs npm/build.mjs with OIDC publish rights. Manual dispatch has no workflow_run, so it falls back to the typed tag. CodeQL may still flag the checkout-then-run shape; if so, dismiss as won't-fix (publish-from-release is the design; trigger requires write access + a successful tag-push Release).

Not in this PR: #11 (rust/cleartext-logging) is a false positive on a test assert message printing Mach-O UUIDs — dismiss in the UI as "used in tests".

Test plan

  • actionlint clean on npm-publish.yml
  • scripts/e2e_flows.py — ALL PASS; cappath("../x") raises, cappath("a.bin") resolves inside the dir
  • CI green
  • Next release: confirm the npm publish job checks out the tagged commit

🤖 Generated with Claude Code

- npm-publish: check out workflow_run.head_sha (the commit Release built)
  rather than the tag name; dispatch still falls back to the typed tag.
- e2e mock server: cappath resolves and verifies containment in the
  capture dir (the sanitizer CodeQL recognizes) instead of relying on
  basename alone.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 668a0908-7220-46b4-afc9-c8bdf24c0ec2
Commits

Reviewing files that changed from the base of the PR and between efd0b12 and 131dc45.

Files ignored due to path filters: 1
  • scripts/__pycache__/e2e_flows.cpython-314.pyc is excluded by !**/*.pyc
Files selected for processing: 3
  • .github/workflows/npm-publish.yml
  • .gitignore
  • scripts/e2e_flows.py

Limit details: You’ve used all 10 included reviews currently available.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Capture paths are now checked to ensure they stay within the designated capture directory; attempts to escape it are rejected.
  • Chores
    • Release publishing now uses the triggering release’s commit when available, or the resolved tag for manual runs.
    • Python cache directories and bytecode files are now excluded from version control.

The publish workflow uses the triggering Release run’s commit SHA when available and uses the resolved tag for manual dispatches. cappath resolves candidate paths and raises ValueError when a path is outside the resolved capture directory. .gitignore now excludes Python bytecode cache directories and .pyc files.

Possibly related PRs

  • bugsee/bugsee-cli#90: This PR also changes scripts/e2e_flows.py and .github/workflows/npm-publish.yml as part of the same CodeQL remediation work.

Priority: Low

Change: Bug fix

Merge Risk: Minimal · up to 131dc

The publish checkout and capture-path changes have no established merge-blocking issue; they are ready for normal checks.

Security architecture risk: Low · up to 131dc

The changes tighten publish-source selection and capture-file containment without expanding permissions. No introduced or worsened security concern was identified. Some uncertainty remains because the release-to-checkout mapping has not been demonstrated by an actual run, and registry-side publishing permissions were not verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The higher-impact boundary is package publication: code executing in this workflow can potentially affect downstream consumers of packages that authorize it through registry trust. The workflow describes eight packages across two jobs, but the effective authorized package set depends on registry-side settings that were not verified. The capture change is confined to a loopback test harness and its temporary filesystem workspace.

Security Findings and Attack Paths

  • inferred — No introduced or worsened security attack path was identified in the inspected changes. Automated checkout no longer follows a subsequently moved tag when head_sha is present. Manual tag selection and tag-addressed asset downloads remain pre-existing trust dependencies, not new PR concerns.

Trust Boundaries and Controls

  • observed — Request-derived PUT names pass through basename before reaching cappath and open. The new resolved-path gate additionally rejects escape through traversal or an already-resolved outside symlink target. This strengthens the request-to-filesystem boundary without adding authentication or changing the loopback listener.

Resilience and Maintainability Implications

  • inferred — Containment rejection fails before opening an outside capture path. Existing lifecycle limitations remain: PUT accounting occurs before persistence, and realpath validation is not atomic with open. Capture locking does not protect against an independent filesystem actor replacing a symlink. These limitations predate the PR, and no increased exposure was established.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the CI follow-up for CodeQL alerts, which matches the path-validation and checkout changes.
Description check Passed The description directly explains both security-related changes, test results, remaining risks, and out-of-scope items.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 3
  • Waived: $0.75 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Comment @coderabbitai help to get the list of available commands.

@claude

claude Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 32s —— View job


Review of PR #91: CodeQL follow-up for alerts #1 and #12

I read the diff and the surrounding code: the publish-optional-deps job's resolve and checkout steps, every cappath caller, and .gitignore. I did not run actionlint or the e2e script. The Test plan's claims for those are the author's.

No blocking findings.

Checked

  • npm-publish.yml, checkout pinned to workflow_run.head_sha.
    • For a tag-push Release run, head_sha is the commit the tag pointed at when the run started. That is the commit cargo-dist built. This closes the force-pushed-tag window between Release finishing and this job starting.
    • The || fallback is correct. github.event.workflow_run is empty on workflow_dispatch, so the typed, regex-validated tag is used. On the automated path head_sha is non-empty.
    • The if: guard (success, event == 'push', head_branch starts with v) is unchanged. The step is still gated on should_publish, and persist-credentials: false is kept.
    • The Download platform binaries step still resolves assets by the tag name, not the SHA. If the tag were force-moved, the checked-out npm/build.mjs and the downloaded release assets could disagree. The existing Cargo.toml version cross-check in build.mjs catches a version mismatch. I did not look at that step's code in this review, so treat this as a residual edge rather than a verified gap. Same-version content drift is not caught by any check I looked at.
  • scripts/e2e_flows.py, cappath.
    • realpath on both the root and the joined path, plus a root + os.sep prefix check, is the right containment pattern. It avoids the /tmp/cap vs /tmp/cap-evil prefix bug.
    • It also resolves symlinks inside the capture dir. That is stricter than before and safe here, because the harness only writes regular files there.
    • The one caller that takes a request-derived name (do_PUT, line 119) already applies basename, so it cannot hit the ValueError. A .. segment becomes ...bin, and an empty name becomes .bin. Both stay inside the dir. Raising from a handler would only surface as a failed flow in a test harness, not as a security problem.
    • The basename call and its comment at line 117 are now redundant with cappath's check. They are harmless as defence in depth.

Minor (P3, non-blocking)

  • scripts/__pycache__/e2e_flows.cpython-314.pyc was committed, and this PR deletes it. Nothing in .gitignore prevents it coming back. grep found no __pycache__ or *.pyc entry. Any local run of the e2e script will recreate the file, and it can be committed again. Suggest adding __pycache__/ and *.pyc to .gitignore in this PR.
  • CodeQL may still flag chore(deps): bump zip from 7.2.0 to 8.6.0 #12. The PR description already says so and gives a dismissal rationale. That is reasonable. Pinning to an immutable SHA is a real hardening even if the query keeps matching the checkout-then-run shape.

Summary

  1. Overall risk: Low. The change is CI-only, with no product code touched.
  2. Merge recommendation: Approve and merge once CI is green. Adding the .gitignore entry first is optional but recommended.
  3. Most important item: the .gitignore entry for __pycache__/ and *.pyc.
  4. Positives:
    • The checkout comment explains the threat model clearly.
    • The SHA pin is the correct fix for a mutable ref feeding OIDC-privileged code.
    • cappath is a clean, correctly written containment check.
    • The unchecked "Next release" test-plan item is the right way to validate the workflow change.

The e2e harness recreates scripts/__pycache__ on every local run; #90
committed one by accident and this PR removes it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@krassx

krassx commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the P3: added __pycache__/ and *.pyc to .gitignore (the stray .pyc came in with #90 and is removed here). The CodeQL untrusted-checkout annotation on npm-publish.yml is the expected #12 re-match; the plan is to dismiss it as won't-fix after merge. Noted the residual that Download platform binaries still resolves assets by tag name — out of scope here (build.mjs's Cargo.toml version cross-check covers the realistic case).

@claude

claude Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Claude finished @krassx's task in 16s —— View job


Re-review of PR #91 after the new push (131dc45)

I re-read the full diff against origin/main and the surrounding code. I did not run actionlint, cargo, or the e2e script. The Test plan results are the author's.

No new findings, so I posted no inline comments.

Earlier finding

  • .gitignore entry for Python bytecode (my earlier P3): fixed by 131dc45. __pycache__/ and *.pyc are now ignored, so the deleted scripts/__pycache__/e2e_flows.cpython-314.pyc should not come back.

Re-checked this round

  • npm-publish.yml, checkout ref: github.event.workflow_run.head_sha || steps.resolve.outputs.tag is correct. head_sha is set on the automated workflow_run path, and the typed tag is the fallback for workflow_dispatch.
  • Download step, which I had flagged as a residual edge: it runs gh release download "$TAG" (line 306). That fetches assets from the release object, not from the git ref. A force-moved tag therefore cannot change those assets. The only exposure is the checked-out npm/build.mjs versus the assets, and the SHA pin now closes that. I'm withdrawing the residual-edge note.
  • cappath: the realpath plus root + os.sep containment check is sound. It correctly rejects sibling-prefix paths such as cap-evil.

Summary

  1. Overall risk: Low. The change is CI and harness only, with no product code touched.
  2. Merge recommendation: Approve and merge once CI is green. After the next release, confirm the npm publish job checked out the tagged commit, as the Test plan already lists.
  3. Most important issues: none outstanding.
  4. Positives:
    • The SHA pin is the right hardening for a mutable ref feeding OIDC-privileged code.
    • cappath is a clean containment check.
    • The PR description is honest about the alert that CodeQL may keep flagging and gives a dismissal rationale.
    • The .gitignore follow-up landed promptly.

@krassx
krassx merged commit 40d3d77 into main Oct 26, 2026
25 of 26 checks passed
@krassx
krassx deleted the fix/code-scanning-followup branch October 26, 2026 13:18
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