Skip to main content
The AI SAST detection agent can’t infer every fact about your code from the source. Before a scan, you give the agent that context. After the scan, you correct its findings with feedback on single findings and with rules for recurring patterns. Later default branch scans apply most corrections to new and existing findings. See AI context rules to write and manage rules.

Before you begin

Make sure you have the following prerequisites:
  • A project with AI SAST turned on. See AI SAST to set up scans in CI/CD or in SCM apps.
  • The AI SAST - Detection rule enabled in finding policies. See AI SAST detection agent to enable it.
  • The Admin role to create and edit AI context rules. See Authorization roles.
  • A role that can create and delete feedback, such as Admin or Code Scanner, to give feedback on findings.

Prepare context before the first scan

During a scan, the agent reads the AI context rules you create. It also builds automatic context from guidance files in your repository and from prior reviewer feedback. Prepare your rules and guidance files before the first scan. The first scan’s findings then already reflect your codebase.

Check the guidance files in your repository

The agent reads guidance files within the scan scope, such as CLAUDE.md and AGENTS.md. The agent checks what these files say against your code and treats them as reference only. See Automatic context from repository files to view the full list of files and directories that a scan reads by default. Review these files for content that describes your architecture, frameworks, and security controls. Accurate guidance files help the agent understand your code.

Write your starting rules

The agent treats AI context rules as trusted facts from your security team. It applies a rule even when the code doesn’t show what the rule states. Write rules for the facts that the code alone doesn’t reveal:
  • The frameworks you use and where untrusted input enters your code, such as the package that holds your HTTP handlers.
  • The middleware or functions that enforce authentication and authorization, and the files they live in.
  • The sanitizers your project uses, named exactly, and the sinks that bypass them.
  • The directories that never reach production, such as test data, tooling, or generated code.
  • The severity you expect for findings in specific services, when it differs from the severity that the agent computes.
Anchor each rule to a file, directory, framework, route, or function name that the agent can locate. A suppression applies to every finding at the symbol, file, location, or finding class that it names. Keep each suppression as narrow as the safe pattern. See Example AI context rules to adapt a rule to your own code. See Create an AI context rule to create the rules. Under Scope, select the namespace. To limit a rule to specific projects, use Inclusions and Exclusions.

Run the first scan

Run an AI SAST scan of the default branch. Start it from your CI/CD pipeline or SCM app, or run endorctl scan --ai-sast --path=/path/to/code -n <namespace>. The agent reads your rules at the start of each scan. A rule that you create after a scan starts applies from the next scan. See AI SAST detection agent to run the scan.

Review findings and correct the agent

Review the AI SAST findings of the scan. For each finding, choose the response that fits from the following table. Prefer a rule when the same mistake repeats. Feedback applies to the findings of one project. A rule applies to every project in its scope. See Give feedback on AI SAST findings to learn how feedback and rules interact, and when scans pick up new feedback.

Apply your changes to existing findings

A rule change makes stored findings due for the refresh of findings. Later default branch scans re-evaluate them against your current rules and feedback. The refresh dismisses the findings that your changes now cover. It also applies severity rules to the findings it confirms. The agent reads rules at the start of every scan. New feedback makes stored findings due only after a default branch scan analyzes the code. A scheduled scan of an unchanged commit only refreshes findings and keeps the earlier feedback. To apply new feedback without a new commit, run a default branch scan from CI/CD or with endorctl. The refresh doesn’t run detection on unchanged files. A rule that asks the agent to look for a new pattern reports it in unchanged files only after a full detection scan. See When rules take effect to run a full detection scan.
A full detection scan deletes stored findings that it doesn’t detect again, including triaged findings. A scan profile setting can also keep every default branch scan in full mode until you remove it. See When rules take effect before you run one.

Verify the results

After the next default branch scans complete, check that your corrections took effect:
  • Endor Labs deletes a stored finding after two consecutive default branch scans dismiss it. A dismissed finding still appears after the first of these scans. Each scan deletes a limited number of findings. A broad rule can need more scans to clear all the findings it dismisses.
  • A severity rule applies to new findings and to the stored findings that the refresh confirms.
  • After a rule asks the agent to look for a new pattern, the next scan can report findings in changed files. Unchanged files need a full detection scan.
If a finding doesn’t change, check the following conditions:
  • You enabled the rule. Its scope includes the project. An exclusion takes precedence over an inclusion.
  • The rule names a file, symbol, or pattern that the agent can locate.
  • The scan ran on the default branch. The refresh doesn’t run on PR scans, --diff-scope scans, or dry runs.
  • The project’s scan profile doesn’t set ENDOR_SCAN_AI_SAST_REFRESH to false.
  • For a feedback change, a default branch scan analyzed the code after you gave the feedback. A scheduled scan of an unchanged commit keeps the earlier feedback.
  • The scan didn’t skip or stop the refresh. A scan skips the refresh when the checkout doesn’t contain the default-branch commit. The refresh also skips or stops when the default branch moves to a newer commit during the scan.
  • The scan reached the finding before its time limit. Findings that a scan doesn’t reach wait for a later default branch scan.
  • The finding isn’t waiting behind the deletion limits. See Refresh of findings to check the limits on deletions per scan.

Keep your context current

Repeat the review after each significant change to your code or your security controls. Update or delete a rule when the code it describes moves or changes. The agent then doesn’t work from stale guidance. See Manage AI context rules to edit, disable, or delete a rule.

Next steps

See View AI SAST detection agent findings to read the analysis behind each finding.