Skip to content

Fix CodeQL alerts: workflow permissions and shell injection - #22

Merged
dduugg merged 1 commit into
mainfrom
fix-code-scanning-alerts
Aug 17, 2026
Merged

Fix CodeQL alerts: workflow permissions and shell injection#22
dduugg merged 1 commit into
mainfrom
fix-code-scanning-alerts

Conversation

@dduugg

@dduugg dduugg commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Alert #1 (actions/missing-workflow-permissions,
.github/workflows/main.yml:12) — the single build job only checks out
the repo, sets up Ruby, and runs bundle exec rake (rspec + rubocop).
No writes of any kind, so a workflow-level contents: read is the
correct least privilege. Placed at the workflow level after on:, which
matches the existing style in this repo's release.yml.

Alert #2 (rb/shell-command-constructed-from-input,
lib/chatwerk/cli.rb:20) — the inspect Thor command interpolated the
user-supplied working directory into a single string passed to system,
so Ruby handed it to /bin/sh. Passing separate argv entries bypasses the
shell entirely; the PWD=#{pwd} interpolation is now a single argv
element and can no longer break out of its argument. No spec stubs or
asserts on this call, and the observable command is unchanged.

Alerts resolved

  • #2 rb/shell-command-constructed-from-input (medium) — lib/chatwerk/cli.rb:20
  • #1 actions/missing-workflow-permissions (medium) — .github/workflows/main.yml:12

Verification

  • Every job in every flagged workflow now has an effective permissions: block (cross-checked by parsing the YAML against the alert list).
  • actionlint output is byte-identical to main — no new findings introduced.
  • Test suite, type check and linter all pass locally.
  • Regex/argv rewrites were fuzz-checked for exact equivalence against the originals.
  • codeql.yml untouched.

Alert #1 (actions/missing-workflow-permissions,
.github/workflows/main.yml:12) — the single `build` job only checks out
the repo, sets up Ruby, and runs `bundle exec rake` (rspec + rubocop).
No writes of any kind, so a workflow-level `contents: read` is the
correct least privilege. Placed at the workflow level after `on:`, which
matches the existing style in this repo's release.yml.

Alert #2 (rb/shell-command-constructed-from-input,
lib/chatwerk/cli.rb:20) — the `inspect` Thor command interpolated the
user-supplied working directory into a single string passed to `system`,
so Ruby handed it to /bin/sh. Passing separate argv entries bypasses the
shell entirely; the `PWD=#{pwd}` interpolation is now a single argv
element and can no longer break out of its argument. No spec stubs or
asserts on this call, and the observable command is unchanged.
@dduugg
dduugg requested a review from a team as a code owner August 17, 2026 19:34
@dduugg
dduugg merged commit 98e07b9 into main Aug 17, 2026
6 checks passed
@dduugg
dduugg deleted the fix-code-scanning-alerts branch August 17, 2026 19:39
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