Introducing a new way to review your PRs.

Read the announcement

affaan-m / agentshield

AI agent security scanner. Detect vulnerabilities in agent configurations, MCP servers, and tool permissions. Available as CLI, GitHub Action, ECC plugin, and GitHub App integration. 🛡️

View on GitHub

20 documents · Updated Sep 11, 2026

docs / baselines-and-fingerprints

Baselines and fingerprints

Baselines and fingerprints let AgentShield tell a new security problem from an issue that was already present. A baseline records an accepted scan state. Later scans compare their finding identities and score with that state to show regressions, resolved issues, and posture change. See Policy governance for the wider decision model and Policy evaluation and promotion for policy checks that remain separate from baseline drift.

Baseline model

A baseline is a versioned record of the findings and numeric score accepted at a point in time. It is a reference for change detection. It does not remove those findings from later scan reports or make them permanently safe.

Accepted state

The baseline stores a timestamp, the score used for the scan, and a record for each selected finding. Each record keeps enough context for a reviewer to understand the earlier issue and a fingerprint for later comparison. The CLI can save the current filtered scan as a JSON baseline, then use that file in a later run.

An issue that remains in the baseline with the same identity is reported as unchanged. This is the baseline meaning of an accepted issue. It is still visible in the current findings, so a baseline is not the same as a policy exception or a fix.

References: src/…/types.ts• L5-20 src/…/compare.ts• L19-46 src/index.ts• L433-439

Scan scope

The baseline uses the findings that remain after the scan’s minimum-severity filter. Its score is calculated from that same filtered result. A later comparison must use the intended scan scope because changing the severity threshold changes both the finding set and the score being compared.

References: src/index.ts• L315-332 src/index.ts• L433-449 src/…/watcher.ts• L168-182

Finding identity

A finding fingerprint is the stable identity used to match one finding across scans. AgentShield builds it from the finding rule ID, file path, and a short hash of the evidence. The identity avoids placing the full evidence text in the baseline while still changing when the relevant evidence changes.

Identity fields

Only three finding properties define the fingerprint:

FieldRole in identity
Finding IDIdentifies the security rule or condition that produced the finding
File pathIdentifies the configuration location involved
EvidenceDistinguishes different evidence at that location through a short SHA-256 digest; missing evidence uses a fixed marker

Severity, category, title, description, line number, runtime confidence, and fix data do not change the fingerprint. A change to one of those fields alone therefore keeps the finding matched to the baseline. This lets comparison track the same issue while the current scan remains the source of its current details.

References: src/fingerprint.ts• L4-20 src/types.ts• L17-28

Identity compatibility

The comparison keeps the fingerprint saved in the baseline as the main record of identity. It also supports baseline records that retain raw evidence from an older fingerprint form. This compatibility helps old baselines classify existing findings correctly after the fingerprint format changes.

Evidence text is part of identity. A rule or formatting change that alters evidence can make an existing issue appear as a new finding and the old record appear resolved. Treat fingerprint inputs as a contract when changing rule output.

References: src/fingerprint.ts• L6-20 src/…/compare.ts• L77-93 src/…/compare.ts• L126-136

Comparison flow

Baseline comparison turns one current scan into a change report. It matches fingerprints first, then compares the current numeric score with the score saved in the baseline.

The main flow is:

flowchart LR
    A[Current scan] --> B[Filtered findings and score]
    B --> C[Fingerprint current findings]
    D[Stored baseline] --> E[Fingerprint baseline records]
    C --> F[Match identities]
    E --> F
    F --> G[New, resolved, and unchanged findings]
    B --> H[Score delta]
    G --> I[Drift result]
    H --> I
    I --> J[Optional regression gate]

Comparison result

The comparison result gives reviewers both finding-level change and score-level change. A finding can be new or resolved while other findings remain unchanged. New and resolved findings can occur in the same scan.

ResultMeaning
New findingsCurrent findings whose fingerprints are absent from the baseline
Resolved findingsBaseline records whose fingerprints are absent from the current scan
Unchanged findingsCurrent findings that match the baseline; the count is derived from the current finding set
Score deltaCurrent numeric score minus the baseline numeric score

The comparison marks a result as a regression when it has at least one new finding or a negative score delta. A score increase does not cancel a new finding. A score drop can be a regression even when no finding is new.

References: src/…/compare.ts• L69-123 src/…/types.ts• L24-36

Security posture change

The score delta gives a broad view of posture movement, while the finding sets explain what caused the change. A positive delta shows improvement in the numeric score. A zero delta shows no score movement, but it does not by itself prove that the finding set is unchanged.

Because severity is not part of a fingerprint, a severity change on the same rule, file, and evidence remains an unchanged identity. Baseline comparison therefore focuses on introduced identities and score movement. Policy evaluation remains the separate control for judging the current severity and configuration against required rules.

References: src/fingerprint.ts• L4-8 src/…/compare.ts• L87-109 src/types.ts• L17-27

Regression gate

The regression gate converts a comparison into a pass or fail decision. Its limits can be configured for the number of new findings and the allowed score loss. Critical and high findings have separate controls because their severity can require an immediate review.

Gate thresholds

The default gate is strict about new findings and serious severity levels:

CheckDefault behavior
Total new findingsFails when more than zero are present
New critical findingsFails when any are present
New high findingsFails when any are present
Score lossFails when the score drops by more than five points

The gate returns the comparison together with human-readable reasons. A comparison can be marked as a regression even when a custom gate allows it. This separates the fact that posture changed from the local decision about whether that change blocks work.

References: src/…/types.ts• L38-60 src/…/compare.ts• L139-177

CI signals

The CLI can print the comparison and fail with the baseline gate when requested. The GitHub Action exposes the baseline status, new and resolved counts, unchanged count, and score delta as separate outputs so a workflow can report drift without treating it as an ordinary scan finding.

If the baseline file is missing or invalid, the comparison cannot run. The Action reports missing and marks the comparison as skipped. That state is not evidence that the current scan matches an accepted state.

References: src/index.ts• L441-464 src/action-baseline.ts• L3-76 action.yml• L98-109

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the fingerprint inputs stable when changing rule IDs, file paths, or evidence formatting. A change can turn unchanged findings into new and resolved findings.
  • Keep the scan severity filter and score calculation consistent when creating and comparing a baseline. A different filter changes the accepted finding set.
  • Preserve the baseline fingerprint field when changing the serialized baseline format. Older baseline files need their compatibility path to remain readable.
  • Keep isRegression separate from gate limits. Consumers must not treat a permitted regression as an unchanged posture.
  • Keep baseline status and count outputs aligned with comparison behavior. A missing baseline must not be reported as a passing comparison.

Important failure modes

TriggerConsequenceGuard
Baseline file is missing, malformed, or uses an unsupported versionComparison is skipped; the Action reports missing and the CLI reports a load errorStore a valid baseline at a stable path before enabling drift checks
Evidence text changes for the same rule and fileThe issue can appear as new while the old baseline record appears resolvedTreat evidence formatting as part of the fingerprint contract
The scan severity threshold changes between baseline creation and comparisonFindings and score no longer describe the same scopeUse the same threshold for both runs
A finding changes severity but keeps its ID, file, and evidenceIt remains unchanged for baseline matching and does not count as a new critical or high findingUse policy evaluation to enforce current severity requirements
A score drops without a new findingThe comparison is marked as a regression and the gate can fail on the score limitReview score-rule changes and the resulting score delta

Key files

FileWhy to read it
src/fingerprint.tsDefines the stable finding identity and evidence digest.
src/…/types.tsDefines the stored baseline, comparison result, and gate contracts.
src/…/compare.tsShows baseline save, load, comparison, compatibility handling, and gate decisions.
src/…/index.tsExposes the baseline and fingerprint capabilities as one public module.
src/index.tsShows where baseline save and comparison fit into the CLI scan flow.
src/action-baseline.tsMaps comparison and gate results to GitHub Actions status and job-summary output.
action.ymlDefines the Action inputs and baseline outputs used by CI consumers.
src/…/diff.tsShows how the same fingerprint model supports in-memory drift checks for watch mode.