-
Notifications
You must be signed in to change notification settings - Fork 0
fix(guardrails): address code-reviewer findings — 3 CRITICAL + 4 HIGH #146
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -486,16 +486,21 @@ | |||||
| } | ||||||
|
|
||||||
| function parseFindings(raw: string) { | ||||||
| // Count only actionable findings — exclude negations like "No CRITICAL issues found" | ||||||
| // Match structured finding patterns: "[CRITICAL]", "**CRITICAL**", "CRITICAL:", "- CRITICAL" | ||||||
| // Exclude negations, injected context lines, and prose mentions | ||||||
| const lines = raw.split("\n") | ||||||
| let critical = 0, high = 0, medium = 0, low = 0 | ||||||
| for (const line of lines) { | ||||||
| const neg = /\b(no|zero|0|none|without|aren't|isn't|not)\b/i.test(line) | ||||||
| if (neg) continue | ||||||
| if (/\bCRITICAL\b/i.test(line)) critical++ | ||||||
| if (/\bHIGH\b/i.test(line)) high++ | ||||||
| if (/\bMEDIUM\b/i.test(line)) medium++ | ||||||
| if (/\bLOW\b/i.test(line)) low++ | ||||||
| const trimmed = line.trim() | ||||||
| // Skip negation lines | ||||||
| if (/\b(no|zero|0|none|without|aren't|isn't|not)\b/i.test(trimmed)) continue | ||||||
| // Skip injected guardrail context lines (e.g., "CRITICAL=0 HIGH=0") | ||||||
| if (/CRITICAL=\d|HIGH=\d|checklist|Guardrail mode/i.test(trimmed)) continue | ||||||
| // Match structured patterns: leading marker or bracketed/bold severity | ||||||
|
Comment on lines
+494
to
+499
|
||||||
| if (/^[\s\-*]*\[?CRITICAL\]?[\s:*]/i.test(trimmed) || /^\*\*CRITICAL\*\*/i.test(trimmed)) critical++ | ||||||
| if (/^[\s\-*]*\[?HIGH\]?[\s:*]/i.test(trimmed) || /^\*\*HIGH\*\*/i.test(trimmed)) high++ | ||||||
| if (/^[\s\-*]*\[?MEDIUM\]?[\s:*]/i.test(trimmed) || /^\*\*MEDIUM\*\*/i.test(trimmed)) medium++ | ||||||
| if (/^[\s\-*]*\[?LOW\]?[\s:*]/i.test(trimmed) || /^\*\*LOW\*\*/i.test(trimmed)) low++ | ||||||
| } | ||||||
| return { critical, high, medium, low, total: critical + high + medium + low } | ||||||
| } | ||||||
|
|
@@ -526,11 +531,18 @@ | |||||
| return | ||||||
| } | ||||||
| const findings = parseFindings(result.text) | ||||||
| const attempts = num(data.workflow_review_attempts) + 1 | ||||||
| if (attempts >= 3) { | ||||||
|
||||||
| if (attempts >= 3) { | |
| if (attempts > 3) { |
Check failure on line 1547 in packages/guardrails/profile/plugins/guardrail.ts
GitHub Actions / unit (linux)
ReferenceError: bashData is not defined
at <anonymous> (/home/runner/work/opencode/opencode/packages/guardrails/profile/plugins/guardrail.ts:1547:34)
Check failure on line 1547 in packages/guardrails/profile/plugins/guardrail.ts
GitHub Actions / unit (linux)
ReferenceError: bashData is not defined
at <anonymous> (/home/runner/work/opencode/opencode/packages/guardrails/profile/plugins/guardrail.ts:1547:34)
Check failure on line 1547 in packages/guardrails/profile/plugins/guardrail.ts
GitHub Actions / unit (linux)
ReferenceError: bashData is not defined
at <anonymous> (/home/runner/work/opencode/opencode/packages/guardrails/profile/plugins/guardrail.ts:1547:34)
Copilot
AI
Apr 8, 2026
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.
bashData is referenced here but is not defined in the tool.execute.after hook scope (only data is). This will fail typecheck / runtime. Use the data already loaded in this hook, or fetch a fresh snapshot with await stash(state) inside this block before reading workflow_phase.
| const currentPhase = str(bashData.workflow_phase) | |
| const currentPhase = str(data.workflow_phase) |
Copilot
AI
Apr 8, 2026
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.
The comment says follow-up issue guidance is shown only during an "active pipeline", but the condition includes the "blocked" phase (it only excludes idle/done). If blocked should not be treated as active, align this condition with the pipelineActive logic (exclude "blocked" too).
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.
The deny rules for
gh pr mergeflags are ineffective as written: permission evaluation uses the last matching rule, and"gh pr merge*": allowcomes after the deny entries, overriding them for--admin/--automerges. Also, the patterns"gh pr merge * --admin*"/"... * --auto*"can be bypassed by putting the flag first (e.g.,gh pr merge --admin 123). Move the deny rules after the allow rule (or narrow the allow rule), and use patterns that match the flag in any position (e.g., without requiring an extra arg before the flag).