Skip to content

Audit: lower nothing in a file with a hidden line break or after a backslash - #309

Merged
yourconscience merged 4 commits into
mainfrom
audit-followup
Nov 20, 2026
Merged

yourconscience merged 4 commits into
mainfrom
audit-followup

Conversation

@yourconscience

@yourconscience yourconscience commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

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:

  • A hidden line break (a carriage return before the end of a line, U+2028 or U+2029) changes how the lines after it are read, not only its own line. A script that holds one now lowers nothing. Release tackroom 3.0.0 #300 covered only the line with the break.
  • A line after one that ends with a backslash continues it in a shell and in most languages, so in a script it is never lowered now.

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.md and the 3.0 notes now say what the audit is: a pattern check per line, not a parser or a sandbox. To match, tackroom doctor and 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.sh and the tools/sitedocs build pass.

  • 93 Python, shell, JavaScript and Markdown files run through scanText on main and on this branch. Two scripts that run their command under python3 and sh were pinned on main and 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 ./... and go vet ./... pass

  • I 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:

  • Prevent audit findings in scripts from being lowered when hidden line breaks or preceding backslash continuations can cause following lines to execute as code.

Enhancements:

  • Clarify that the audit is a per-line pattern check rather than a parser or sandbox.
  • Preserve Markdown-specific handling while applying continuation safeguards only to scripts.

Documentation:

  • Update audit guidance, upgrade notes, and site output to describe audit limitations and use clearer pass messaging.

@sourcery-ai

sourcery-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Prevent 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.

  • internal/app/audit_rules.go L379-381, L410-420, L426

UI

Use “no audit rule matched” for the passing audit result in the doctor output and site mock.

  • docs/site/index.html L224
  • internal/app/audit.go L107

Documentation

Explain the audit’s limits as a per-line pattern check and update the upgrade note to describe the hidden-line-break limitation.

  • docs/skills.md L119-120
  • docs/upgrading.md L45

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b1015b6e-7dd2-46ca-a0d5-74584b008573
Commits

Reviewing files that changed from the base of the PR and between 6c74d74 and 63c1605.

Files selected for processing: 5

  • docs/site/index.html
  • docs/skills.md
  • docs/upgrading.md
  • internal/app/audit.go
  • internal/app/audit_rules.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread internal/app/audit_rules.go Resolved
Comment thread internal/app/audit_rules.go Resolved
@yourconscience
yourconscience merged commit 89229a2 into main Nov 20, 2026
11 checks passed
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