.semgrepignore file.
To do this, create a .semgrepignore file in your repository’s root directory. Then, add the paths of the files you want to exclude. The specific paths that you add to this file depend on your goal:
Note: Unreachable findings are only generated from manifest files or lockfiles, because Semgrep defines unreachable findings as the absence of a match in the code.
Sample .semgrepignore configuration
Given a repository with the following files:
- A file
codefile_with_vuln.jsthat generates reachable and unreachable findings due to a vulnerable dependency. - A
package-lock.jsonfile that lists the vulnerable dependency.
codefile_with_vuln.js to .semgrepignore to ignore reachable findings from that file. Semgrep still generates findings from package-lock.json:
package-lock.json to .semgrepignore so that Semgrep doesn’t scan dependencies listed in this lockfile. This results in no Supply Chain findings generated from either codefile_with_vuln.js or package-lock.json: