Skip to content

feat(tier1): apply audited SkillSpector baselines - #300

Merged
rng1995 merged 11 commits into
mainfrom
naren/port-skillspector-baseline
Nov 4, 2026
Merged

rng1995 merged 11 commits into
mainfrom
naren/port-skillspector-baseline

Conversation

@rng1995

@rng1995 rng1995 commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds --skillspector-baseline FILE so a reviewed SkillSpector exception can be applied explicitly, and reports whether the baseline actually did anything.

  • New option on validate, tier1 (and tier1 validate), and security-scan (and tier1 security-scan). The Python entry points take a matching skillspector_baseline argument: SecurityValidator, run_validation, run_security_scan, and run_tier1_workflow. The path is checked by Click (exists, readable, file only) and resolved, and parallel catalog children (validate --workers) receive it.

  • The file is passed to both SkillSpector stages (static and LLM enrichment) with --baseline. SkillEvaluator never discovers a baseline from the scanned skill and never passes --use-shipped-baseline.

  • In-tree baseline on a staged scan. When a skill has evals/ or other generated output, the scan runs on a staged copy. A baseline inside the skill is then passed as its staged copy, so SkillSpector excludes the file it actually scans. Without this, the copied baseline was scanned as skill content, and its reviewed match text came back as new HIGH findings. A baseline outside the skill, or one under an excluded directory, keeps its original path.

  • Unbounded rules. A rule whose id, path, and message contain no literal text (for example id: "*", path: "*/*", or message: "[!a]*") is rejected before the scan, because SkillSpector would let it suppress every finding. The check uses the same field aliases as SkillSpector's loader (rule_id, file). A missing, unparseable, or non-mapping baseline is also rejected. In each case the security check is INCOMPLETE with an explanatory error, and SkillSpector does not run.

  • Cheap schema pre-checks. SkillSpector rejects an invalid baseline at load time with exit code 2, and SkillEvaluator redacts scanner diagnostics, so the user saw only "unexpected exit code 2". Two errors that SkillSpector 2.9.5 through 2.12.0 all reject are now caught before the scan with a clear message: a version 2 rule or fingerprint without a non-empty reason, and rules or fingerprints that are not lists. Legacy rule-only baselines (no version, or version 1) still need no reason, as in SkillSpector. For anything else SkillSpector rejects, an exit code 2 on a run with a baseline adds a hint to check the file with skillspector scan <skill> --baseline <file>.

  • Diagnostics. JSON reports for single-skill targets add results[].skillspector_baseline with these fields:

    • status: applied, no_matches, fingerprint_version_mismatch, or not_applied.
    • file and digest: the baseline's file name and a sha256: digest of its bytes. The local path is not recorded, and inspection errors name only the file.
    • the baseline and runtime scanner versions.
    • rule and fingerprint counts.
    • suppressed, active, and active-blocking finding counts, taken from SkillSpector's report before any --llm-verify downgrade or policy severity override.
    • a message, which also explains a rejected baseline or a scan that returned no usable report.

    If fingerprints were generated with a different SkillSpector version, SkillSpector ignores all of them. SkillEvaluator then reports the mismatch with both versions: as an error when blocking findings remain, and as a warning otherwise. The pass/fail outcome does not change. Versions are compared as exact strings, as SkillSpector does. Rule-only baselines are not version-bound.

  • Docs: a new "Audited SkillSpector baselines" section in docs/tier1-validation.mdx with a v2 rule example, matching semantics, the bracketed-glob trick, the skillspector baseline fingerprint workflow, and version behavior. The option is also added to docs/cli-reference.mdx, and the JSON field to the CI table in docs/ci-integration.mdx.

  • CHANGELOG entry under Unreleased / Added.

Why

Public users had no reviewed, file-based way to accept a SkillSpector false positive. SkillEvaluator never passed a baseline to SkillSpector. A report that contained suppressed findings anyway was treated as untrustworthy, and the security check went INCOMPLETE. Users could either live with a red security check or stop running SkillSpector.

Two problems come with naively adding the flag:

  • A baseline kept inside the skill flags itself. Keeping the baseline in the skill (for example config/skillspector-baseline.yaml) is the natural layout. On any skill with Tier 3 output under evals/, that layout produced new findings from the baseline file itself, so the check stayed blocked even though the exceptions were correct.
  • An inert baseline is silent. Exact fingerprints silently stop matching after a SkillSpector upgrade. A report that showed only the unchanged HIGH count could not be told apart from a run where no baseline was passed at all.

Both were reproduced with a real SkillSpector 2.11.2 run before the fix (see Tests).

Kept from public

  • Fail-closed on unexpected suppressions. Without a requested baseline, any suppressed finding still makes the scan INCOMPLETE. test_unexpected_skillspector_suppression_fails_closed is unchanged.
  • Strict report contract. All existing SkillSpector JSON checks still apply with a baseline: semver version, 2.9.5 and 2.10+ completeness schemas, suppressed_count == len(suppressed), finding-count reconciliation, and exit code against the risk score. With a baseline, the report must also include both suppressed_count and suppressed. If either is missing, the scan fails closed instead of reporting counts as "unknown".
  • Risk-score reconciliation stays as strict as before. Suppressed rows are subtracted from findings_after_filtering before the minimum-score check. Otherwise each suppressed finding would count as an unseen occurrence and loosen the bound. The same subtraction applies to the score floor that is kept after generated-artifact or SPDX-comment issues are removed. Two regression tests cover this. In the first, a report that understates an active HIGH finding is still rejected when three findings are suppressed. In the second, the floor still raises the skillspector_risk_score HIGH finding when an evals/ issue is removed and three findings are suppressed.
  • Staging behavior. The artifact-free staged copy (copytree(symlinks=True) with shipped bytecode kept), path rewriting back to the original root, and the in-place fallback are unchanged. The baseline mapping only chooses which path goes to --baseline.
  • Explicit JSON allowlist. The reporter adds one named field rather than serializing validator metadata wholesale.
  • No local paths in reports. As with quality_config provenance, the baseline is identified by file name and sha256: digest, not by its absolute path.
  • Catalog forwarding guard. The --skillspector-baseline option is forwarded to catalog children, so test_catalog_child_argv_forwards_every_validate_option keeps passing without an exemption.
  • No new error-code family. Outcomes are a status value plus a message. This leaves stable error codes to the separate effort in feat: add stable evaluator error codes #115.

Tests

  • New in tests/validators/test_security.py (mocked SkillSpector, following the existing contract-test helpers):
    • the requested baseline is passed with --baseline and its suppressions are accepted. Status is applied, and the field appears in the JSON report with the file name and digest. The baseline's directory does not appear anywhere in the rendered report.
    • suppressions do not loosen risk-score reconciliation. This test fails without the subtraction.
    • suppressions do not lower the score floor after an evals/ issue is removed, so the skillspector_risk_score HIGH finding is still raised. This test fails without the subtraction in report processing.
    • a baseline run fails closed when suppression accounting is missing.
    • a fingerprint version mismatch is reported as an error when blocking findings remain and as a warning otherwise. The pass/fail status is unchanged, and the message is not a SkillSpector finding.
    • a rule-only baseline ignores the scanner version (no_matches).
    • unusable baselines block the scan: wildcard-only rules, a mix of bounded and unbounded rules, negated classes, non-mapping rules, non-mapping roots, invalid YAML, a missing file, a version 2 rule without a reason or with a blank one, a version 2 fingerprint without a reason, and rules or fingerprints that are not lists. The baseline message holds the error, and no error contains the local directory.
    • an exit code 2 from SkillSpector on a run with a baseline adds the --baseline hint, and the baseline message says the outcome is unknown. Without a baseline, an exit code 2 gets no such hint.
    • bounded rules are accepted, including the rule_id/file aliases and bracketed globs. Legacy rule-only baselines (no version, or version 1) need no reason.
    • the LLM enrichment stage also receives --baseline.
  • New in tests/validators/test_artifact_dir_exclusion.py:
    • an in-tree baseline is passed as the staged copy, and the file exists at scan time. This test fails without the mapping. The report records the file name and digest, not the temporary copy or the original path.
    • a baseline under evals/ keeps its original path.
    • an external baseline keeps its path on a staged scan.
    • an in-place scan keeps the original path.
  • New in tests/test_commands.py:
    • the flag reaches the security scan from validate, security-scan, tier1 security-scan, tier1, and tier1 validate. A relative path is resolved.
    • a missing file is a usage error (exit 2).
    • catalog children receive the resolved path.
  • tests/golden/cli_surface.json regenerated (adds the option to the five commands above).
  • After rebasing on current main, ran tests/validators/, tests/test_commands.py, tests/test_cli.py, tests/cli/, tests/golden/, tests/reporting/ (including the retained CI report renderer), tests/ci/, tests/test_ci_workflows.py, the OSS packaging, boundary, and source-hygiene tests, tests/test_checks_routing.py, tests/test_quality_config.py, tests/test_publication_evidence.py, tests/test_quality_policy_gate.py, the catalog and plugin-inventory tests, and tests/test_safety_boundaries.py: 5609 passed, 3 skipped. CLI banner, progress, publication, results-location, and HTML-parser tests: 679 passed, 2 skipped.
  • ruff check is clean on all changed Python files. ruff format introduces no new drift: security.py, test_commands.py, and test_security.py already differ from the formatter on main, and this change adds nothing to that. The OSS boundary check passed.
  • Live check with SkillSpector 2.11.2 on a skill that contains docker run --privileged and an evals/ directory:
    • no baseline: PE5 HIGH, failed.
    • in-tree rule baseline with a literal *--privileged* message, before the mapping: a new PE5 HIGH at config/skillspector-baseline.yaml:5.
    • the same baseline after the mapping: passed, applied.
    • a generated fingerprint baseline: applied.
    • the same fingerprints with scanner_version edited to 2.10.0: failed, fingerprint_version_mismatch with both versions.
    • an id: "*" rule: INCOMPLETE before the scan.
    • The documented *--privilege[d]* example suppresses PE5 and does not trigger it when the baseline is scanned as content.
  • Baseline v2 rules, version-bound fingerprints, and --baseline file exclusion were also confirmed in the SkillSpector v2.12.0 sources that the docs recommend.

🤖 Generated with Claude Code

rng1995 and others added 2 commits October 30, 2026 12:49
Public users had no way to accept a reviewed SkillSpector false positive.
SkillEvaluator never passed a baseline to SkillSpector, and any suppressed
finding in a report made the security check INCOMPLETE, so the only options
were a red security check or dropping SkillSpector.

Add --skillspector-baseline FILE to validate, tier1 (and tier1 validate),
and security-scan (and tier1 security-scan), plus a skillspector_baseline
argument on SecurityValidator, run_validation, run_security_scan, and
run_tier1_workflow. The file goes to both SkillSpector stages with
--baseline, and parallel catalog children receive it. Baselines are never
discovered from the scanned skill, and suppressed findings without a
requested baseline still fail closed. With a baseline, the report must
account for suppressions (suppressed_count and suppressed), and suppressed
rows are no longer counted as unseen occurrences when reconciling the risk
score, so that check stays as strict as without a baseline.

A baseline kept inside a skill that has evals/ outputs is passed as its
staged copy, so SkillSpector excludes the file it actually scans instead of
reporting the baseline's own match text as new findings. Rules whose id,
path, and message contain no literal text (for example id: "*") are
rejected before the scan, because SkillSpector would let them suppress
every finding.

JSON reports add results[].skillspector_baseline with the outcome
(applied, no_matches, fingerprint_version_mismatch, not_applied), the
baseline and runtime scanner versions, rule and fingerprint counts, and
suppressed, active, and blocking finding counts. Fingerprints ignored
after a SkillSpector upgrade are reported as an error when blocking
findings remain and as a warning otherwise, instead of a baseline that
silently suppresses nothing.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The skillspector_baseline report field recorded the baseline's absolute
local path, and inspection errors repeated it. Reports elsewhere keep local
paths out (quality_config provenance records only the file name), so the
field now records the file name and a sha256 digest of the file instead,
and errors name only the file.

SkillSpector rejects an invalid baseline at load time with exit code 2,
and the scanner diagnostics are redacted, so a baseline missing a required
reason surfaced only as "unexpected exit code 2". SkillEvaluator now
rejects, before the scan, a version 2 rule or fingerprint without a
non-empty reason and rules or fingerprints that are not lists. Legacy
rule-only baselines still need no reason. For any other rejection, an exit
code 2 on a run with a baseline adds a hint to check the file with
skillspector scan --baseline, and the baseline message explains that the
outcome is unknown.

Adds a regression test for the suppressed-row subtraction in the score
floor kept after generated-artifact issues are removed; it fails without
the subtraction. Docs now say that all rule globs are case-insensitive,
that the JSON field is present only for single-skill targets when
SkillSpector is installed, and that its finding counts come from
SkillSpector's report before --llm-verify or policy overrides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review: 6 findings (0 P1, 4 P2, 2 P3); 6 posted inline.

Comment thread docs/tier1-validation.mdx Resolved
Comment thread docs/tier1-validation.mdx Resolved
rng1995 and others added 3 commits November 2, 2026 11:28
Conflicts: CHANGELOG.md, docs/tier1-validation.mdx

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…errors

The pre-check loaded the baseline with plain yaml.safe_load. An impossible
date such as reviewed_on: 2026-06-31 raised an uncaught ValueError and
crashed the run, an empty or comment-only file was rejected although
SkillSpector loads it as an empty baseline, and chained merge keys expanded
without limit. It now reads at most 2 MiB and parses with a SafeLoader that
bounds composition and alias/merge expansion like SkillSpector's loader,
catches the scalar-constructor errors, and treats an empty document as {}.

Rule and fingerprint entries that are not mappings are now reported as such
instead of as an unbounded rule or a missing reason.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y report

SkillSpector's LLM meta-analysis rewrites findings before the baseline is
applied, so fingerprints from `skillspector baseline --no-llm` match only the
static stage. Merging the LLM stage overwrote the static suppression count,
and the outcome read `no_matches` although the baseline had matched. Each
stage's count is now kept; when the LLM stage suppresses fewer findings the
outcome is `llm_stage_unmatched`, reported as an error when blocking findings
remain and as a warning otherwise.

The outcome was only in the JSON report. It is now also a
`skillspector_baseline` success detail with the file name and digest, so
Markdown and HTML reports disclose applied or inert baselines, and a scan
whose only findings were suppressed no longer reads "No security
vulnerabilities detected".

Docs: fingerprints work on static-only runs and narrow rules for LLM runs,
where the JSON field appears for folder targets, and the suppression
reference pinned to the SkillSpector release the docs install.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two baseline-trust problems need fixing: an in-skill baseline lets the skill author write the exceptions, and the check for unbounded rules is passed by a single letter. The new pre-check loader and the per-stage outcome reporting otherwise read correctly (I fed the loader a couple dozen odd YAML inputs and ran real SkillSpector scans through the rule and fingerprint paths). The new item is that Markdown for a security-scan on a folder still says only 'All checks passed' for a skill whose findings were suppressed, which the new docs say it doesn't.

Comment thread docs/tier1-validation.mdx Resolved
Comment thread docs/tier1-validation.mdx Resolved
rng1995 and others added 6 commits November 3, 2026 09:58
Require a literal run of two characters in a rule id, or four in a path or
message glob, so `*e*` no longer passes the pre-check. Record every
baseline outcome as a success detail even when it also adds an error, add
suppressed severity counts and rule IDs to the diagnostic, keep the outcome
in folder scan summary lines, and document keeping the baseline outside the
skill under review.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Conflicts resolved by keeping both sides: run_validation and
run_tier1_workflow take main's --skip and this branch's
--skillspector-baseline; _validate_skillspector_report takes main's
scanned_root (accepted image gaps) and this branch's baseline_requested;
the LLM stage keeps main's repeated-warning dedupe and this branch's
per-stage suppressed count; the security accordion keeps main's
/etc/passwd bind-mount paragraphs and this branch's baseline pointer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
e8aa35d committed security.py.orig and test_security.py.orig by
mistake; they are stale copies from a conflict resolution.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
…he run

The merge with main put the new --skip parameter beside
--skillspector-baseline in run_validation and run_tier1_workflow; check
that validate and tier1 forward both together.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
…rity.py.orig

Commit e8aa35d briefly added tests/validators/test_security.py.orig (a
merge leftover, removed again in 7a3bf92). Gitleaks scans full history, so
the "us.anthropic.claude-opus-5" model ID that follows AWS_BEARER_TOKEN_BEDROCK
in that copy is flagged as generic-api-key at a path the existing allowlist
does not cover. Add an exact-path, exact-value allowlist entry for that file
and pin it in the allowlist scope test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
@rng1995
rng1995 enabled auto-merge (squash) November 4, 2026 18:59
@rng1995
rng1995 merged commit 39d8901 into main Nov 4, 2026
22 checks passed
@rng1995
rng1995 deleted the naren/port-skillspector-baseline branch November 4, 2026 19:29
rng1995 added a commit that referenced this pull request Nov 5, 2026
Resolve conflicts with #300 (SkillSpector baselines): SecurityValidator
takes content_type, skillspector_reference_root, and skillspector_baseline;
Tier 1 security passes the agent-scope arguments and the baseline; the
SkillSpector summary keeps both the baseline-suppressed message and the
agent-control-path suppression note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
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.

2 participants