Skip to content

fix(ci): the invisible-character gate never matched anything - #81

Open
hyperpolymath wants to merge 2 commits into
mainfrom
fix/empty-linter-pattern-never-matched
Open

fix(ci): the invisible-character gate never matched anything#81
hyperpolymath wants to merge 2 commits into
mainfrom
fix/empty-linter-pattern-never-matched

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Measured 2026-08-27: this gate caught 0 of 6 invisible-character test cases. It has never detected an NBSP, zero-width space, BOM, soft hyphen, bidi override or word joiner.

Root cause

The pattern used UTF-8 byte sequences (\xc2\xa0) while grep -P matches characters. Bytes c2 a0 are one character U+00A0; \xc2\xa0 asks for two, U+00C2 then U+00A0 — never present.

grep -P '\xc2\xa0'  ->  miss
grep -P '\x{a0}'    ->  MATCH

Only \x00 worked, being single-byte in both readings. The gate ran, passed, and could not see what it exists to see.

Fixed

  • codepoint escapes in place of byte sequences
  • C0 controls \x01-\x08,\x0B,\x0C,\x0E-\x1F added (TAB/LF/CR excluded)
  • grep -a — without it grep skips any NUL-bearing file as binary

The C0 range matters: a stray backspace byte made a workflow unparseable in developer-ecosystem, so it never ran — and this linter called it clean.

Canonical fix: hyperpolymath/empty-linter#70. 1 file(s) here.

Verified: YAML re-parsed, and the corrected pattern was confirmed to catch a real NBSP before the change was kept.

MEASURED 2026-08-27: this gate's pattern caught 0 OF 6 invisible-character test
cases. It has never detected an NBSP, zero-width space, BOM, soft hyphen, bidi
override or word joiner.

ROOT CAUSE: the pattern used UTF-8 BYTE sequences (\xc2\xa0) while grep -P
matches CHARACTERS. Bytes c2 a0 are ONE character U+00A0; \xc2\xa0 asks for TWO
characters, U+00C2 then U+00A0, which is never present.

  grep -P '\xc2\xa0'  ->  miss
  grep -P '\x{a0}'    ->  MATCH

Only \x00 worked, being single-byte in both readings.

FIXED: codepoint escapes; C0 control characters \x01-\x08,\x0B,\x0C,\x0E-\x1F
added (TAB/LF/CR excluded); and grep -a, without which grep skips any NUL-bearing
file as binary.

The C0 range matters: a stray BACKSPACE byte made a workflow unparseable in
developer-ecosystem, so it never ran, and this linter called it clean.

Canonical fix: hyperpolymath/empty-linter#70. 1 file(s) here.
VERIFIED: YAML re-parsed, and the corrected pattern was confirmed to catch a real
NBSP before the change was kept.
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 34a5ccde-a7ca-4cdc-a339-885fe0386caa

📥 Commits

Reviewing files that changed from the base of the PR and between 5c9e8b5 and e29df4d.

📒 Files selected for processing (1)
  • .github/workflows/dogfood-gate.yml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (24)
  • GitHub Check: scan / rust-secrets
  • GitHub Check: scan / gitleaks
  • GitHub Check: governance / Licence consistency
  • GitHub Check: governance / Code quality + docs
  • GitHub Check: governance / Trusted-base reduction policy
  • GitHub Check: scan / shell-secrets
  • GitHub Check: governance / Workflow security linter
  • GitHub Check: governance / Check Workflow Staleness
  • GitHub Check: governance / Allowlist Preflight
  • GitHub Check: governance / Security policy checks
  • GitHub Check: governance / Well-Known (RFC 9116 + RSR)
  • GitHub Check: governance / Language / package anti-pattern policy
  • GitHub Check: governance / Guix packaging policy (Nix retired)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Hypatia Neurosymbolic Analysis
  • GitHub Check: fmt + clippy + test
  • GitHub Check: rescript + wasm + bun test + bundle
  • GitHub Check: analyze (rust, none)
  • GitHub Check: wasm build
  • GitHub Check: analyze (javascript-typescript, none)
  • GitHub Check: Validate K9 contracts
  • GitHub Check: Validate A2ML manifests
  • GitHub Check: Groove manifest check
  • GitHub Check: Empty-linter (invisible characters)
🔇 Additional comments (1)
.github/workflows/dogfood-gate.yml (1)

133-133: 🎯 Functional Correctness

Do not add a separate leading-BOM check. The existing grep -aPrl pattern includes \x{feff} and detects a UTF-8 BOM at the start of a file.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of invisible and control characters during automated checks.
    • Scanning now consistently examines binary files as text, helping identify hidden problematic characters.

Walkthrough

The workflow now detects invisible characters with Unicode code-point escapes. It includes additional control and format characters. The grep command treats binary files as text during scanning.

Changes

Invisible-character gate

Layer / File(s) Summary
Expand pattern and scan coverage
.github/workflows/dogfood-gate.yml
The PATTERNS regex uses Unicode code-point escapes and includes additional control and format characters. The grep scan uses -a to process binary files as text.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to e29df

The workflow now detects the intended invisible characters, including BOMs, without requiring a separate check. No actionable merge-blocking risk remains after normal checks and review.

Poem

A rabbit checks each hidden mark,
And scans the files from light to dark.
Code points now stand clear and bright,
Binary files join the sight.
Tiny controls no longer hide,
The gate now catches them inside.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The workflow pattern fixes codepoint matching, C0 control detection, and NUL-containing file scanning. However, the linked issue also requires a separate leading-BOM check and matching C0-control upda… Add the separate byte-wise leading-BOM check and update stdlib/ByteDetector.affine and config.ncl so the compiled linter uses the same C0-control detection. Confirm that all required inline copies are updated, or limit the issue scope e…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing the CI gate that failed to detect invisible characters.
Description check ✅ Passed The description directly explains the detection failure, the root cause, and the implemented fixes.
Out of Scope Changes check ✅ Passed The changes are limited to the CI invisible-character gate and directly support the linked issue objectives. No unrelated changes are shown.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Full details: Linked Issues check

Explanation

The workflow pattern fixes codepoint matching, C0 control detection, and NUL-containing file scanning. However, the linked issue also requires a separate leading-BOM check and matching C0-control updates in the compiled linter. The summary shows changes only in .github/workflows/dogfood-gate.yml [#70].

Resolution

Add the separate byte-wise leading-BOM check and update stdlib/ByteDetector.affine and config.ncl so the compiled linter uses the same C0-control detection. Confirm that all required inline copies are updated, or limit the issue scope explicitly.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

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

Comment @coderabbitai help to get the list of available commands.

@gitar-bot

gitar-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

Gitar is working

Gitar

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 27, 2026
@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 57 issues detected

Severity Count
🔴 Critical 6
🟠 High 31
🟡 Medium 20

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in scorecard.yml",
    "type": "missing_workflow",
    "file": "scorecard.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Workflow executes remote script directly (curl/wget piped to shell). Download, verify checksum/signature, then execute.",
    "type": "download_then_run",
    "file": "ui-ci.yml",
    "action": "verify_download_integrity",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in boj-build.yml",
    "type": "missing_timeout_minutes",
    "file": "boj-build.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in codeql.yml",
    "type": "missing_timeout_minutes",
    "file": "codeql.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production 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.

Pull Request Overview

The PR successfully updates the invisible-character detection gate to use PCRE codepoint escapes and the -a flag, which ensures that control characters and non-breaking spaces are correctly identified even in files containing null bytes. Codacy analysis indicates the changes are up to standards.

While the logic correction is sound, the implementation uses an inefficient find -exec pattern that spawns a process for every file. Additionally, there is a gap in acceptance criteria regarding verification: the PR lacks automated test files containing the targeted characters, meaning the fix is not currently verified by the CI itself.

About this PR

  • Consider adding 'malicious' test files to the repository containing the targeted invisible and control characters (e.g., U+00A0, U+FEFF, and C0 controls). This would provide an automated way to verify that the CI gate correctly identifies these characters and fails as expected.

Test suggestions

  • Detection of Non-breaking Space (U+00A0)
  • Detection of C0 control characters (e.g. Backspace \x08)
  • Detection of Byte Order Mark (U+FEFF)
  • Detection of NUL bytes without skipping the file as binary
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Detection of Non-breaking Space (U+00A0)
2. Detection of C0 control characters (e.g. Backspace \x08)
3. Detection of Byte Order Mark (U+FEFF)
4. Detection of NUL bytes without skipping the file as binary

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

-o -name '*.idr' -o -name '*.zig' -o -name '*.v' -o -name '*.jl' \
-o -name '*.gleam' -o -name '*.hs' -o -name '*.ml' -o -name '*.sh' \) \
-exec grep -Prl "$PATTERNS" {} \; > /tmp/empty-lint-results.txt 2>/dev/null
-exec grep -aPrl "$PATTERNS" {} \; > /tmp/empty-lint-results.txt 2>/dev/null

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 MEDIUM RISK

Suggestion: The -r (recursive) flag is redundant because find is already handling directory traversal and passing individual file paths. Switching from -exec ... {} \; to -exec ... {} + will significantly improve CI performance by batching multiple files into fewer grep process invocations.

Additionally, the -a flag is critical here to ensure grep treats all files as text; without it, null bytes or control characters cause files to be skipped as binary, which was a primary reason the gate previously failed to match.

Suggested change
-exec grep -aPrl "$PATTERNS" {} \; > /tmp/empty-lint-results.txt 2>/dev/null
-exec grep -aPl "$PATTERNS" {} + > /tmp/empty-lint-results.txt 2>/dev/null

@hyperpolymath
hyperpolymath enabled auto-merge (squash) August 28, 2026 07:23
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 61 issues detected

Severity Count
🔴 Critical 6
🟠 High 31
🟡 Medium 24

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in scorecard.yml",
    "type": "missing_workflow",
    "file": "scorecard.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Workflow executes remote script directly (curl/wget piped to shell). Download, verify checksum/signature, then execute.",
    "type": "download_then_run",
    "file": "ui-ci.yml",
    "action": "verify_download_integrity",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in boj-build.yml",
    "type": "missing_timeout_minutes",
    "file": "boj-build.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in codeql.yml",
    "type": "missing_timeout_minutes",
    "file": "codeql.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

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