Skip to content

fix(audit): report audit-rules load errors and block installs whose audit cannot run - #882

Merged
runkids merged 2 commits into
mainfrom
runkids/audit-rules-load-errors-879
Nov 13, 2026
Merged

runkids merged 2 commits into
mainfrom
runkids/audit-rules-load-errors-879

Conversation

@runkids

@runkids runkids commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)
  • Approved feature or large change (the linked issue has the approved label)

Linked Issue

Closes #879

What changed

Audit (commit 1). Global scans (ScanSkill, ScanSkillWithFollow, ScanSkillFiltered, ScanFile) now return the error when audit rules fail to load, as project scans already did. Before, a single bad regex in the global audit-rules.yaml turned off every pattern check without warning. Errors now name the file, for read, parse and compile failures alike:

✗ demo  scan error: load rules: global user rules: ~/.config/skillshare/audit-rules.yaml: rule "bad-regex": invalid regex: ...

audit reports a scan error for each skill and exits 2. A project file that sets enabled: false on a broken global rule still loads. When it does not, the error points at the global file.

Install (commit 2). Once the error is returned, install used to log it as a warning and install the skill with no audit at all. Install now matches the update gate:

  • A scan that cannot run blocks skill, agent and tracked-repo installs and removes what was installed.
  • --force does not override this. --skip-audit still skips the scan.
  • The error wraps the new install.ErrAuditScanFailed, not audit.ErrBlocked, so neither the CLI nor the dashboard offers a --force retry.
  • upgrade --skill reinstalls with --force, which deleted the old skill before the audit ran. It now goes through the staged update path, so the installed skill is kept when the audit fails.
  • update --all used to count the error as a silent skip. It now lists it under "Blocked by security audit" with the reason and exits non-zero.
  • Docs (English plus ja, ko, zh-Hans, zh-Hant) and the built-in skill references now describe the new behavior. Wherever they explain --force, they now say it overrides blocks from findings, not a failed scan.

Checks run

All in a devcontainer-image container:

  • make check (docs-check, fmt-check, lint, test, test-herdr): passed
  • go test ./tests/integration: passed
  • Regression tests:
    • TestGlobalScans_ReturnRulesLoadError
    • TestRulesWithProject_InvalidProjectRuleNamesFile
    • TestRulesWithProject_BadGlobalRule
    • TestAudit_ScanErrorBlocksAndCleansUp
    • TestInstall_ForceUpdateScanErrorKeepsExistingSkill
    • TestCompactBlockedUpdateMessage_ShowsScanFailure
  • Two of these were also run against a reverted fix to confirm they fail. TestRulesWithProject_BadGlobalRule failed against the version that loaded global rules first. TestInstall_ForceUpdateScanErrorKeepsExistingSkill failed without Update.
  • E2E in an isolated ssenv with a broken global audit-rules.yaml. Each command was run against the real binary:
    • audit and audit --json
    • install, install --force, install --json, install --track --force and install --skip-audit
    • upgrade --skill --force (skill kept), update --all and update <name>
    • All of them again after deleting the file

Not run: website build, dashboard click-through. The dashboard handles the new message through the existing error branch, because isAuditBlock and isForceRetryable do not match it.

Not covered (follow-ups)

  • audit --json and the dashboard Audit page report only the count of scan errors, not their reason.
  • audit rules lists rules without compiling them, so a bad regex looks fine in that list.
  • hub build --audit drops risk scores for entries whose scan failed, and does not say so.
  • A long-running dashboard server caches the rules-load error until it restarts.
  • skillshare audit >/dev/null exits 2 even on a clean audit. This is reproducible on main.

Checklist

  • I've read CONTRIBUTING.md, including its AI-assisted contributions section
  • I've reviewed every line of the diff and can explain it
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

The global scan entry points (ScanSkill, ScanSkillWithFollow,
ScanSkillFiltered, ScanFile) dropped the error from Rules() and scanned
with no pattern rules. One bad regex in the global audit-rules.yaml
turned every pattern check off with no warning, so audits reported
fewer findings than they should have (#879). Project mode already
returned the error.

Return the error from the global path as well, and name the failing
file in it: parse errors from loadUserRules and compile errors from
Rules() and RulesWithProject now carry the path. When a project scan
fails to compile, the global file is blamed only if it fails on its
own, so a project file that disables a broken global rule still loads.
The cached markdown split now takes the rules its caller already
loaded instead of loading them again and dropping the error.
Once global scans return rule-load errors, install treated the error as
a warning and installed the skill with no audit at all. update already
fails closed on a scan error, and --force there accepts findings, not
an install nobody could check.

A scan error now blocks skill, agent and tracked-repo installs and
removes what was installed. --force does not override it;
--skip-audit still bypasses scanning. The error wraps the new
install.ErrAuditScanFailed rather than audit.ErrBlocked, so install
output and the dashboard do not offer a --force retry that cannot help.

upgrade reinstalls the built-in skill with --force, which deleted the
old copy before the audit ran. A typo in audit-rules.yaml would have
left users without the skill, so upgrade now stages the download
through the update path and keeps the installed copy when the audit
fails.

update --all counted the new error as a silent skip. It is now listed
under "Blocked by security audit" with its reason and makes the run
exit non-zero. The install warning summary that counted "audit scan
error" warnings is removed, since nothing emits them any more.

Fixes #879
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T07:09:44.438024Z b509ade PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@runkids
runkids merged commit 08ecb7a into main Nov 13, 2026
9 checks passed
@runkids
runkids deleted the runkids/audit-rules-load-errors-879 branch November 13, 2026 07:19
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.

audit: global scans ignore pattern-rule load errors

1 participant