Sub topic 13
Excluding paths to reduce noise
This chapter assumes you can edit files in a repository, know how secret scanning raises alerts, and have seen the alert list for at least one repository. Here you will learn how to tell secret scanning to skip paths that only contain dummy values, and what you give up when you do.
Why exclude paths
Secret scanning matches text, not intent. A documentation page that shows an example token, or a test fixture that holds a fake key, can look identical to a real credential. Each match creates an alert that someone must open, read and close. If most alerts are false positives, people stop trusting the list, and a real leak can be missed.
Path exclusions remove a known source of noise. They do not make scanning smarter. They make it skip files you have chosen.
The configuration file
You list excluded paths in a file named secret_scanning.yml inside the .github directory of the repository. The key is paths-ignore, and each entry is a path pattern.
# .github/secret_scanning.yml
paths-ignore:
- "docs/**/*.md"
- "test/fixtures/**"The first pattern skips every Markdown file under docs/, at any depth. The second skips everything under test/fixtures/.
Some points to keep in mind:
- Quote each pattern. Characters such as
*have special meaning in YAML. *matches within one directory level.**matches across directory levels.- Commit the file to the default branch. GitHub reads the configuration from there.
- Changes apply to future scans. Alerts that already exist are not closed for you, so close them yourself with a suitable resolution.
What an exclusion does and does not cover
An exclusion applies to the paths you list, and only to scanning of those paths. It is easy to assume more than that, so check the table.
| Question | Answer |
|---|---|
| Does the file stop producing new alerts? | Yes, for matching paths. |
| Are real secrets in those paths still dangerous? | Yes. The credential works wherever it is stored. |
| Are existing alerts removed? | No. Review and close them. |
| Does the exclusion hide the file from reviewers? | No. It only affects scanning. |
The main risk is that an excluded folder becomes a place where a real secret can sit unnoticed. Someone copies a working key into a fixture "just for now", and nothing warns anyone.
Choosing what to exclude
Use a narrow scope and a clear reason. A good decision follows this path.
Prefer these habits:
- Exclude a specific folder such as
test/fixtures/**, not a broad pattern such as**/*.json. - Make fake values obviously fake, so a reviewer can tell them from real ones.
- Add a comment in the YAML file that says why each path is listed.
- Review the list from time to time and remove paths that no longer need it.
Do not exclude a path just to silence one real alert. If the secret is real, revoke and rotate it, as described in the remediation chapter.
Common errors
- The pattern does not match. A pattern like
docs/*.mdonly matches files directly indocs/. Usedocs/**/*.mdfor nested files. - The file is on the wrong branch. A configuration that exists only on a feature branch has no effect until it is on the default branch.
- Old alerts remain. The exclusion stops new alerts. It does not clean up the existing ones.
- An over-broad pattern. A wide pattern can hide a real leak in a path you did not think about.
Exercise
Your repository has a samples/ folder with example config files that hold placeholder tokens, and secret scanning keeps raising alerts for them. Write the .github/secret_scanning.yml content that excludes only the Markdown and YAML files under samples/, and name one step you still need to do for the alerts that already exist.
Show answer
Content: paths-ignore: followed by the two entries - "samples/**/*.md" and - "samples/**/*.yml", with each pattern in quotes. Existing alerts are not closed by the exclusion, so review each one and close it with a resolution that matches the facts, such as false positive for placeholder values. Also confirm the file is committed to the default branch.