Skip to content

Commit e990b43

Browse files
Fix incorrect references to manifest files (#1930)
This KB is about generating lockfiles, defined as files that list specific pinned dependency versions. These are the only files we currently support for Python with SSC.
1 parent 89f7010 commit e990b43

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

docs/kb/semgrep-supply-chain/ssc-python-lockfiles.md

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Generate various Python lock files to run Semgrep Supply Chain scans successfully.
2+
description: Generate Python lockfiles to run Semgrep Supply Chain scans successfully.
33
tags:
44
- Semgrep Supply Chain
55
- Python
@@ -10,18 +10,15 @@ tags:
1010
- Poetry.lock
1111
---
1212

13-
# Generating Python manifest files for Semgrep Supply Chain scans
13+
# Generating Python lockfiles for Semgrep Supply Chain scans
1414

15-
To correctly scan all dependencies in a project, Semgrep Supply Chain requires a Python manifest file. This article describes methods to generate the following Python manifest files or lockfiles:
15+
To correctly scan all dependencies in a project, Semgrep Supply Chain requires a Python lockfile: a file with specific versions of all dependencies. This article describes methods to generate the following supported Python lockfiles:
1616

17-
* `requirements.txt`, including those in a requirements folder, such as `**/requirements/*.txt`
18-
* `requirements.pip`
19-
* `requirement.txt`, including those in a requirement folder, such as `**/requirement/*.txt`
20-
* `requirement.pip`
17+
* `requirements.txt`
2118
* `Pipfile.lock`
2219
* `Poetry.lock`
2320

24-
You can use any of these files to get a successful Semgrep Supply Chain scan. Your manifest files must have one of these three names to be scanned, or you must have a `*/requirement/*` file in the project.
21+
You can use any of these files to get a successful Semgrep Supply Chain scan. Since Semgrep 1.93.0, a `requirements.txt` file can be placed in a `**/requirements/` folder, or can have any name that matches `*requirement*.txt` or `*requirement*.pip`.
2522

2623
## Generating `requirements.txt`
2724

@@ -32,7 +29,6 @@ You can use any of these files to get a successful Semgrep Supply Chain scan. Yo
3229
* `pip-tools` must be installed on your machine. See the [pip-tools GitHub repository](https://github.com/jazzband/pip-tools) for installation instructions.
3330
:::
3431

35-
3632
To generate a `requirements.txt` file from `requirements.in`, enter the following command in the root of your project directory:
3733

3834
```bash
@@ -112,10 +108,8 @@ This file has all direct and transitive dependencies of the example project and
112108
### Using `pip freeze`
113109

114110
:::info Prerequisites
115-
116111
* The `pip freeze` utility uses dependencies from packages already installed in your current environment to generate `requirements.txt`. You must be in an isolated or [virtual environment](https://docs.python.org/3/library/venv.html).
117112
* An existing `setup.py` file.
118-
119113
:::
120114

121115
To generate `requirements.txt` through `pip freeze`, enter the following commands:
@@ -296,16 +290,17 @@ poetry lock
296290

297291
The generated `Poetry.lock` file contains all transitive and direct dependencies that the project uses.
298292

299-
## Selecting a single manifest file among many
293+
## Selecting a single file among many
300294

301-
While there may already be a manifest file in the repository, such as a `Pipfile.lock`, you may want to generate a new one, for example a `requirements.txt`, to be sure it has the latest dependencies.
295+
While there may already be a lockfile in the repository, such as a `Pipfile.lock`, you may want to generate a new one, for example a `requirements.txt`, to be sure it has the latest dependencies.
302296

303-
When scanning with Semgrep Supply Chain, you can use the flag `--include` to specify that only a single manifest file should be scanned. The manifest file must still have one of the supported names.
297+
When scanning with Semgrep Supply Chain, you can use the flag `--include` to specify that only a single lockfile should be scanned. The manifest file must still have one of the supported names.
304298

305299
```
306300
semgrep ci --supply-chain --include=requirements.txt
307301
```
302+
However, if you have multiple `requirements.txt` files that are in supported locations, you do not need to generate a new unified lockfile. Semgrep will scan files from all supported locations.
308303

309304
## Conclusions
310305

311-
There are several ways to generate manifest files or lockfiles for Python dependencies. Depending on your preferences, you can select one or another. Keep in mind that the manifest file should be generated before the Semgrep scan and within the proper environment. This ensures that you are scanning only the dependencies of your project and not all the Python dependencies of your system.
306+
There are several ways to generate lockfiles for Python dependencies. Depending on your preferences, you can select one or another. Keep in mind that the file should be generated before the Semgrep scan and within the proper environment. This ensures that you are scanning only the dependencies of your project and not all the Python dependencies of your system.

0 commit comments

Comments
 (0)