Repository navigation
Audit: lower nothing in a file with a hidden line break or after a backslash - #309
Conversation
…ckslash; say what the audit is not
Reviewer's GuideImplementationPrevent script findings from being lowered when hidden line breaks can affect later lines or a preceding backslash continues the line, while leaving Markdown behavior unchanged.
UIUse “no audit rule matched” for the passing audit result in the doctor output and site mock.
DocumentationExplain the audit’s limits as a per-line pattern check and update the upgrade note to describe the hidden-line-break limitation.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="internal/app/audit_rules.go" line_range="423" />
<code_context>
continue
}
- add(newRuleFinding(rule, file, m, (lowered[i] || low) && !hidden))
+ add(newRuleFinding(rule, file, m, (lowered[i] || low) && !breaks && !joined))
}
}
</code_context>
<issue_to_address>
**Changed critical findings stay accepted**
When an accepted lower-severity finding keeps the same matched text and file path after a hidden break or continuation changes its severity to critical, `auditEvidence` omits severity and surrounding context, so `isAccepted` reuses the old approval and `unacceptedCritical` lets sync admit the changed external candidate.
Include severity and relevant surrounding context in the acceptance evidence so a newly critical finding requires a new approval.
</issue_to_address>
### Comment 2
<location path="internal/app/audit_rules.go" line_range="417" />
<code_context>
- hidden := hiddenLineBreak(line)
+ // A line after one that ends with a backslash continues it in a shell
+ // and in most languages, so it is never lowered.
+ joined := i > 0 && strings.HasSuffix(strings.TrimSuffix(lines[i-1], "\r"), `\`)
for _, rule := range auditRules {
m, low := ruleMatch(rule, line, prose[i])
</code_context>
<issue_to_address>
**Harmless external content is blocked**
When a Markdown prose line, comment, or even run of backslashes ends a line without continuing it, and the next line has a framed match that would otherwise be lowered, `scanText` sets `joined` from any raw trailing backslash, so `newRuleFinding` leaves the next match CRITICAL and `auditBlock` or `unacceptedCritical` blocks otherwise harmless external content from syncing.
Make `joined` recognize only actual continuations for the file syntax, excluding Markdown hard breaks, comments, and escaped or even backslashes.
Also at `internal/app/audit_rules.go:418-423`.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: internal/app/audit_rules.go:423, internal/app/audit_rules.go:417
What and why
Follow-up to #300. The audit counts a match one level lower when the line looks like a comment or a docstring. In scripts, two cases still let code that runs look like one of those:
Markdown is left as it was: nothing in it runs, and there a backslash ends a hard line break or a continued line in a fenced example.
docs/skills.mdand the 3.0 notes now say what the audit is: a pattern check per line, not a parser or a sandbox. To match,tackroom doctorand the site mock say "no audit rule matched" instead of "no risky patterns".How I checked it
go test ./...,go vet ./...,gofmt,scripts/release_test.shand thetools/sitedocsbuild pass.93 Python, shell, JavaScript and Markdown files run through
scanTextonmainand on this branch. Two scripts that run their command underpython3andshwere pinned onmainand are blocked now. The other 91 keep their verdict, including CRLF files with warning comments, a fenced example with a continuation line and a warning after a Markdown hard line break.One new block: in a script, a comment line placed directly after a line that ends with a backslash.
go test ./...andgo vet ./...passI can explain this change without an AI tool
Summary by Sourcery
Keep executable content from being misclassified as comments or docstrings when hidden line breaks or line continuations affect script parsing.
Bug Fixes:
Enhancements:
Documentation: