Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update supply chain semgrepignore docs #2061

Merged
merged 3 commits into from
Mar 28, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions docs/semgrep-supply-chain/ignoring-deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ You can restrict code files or manifest files or lockfiles from generating Suppl
| Goal | Method |
| ---- | ------ |
| Prevent a code file from generating **any reachable findings**. | Include the code file's path in the repository's `.semgrepignore` file. |
| Prevent a manifest file or lockfile from generating **any unreachable findings** but still generate reachable findings from a code file. | Include the manifest file's path or the lockfile's path in the repository's `semgrepignore` file. |
| Prevent a code file from generating either reachable or unreachable findings. | Include the file paths of the manifest file or lockfile and code files in the repository's `.semgrepignore` file. |
| Prevent any findings from being generated using the dependencies in a manifest file or lockfile | Include the file paths of the manifest file or lockfile in the repository's `.semgrepignore` file |


> Unreachable findings are only generated from manifest files or lockfiles, because Semgrep defines unreachable findings as the absence of a match in the code.

Expand All @@ -27,24 +27,16 @@ Given a repository with the following files:
* A file `codefile_with_vuln.js` that generates reachable and unreachable findings due to a vulnerable dependency.
* A `package-lock.json` file that lists the vulnerable dependency.

If you add `codefile_with_vuln.js` to the `.semgrepignore` file, Semgrep ignores any reachable findings generated when scanning `codefile_with_vuln.js`:
If you add `codefile_with_vuln.js` to the `.semgrepignore` file, Semgrep ignores any reachable findings generated when scanning `codefile_with_vuln.js`, but can still generate findings from `package-lock.json`:

```
# .semgrepignore
codefile_with_vuln.js
```

If you add `package-lock.json` to the `.semgrepignore` file, Semgrep presents reachable findings generated when scanning `codefile_with_vuln.js`, but ignores unreachable findings.

```
# .semgrepignore
package-lock.json
```

If you add `codefile_with_vuln.js` and `package-lock.json` to the `.semgrepignore` file, Semgrep ignores reachable and unreachable findings generated when scanning `codefile_with_vuln.js`:
If you add `package-lock.json` to the `.semgrepignore` file, Semgrep will not scan dependencies from this lockfile, so no Supply Chain findings will be generated in either `codefile_with_vuln.js` or `package-lock.json`:

```
# .semgrepignore
codefile_with_vuln.js
package-lock.json
````