Exclude files and folders from tests
Learn how to exclude SAST issues associated with specific files and folders in your projects from test results.
Overview
You can set up file and folder exclusion rules for your organization, for specific applications, and for specific projects. Up to 30 exclusion rules can be defined for your organization, each application, and each project. Once configured, SAST issues (including SAST issues imported from third-party tools) found in excluded files:
- Are hidden in the Polaris user interface, without affecting issue metadata.
Note: This means each issue's metadata (triage status, first detected date, ... etc.) can be restored when exclusion rules change.
- Do not count as policy violations.
Additionally, pull request (PR) comments will not be applied to excluded files.
GET /api/findings/issues/{id}
and GET /api/findings/issues
endpoints in the Findings API (and can be easily identified when the _includeIssueExclusion
parameter is set to true
).Processing exclusions
Polaris evaluates and applies exclusions:
- At the end of SAST tests, before test results appear in Polaris.
Note: This means all the files in your project are still available and evaluated during tests, and ensures the exclusion rules you configure don't affect test quality.
- At the end of external analysis tests, before issues you import from third-party tools appear in Polaris.
- When file and folder exclusion rules are modified.
Note: A banner appears at the top of the Issues tab (Portfolio > select an application > select a SAST & SCA project > Issues) while Polaris processes changes.
Exclusion inheritance
File and folder exclusion rules set at the organization-level serve as defaults for all the applications and projects in your portfolio. However, exclusion rules assigned to applications and projects take precedence; an application's rules override organization-level rules, while a project's exclusion rules override both application and organization-level rules.
To check the active exclusion rules for an application or project, open the Analysis tab.
- For an application, go to Portfolio > select an application > Settings > Analysis.
- For a project, go to Portfolio > select an application > select a project > Settings > Analysis.
When Inherited appears at the top of the Code Exclusions panel, the exclusion rules that apply to the application (example below) or project are inherited.

Regular expression reference
Exclusion rules are regular expressions (regex), and each rule can include a comment.
Rule #Comment
Rule #Comment
Rule #Comment
Type | Operator | Description |
---|---|---|
Anchors | ^ |
Matches the start of a path or file name. |
$ |
Matches the end of a path or file name. | |
Path separator | / |
Separates directories in a path. |
Escape | \ |
An escape character that precedes literals. For example, use \. to select a period. |
Quantifiers | * |
Zero or more occurrences of the preceding element. |
+ |
One or more occurrences of the preceding element. | |
? |
Zero or one occurrence of the preceding element. | |
{n} |
A specific number (n ) of occurrences of the preceding element. |
|
{n,} |
A minimum number (n ) of occurrences of the preceding element. |
|
{n,m} |
A range (between n and m ) of occurrences of the preceding element. |
|
Character classes | \d |
Any digit. |
\D |
Any non-digit. | |
\w |
Any word character. | |
\W |
Any non-word character. | |
\s |
Any whitespace character. | |
\S |
Any non-whitespace character. | |
Character ranges | [abc] |
Any of the characters in the brackets. |
[^abc] |
Anything but the characters in the brackets. | |
[a-z] |
Letters of the alphabet from a to z. |
Example exclusion rules
Example Python project structure:
project/
│
├── src/
│ ├── __init__.py
│ ├── main.py
│ ├── utils.py
│ └── config.py
│
├── tests/
│ ├── __init__.py
│ ├── test_main.py
│ └── test_utils.py
│
├── venv/
│ ├── lib/
│ └── bin/
│
├── .git/
├── README.md
└── requirements.txt
Example exclusion rule | Effect |
---|---|
^.*test_[\w_-]*\.py$ |
Excludes all Python files with names that start with "test_" (and allows filenames to include additional underscores and dashes). |
^venv/.*$ |
Excludes the entire venv directory and its contents. |
^tests/.*\.py$ |
Excludes all Python files in the tests directory. |
^src/config\.py$ |
Excludes only the config.py file in the src directory. |
Create or update organization-level exclusion rules
To create organization-level exclusion rules, follow these steps:
Create or update application-level exclusion rules
To create application-level exclusion rules, follow these steps:
Create or update project-level exclusion rules
To create project-level exclusion rules, follow these steps:
Reset application and project-level exclusion rules
After you customize application or project-level exclusion rules, you can select Reset (at the top of the Code Exclusions panel) to delete the application or project-level rules. When you reset an application's exclusion rules, the application will inherit your organization-level rules. When you reset a project's exclusion rules, the project will inherit application (if set) or organization-level rules.
-
Open the application or project's settings:
- For an application, go to Portfolio > select an application > Settings > Analysis.
- For a project, go to Portfolio > select an application > select a project > Settings > Analysis.
- Select Reset (at the top of the Code Exclusions panel).