Skip to content

Commit e1a8356

Browse files
committed
Clarify module-folder discovery and SBOM scans
Document how to include a generated SBOM in pull request comparisons. Test the manifest list submitted by the CLI under different directory settings. Group the documentation with the pending 2.14.0 release.
2 parents 2cad7fa + 4e28391 commit e1a8356

12 files changed

Lines changed: 511 additions & 155 deletions

‎CHANGELOG.md‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
# Changelog
22

3-
## 2.13.3
3+
## 2.14.0
4+
5+
### Changed
6+
7+
- Updated the Socket Python SDK (`socketdev`) to 3.6.4. This can increase
8+
advisory counts in full-scan JSON, SARIF, and GitLab security reports, and
9+
in the existing findings shown in GitLab security and FOSSA diff reports.
10+
11+
### Fixed
12+
13+
- `--strict-blocking` counts distinct advisories on unchanged dependencies and
14+
lists findings that persist after a version change in the Existing alerts
15+
table. When a finding has both Warn and Block actions, Block takes precedence.
16+
- SARIF reports use advisory IDs to distinguish findings on the same package
17+
and manifest.
418

519
### Documentation
620

7-
- `--include-module-folders` help and docs now say what the flag does: every
8-
supported manifest under `node_modules`, `bower_components` or `jspm_packages`,
9-
nested folders included, is added to the scan, and Socket resolves the
10-
dependencies those files declare. It does not list installed packages. The troubleshooting guide covers scanning
11-
packages installed outside the lockfile with a CycloneDX SBOM.
21+
- Clarified that `--include-module-folders` discovers dependency manifests.
22+
Added a guide to scanning packages installed outside the lockfile with a
23+
CycloneDX SBOM.
1224

1325
## 2.13.2
1426

‎docs/cli-reference.md‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ docs.socket.dev use `SOCKET_SECURITY_API_KEY`. Either works. If both are set,
324324
| Parameter | Required | Default | Description |
325325
|:-------------------------|:---------|:--------|:------------------------------------------------------------------------------------------------------|
326326
| `--default-branch` | False | *auto* | Make this branch the default branch (auto-detected from git and CI environment when not specified) |
327-
| `--include-module-folders` | False | False | Also discovers manifests anywhere under `node_modules`, `bower_components` and `jspm_packages`, nested folders included (skipped by default; same as `--include-dirs` with those names). Every supported manifest found there is added to the scan, and Socket resolves the dependencies those files declare, `devDependencies` included. The installed packages themselves are not recorded; see [Packages installed outside the lockfile](troubleshooting.md#packages-installed-outside-the-lockfile). For `vendor`, `.venv` and other excluded directories, use `--include-dirs`. |
327+
| `--include-module-folders` | False | False | Includes supported manifests found under `node_modules`, `bower_components`, and `jspm_packages` in manifest discovery. Equivalent to `--include-dirs node_modules,bower_components,jspm_packages`. Other discovery exclusions still apply. For an inventory of installed packages, see [Packages installed outside the lockfile](troubleshooting.md#packages-installed-outside-the-lockfile). |
328328

329329
#### Output Configuration
330330
| Parameter | Required | Default | Description |
@@ -604,19 +604,12 @@ Bot mode (`bot_configs` array items):
604604
605605
## Strict Blocking Mode
606606
607-
The `--strict-blocking` flag enforces a zero-tolerance security policy by failing builds when **ANY** security violations with blocking severity exist, not just new ones introduced in the current changes.
607+
In a scan comparison, `--strict-blocking` fails the build on new and existing findings with a **Block** action.
608608
609609
### Standard vs Strict Blocking Behavior
610610
611-
**Standard Behavior (Default)**:
612-
- ✅ Passes if no NEW violations are introduced
613-
- ❌ Fails only on NEW violations from your changes
614-
- 🟡 Existing violations are ignored
615-
616-
**Strict Blocking Behavior (`--strict-blocking`)**:
617-
- ✅ Passes only if NO violations exist (new or existing)
618-
- ❌ Fails on ANY violation (new OR existing)
619-
- 🔴 Enforces zero-tolerance policy
611+
- **Default** fails on findings introduced by the change that have a **Block** action.
612+
- **Strict blocking** also checks unchanged dependencies and findings that persist after a version change. For example, if an upgrade leaves a blocking advisory unresolved, the run still fails and the advisory appears under **Existing alerts** at the new version.
620613
621614
### Usage Examples
622615
@@ -668,8 +661,8 @@ Security issues detected by Socket Security:
668661
### Important Notes
669662
670663
- **Diff Mode Only**: The flag applies when a scan comparison runs, with or without SCM integration. A full scan logs a warning and does not evaluate existing violations; see [Scan type by pipeline](ci-cd.md#scan-type-by-pipeline).
671-
- **Error-Level Only**: Only fails on `error=True` alerts (blocking severity), not warnings.
672-
- **Existing alerts come from the full scan**: The scan comparison doesn't carry alerts on unchanged packages, so the CLI reads them from the new full scan, at the cost of one more API request per run. If that request fails or omits an unchanged package, the run fails with the infrastructure-error code rather than passing without them.
664+
- **Policy actions**. Warn findings are reported. If the same finding has both Warn and Block actions, Block takes precedence.
665+
- **Existing alerts come from the full scan**. The CLI fetches the current full scan when the comparison leaves out alerts on unchanged packages or when a dependency version changes. A failed fetch or a missing package in that response triggers the infrastructure-error exit code.
673666
- **PR/MR comments**: Existing alerts are listed in their own table after the new ones, blocking first, with license violations grouped per package. `@SocketSecurity ignore` applies to them too. Very large sets are cut off before the comment reaches GitHub's size limit, with a link to the full report. Ignoring every displayed alert preserves the warning about omitted findings; `ignore-all` also clears omitted findings.
674667
- **Priority**: `--disable-blocking` takes precedence - if both flags are set, the build will always pass.
675668
- **First Scan**: On the very first scan of a repository, there are no "existing" violations, so behavior is identical to standard mode.
@@ -899,13 +892,11 @@ The GitLab Security Dashboard report and the JSON/SARIF diff outputs use differe
899892
900893
| Output Format | Default Alerts | With `--strict-blocking` |
901894
|:---|:---|:---|
902-
| `--enable-gitlab-security` | **All** alerts (new + existing) | All alerts (same) |
895+
| `--enable-gitlab-security` | New alerts and existing alerts on unchanged dependencies | Also includes findings that persist after a version change |
903896
| `--enable-json` | New alerts only | New + existing alerts |
904897
| `--enable-sarif` (diff scope) | New alerts only | New + existing alerts |
905898
906-
**Why the difference?** GitLab's Security Dashboard is designed to present the full security posture of a project. An empty dashboard on a scan with no dependency changes would be misleading -- the vulnerabilities still exist, they just didn't change. By contrast, JSON and SARIF in diff scope are designed to answer "what changed?" and only include existing alerts when `--strict-blocking` explicitly requests it.
907-
908-
> **Tip:** If you use `--enable-json` alongside `--enable-gitlab-security`, the GitLab report may contain more vulnerabilities than the JSON output. This is expected. To make JSON output match, add `--strict-blocking`.
899+
Enable `--strict-blocking` to include existing findings in JSON and diff-scope SARIF. Scan-based SARIF includes the advisory ID in the rule ID when available, so separate advisories on the same package and manifest remain distinguishable.
909900
910901
### Alert Ignoring via PR/MR Comments
911902

‎docs/troubleshooting.md‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Flags add:
123123
| `--reach` | `POST orgs/{org}/upload-manifest-files`, `POST tier1-reachability-scan/finalize` | `full-scans:create` |
124124
| `--generate-license` | `POST orgs/{org}/purl` | `packages:list` |
125125
| `--enable-json`, `--enable-sarif`, `--enable-gitlab-security` or `--generate-license` on a full scan | `GET orgs/{org}/full-scans/{id}` (scan contents) | `full-scans:list` |
126-
| `--strict-blocking`, `--enable-gitlab-security` or `--legal-format fossa` on a run that compares scans | `GET orgs/{org}/full-scans/{id}` (alerts on unchanged packages) | `full-scans:list` |
126+
| `--strict-blocking`, `--enable-gitlab-security` or `--legal-format fossa` on a run that compares scans | `GET orgs/{org}/full-scans/{id}` (existing alerts) | `full-scans:list` |
127127

128128
`--reach` also runs the analysis engine with the same token. The engine reports to the
129129
`tier1-reachability-scan/*` endpoints, which check `full-scans:create`.
@@ -234,22 +234,24 @@ by the comparison step that follows.
234234

235235
## Packages installed outside the lockfile
236236

237-
The CLI scans manifests and lockfiles. A package that a `postinstall` script installs into `node_modules` has no lockfile entry, so it is not in the scan.
237+
Packages present only on disk, such as packages that a `postinstall` script adds without updating the lockfile, can be missing from a manifest-based scan.
238238

239-
`--include-module-folders` does not fix this. It adds every supported manifest under `node_modules` to the scan, at any depth: each package's `package.json`, including nested `node_modules` and scoped packages, plus any other manifest or lockfile a package ships. Socket resolves the dependencies those files declare (`devDependencies` included), so the scan can gain hundreds of packages your project never installs. The installed packages themselves are not recorded. With `--reach`, these manifests are uploaded for reachability analysis too.
239+
`--include-module-folders` lets the CLI discover supported manifests in `node_modules`, `bower_components`, and `jspm_packages`, including nested directories. Other directory and path exclusions still apply, and discovery skips symlinked directories. Socket resolves the dependencies the manifests declare, including `devDependencies`. This can add findings for dependencies absent from your installed tree. With `--reach`, the CLI also includes these files in the manifest upload for reachability analysis.
240240

241-
To scan what is installed, generate a CycloneDX SBOM of the installed `node_modules` tree and save it in the scan root before running the CLI:
241+
For npm projects, generate a CycloneDX software bill of materials (SBOM) from the installed tree. The example uses Node.js 20.18 or newer and npm 9 or newer. Run it from the scan root with a Socket API token configured.
242242

243243
```bash
244-
npm ci
245-
npx @cyclonedx/cyclonedx-npm --omit dev --ignore-npm-errors --output-format JSON --output-file installed.cdx.json
246-
socketcli --target-path .
244+
npm ci &&
245+
npx --yes @cyclonedx/cyclonedx-npm@7.0.1 --omit dev --output-format JSON --output-file installed.cdx.json &&
246+
socketcli --target-path .
247247
```
248248

249-
The CLI uploads CycloneDX files named `bom.json`, `*.cdx.json` or `*.cyclonedx.json` (and the `.xml` forms) with your other manifests. No flag is needed.
249+
The example excludes development dependencies. To include them, remove `--omit dev` and run the install and generator without production-only npm settings or `NODE_ENV=production`. If npm reports a dependency-tree error, inspect it first. Use the generator's `--ignore-npm-errors` option only if the tree npm returns contains the packages you intend to scan.
250250

251-
- Generate the SBOM on default-branch scans as well as pull request scans. Otherwise packages that only the SBOM lists show up as new in every comparison.
252-
- Packages fetched at runtime, for example by `npx`, are not in `node_modules` and are not covered.
251+
The CLI discovers CycloneDX files such as `bom.json`, `*.cdx.json`, and `*.cyclonedx.json` (or their `.xml` equivalents) alongside the lockfile. Leave `--include-module-folders` off when you only want to add the SBOM.
252+
253+
- For PR comparisons, generate the SBOM with the same settings before the default-branch and PR scans. Add `--ignore-commit-files` to the PR scan so it runs a comparison even on commits that change no tracked manifest. A generated SBOM outside the Git diff does not trigger comparison mode on its own.
254+
- The SBOM covers packages present when it is generated. Packages fetched later or installed outside the tree, such as tools fetched into the npm cache by `npx`, are outside its scope.
253255

254256
## Dashboard vs CLI result counts
255257

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.13.3"
9+
version = "2.14.0"
1010
requires-python = ">= 3.11"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [
@@ -16,7 +16,7 @@ dependencies = [
1616
"gitpython==3.2.1",
1717
"packaging==26.3",
1818
"python-dotenv==1.2.4",
19-
"socketdev==3.6.3",
19+
"socketdev==3.6.4",
2020
"beautifulsoup4==4.15.0",
2121
"markdown==3.11.3",
2222
"brotli==1.2.1; platform_python_implementation == 'CPython'",

‎socketsecurity/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.13.3'
2+
__version__ = '2.14.0'
33
USER_AGENT_NAME = 'socket-python-cli'
44
USER_AGENT = f'{USER_AGENT_NAME}/{__version__}'

‎socketsecurity/config.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,9 +1119,9 @@ def create_argument_parser() -> argparse.ArgumentParser:
11191119
dest="include_module_folders",
11201120
action="store_true",
11211121
default=False,
1122-
help="Also scan manifests anywhere under node_modules, bower_components and jspm_packages "
1123-
"(same as --include-dirs with those names). Adds the dependencies they declare, not the "
1124-
"installed packages. See https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#packages-installed-outside-the-lockfile"
1122+
help="Include manifests found under node_modules, bower_components, and jspm_packages. "
1123+
"Use a CycloneDX SBOM to inventory installed packages. "
1124+
"See https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md"
11251125
)
11261126

11271127
# Reachability Configuration

0 commit comments

Comments
 (0)