Repository navigation
fix(rules): close four gaps Codex found in #942 after it merged #947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1259,10 +1259,33 @@ defmodule Hypatia.Rules.WorkflowHardening do | |
|
|
||
| @doc """ | ||
| Return true when a write operation's failure is masked, so a denied write | ||
| cannot turn the job red. | ||
| cannot turn the job red: a shell mask on the write itself, or a STEP-level | ||
| `continue-on-error: true` in text that performs a write. The step flag is | ||
| judged per job body, so it may belong to a sibling step. A job-level | ||
| `continue-on-error` is not counted: it is a deliberate, visible job setting | ||
| (standards' github-backup-mirror-reusable.yml documents and surfaces it). | ||
| """ | ||
| def masked_write?(content) when is_binary(content) do | ||
| Enum.any?(@write_masks, &Regex.match?(&1, content)) | ||
| Enum.any?(@write_masks, &Regex.match?(&1, content)) or | ||
| (step_continue_on_error?(content) and performs_contents_write?(content)) | ||
|
Comment on lines
+1269
to
+1270
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When any non-writing sibling step has Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #950. Generated by Claude Code
Comment on lines
+1269
to
+1270
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #950. Both masked WH013 findings now name the step's Generated by Claude Code |
||
| end | ||
|
|
||
| # `continue-on-error: true` indented under a `steps:` key, i.e. on a step. | ||
| defp step_continue_on_error?(content) do | ||
| lines = String.split(content, "\n") | ||
|
|
||
| case Enum.find(lines, &Regex.match?(~r/^[ \t]*steps:[ \t]*$/, &1)) do | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In valid workflows using Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #950 (this PR has merged). The Generated by Claude Code |
||
| nil -> | ||
| false | ||
|
|
||
| steps_line -> | ||
| steps_indent = indent_of(steps_line) | ||
|
|
||
| Enum.any?(lines, fn line -> | ||
| Regex.match?(~r/^[ \t]*(?:-[ \t]+)?continue-on-error:[ \t]*true\b/, line) and | ||
| indent_of(line) > steps_indent | ||
| end) | ||
| end | ||
| end | ||
|
|
||
| # ─── Internals ────────────────────────────────────────────────────── | ||
|
|
@@ -1399,7 +1422,9 @@ defmodule Hypatia.Rules.WorkflowHardening do | |
|
|
||
| _ -> | ||
| cond do | ||
| line == "" or indent_of(line) >= jobs_indent + 1 -> | ||
| # A comment between jobs (` # Publish`) does not end `jobs:`. | ||
| line == "" or indent_of(line) >= jobs_indent + 1 or | ||
| String.starts_with?(String.trim_leading(line), "#") -> | ||
| {acc, true, jobs_indent, append_line(current, line)} | ||
|
Comment on lines
+1425
to
1428
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A comment at the jobs indentation now keeps extraction active but is also appended to the current job. Because WH013 scans job bodies as raw text, a separator such as Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #950. A comment between jobs keeps the parser in Generated by Claude Code |
||
|
|
||
| true -> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a double-quoted handler containing escaped quotes, such as
trap "kill \"$PID\" 2>/dev/null || true" EXIT, the pattern stops at the first escaped"and leaves the handler's|| truein the scanned text. A normally failing test step with only this cleanup trap is therefore reported as swallowing its exit; the handler matcher needs to consume shell escapes while still preserving commands after the closing quote.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #950. The double-quoted handler matcher now consumes backslash escapes, and a test covers
trap "kill \"$PID\" 2>/dev/null || true" EXIT.Generated by Claude Code