Fix CodeQL alerts: workflow permissions and shell injection - #22
Merged
Conversation
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.
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.
Alert #1 (actions/missing-workflow-permissions,
.github/workflows/main.yml:12) — the single
buildjob only checks outthe repo, sets up Ruby, and runs
bundle exec rake(rspec + rubocop).No writes of any kind, so a workflow-level
contents: readis thecorrect least privilege. Placed at the workflow level after
on:, whichmatches the existing style in this repo's release.yml.
Alert #2 (rb/shell-command-constructed-from-input,
lib/chatwerk/cli.rb:20) — the
inspectThor command interpolated theuser-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 argvelement 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
rb/shell-command-constructed-from-input(medium) —lib/chatwerk/cli.rb:20actions/missing-workflow-permissions(medium) —.github/workflows/main.yml:12Verification
permissions:block (cross-checked by parsing the YAML against the alert list).actionlintoutput is byte-identical tomain— no new findings introduced.codeql.ymluntouched.