Skip to content

Commit a8d72cc

Browse files
committed
Document what --include-module-folders does
The help text said "Enabling including module folders like node_modules", which doesn't say what a scan gains. The flag removes node_modules, bower_components and jspm_packages from the directories manifest discovery skips. Every package.json under them is then uploaded as its own project, and Socket resolves the dependencies each one declares, devDependencies included. The installed packages themselves are never recorded, so the flag can add hundreds of packages a project never installs and still misses a package that a postinstall script put in node_modules without a lockfile entry. Say that in the help text and the CLI reference, and add a troubleshooting entry for packages installed outside the lockfile: a CycloneDX SBOM of the installed tree saved in the scan root is picked up by manifest discovery and uploaded with the other manifests. No behavior change. Bumps the version to 2.13.1 for the version check.
1 parent ef5a7fb commit a8d72cc

7 files changed

Lines changed: 39 additions & 5 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 2.13.1
4+
5+
### Docs
6+
7+
- `--include-module-folders` help and docs now say what the flag does: each
8+
`package.json` under `node_modules`, `bower_components` or `jspm_packages` is
9+
uploaded as its own project, and Socket resolves the dependencies it declares.
10+
It does not list installed packages. The troubleshooting guide covers scanning
11+
packages installed outside the lockfile with a CycloneDX SBOM.
12+
313
## 2.13.0
414

515
### Upgrade notes

‎docs/cli-reference.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ If you don't want to provide the Socket API Token every time then you can use th
308308
| Parameter | Required | Default | Description |
309309
|:-------------------------|:---------|:--------|:------------------------------------------------------------------------------------------------------|
310310
| `--default-branch` | False | *auto* | Make this branch the default branch (auto-detected from git and CI environment when not specified) |
311-
| `--include-module-folders` | False | False | If enabled, re-includes the JS/TS module folders (`node_modules`, `bower_components`, `jspm_packages`) in manifest discovery. For other excluded directories, use `--include-dirs`. |
311+
| `--include-module-folders` | False | False | Also discovers manifests inside the JS module folders (`node_modules`, `bower_components`, `jspm_packages`), which are skipped by default. Same as `--include-dirs node_modules,bower_components,jspm_packages`. Each `package.json` found there is uploaded as its own project, and Socket resolves the dependencies it declares, `devDependencies` included, so a scan can gain hundreds of packages your project never installs. It does not record the installed packages themselves, so it won't find packages missing from your lockfile; see [Packages installed outside the lockfile](troubleshooting.md#packages-installed-outside-the-lockfile). With `--reach`, the extra manifests are uploaded for reachability analysis too. For `vendor`, `.venv` and other excluded directories, use `--include-dirs`. |
312312
313313
#### Output Configuration
314314
| Parameter | Required | Default | Description |

‎docs/troubleshooting.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@ total before assuming either path is at fault.
7474
- Every vulnerability reported as `INSTALL ERROR`: the engine could not install your dependencies. Allow the ecosystem's package registry, or install dependencies in the target path before running `--reach`.
7575
- See **Reachability network access** in the [CLI reference](cli-reference.md) for the full list of hosts.
7676

77+
## Packages installed outside the lockfile
78+
79+
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.
80+
81+
`--include-module-folders` does not fix this. It uploads each `node_modules/*/package.json` as a separate project, and Socket resolves the dependencies those files declare (`devDependencies` included). The installed packages themselves are not recorded, and the scan can gain hundreds of packages your project never installs.
82+
83+
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:
84+
85+
```bash
86+
npm ci
87+
npx @cyclonedx/cyclonedx-npm --omit dev --ignore-npm-errors --output-format JSON --output-file installed.cdx.json
88+
socketcli --target-path .
89+
```
90+
91+
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.
92+
93+
- 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.
94+
- Packages fetched at runtime, for example by `npx`, are not in `node_modules` and are not covered.
95+
7796
## Dashboard vs CLI result counts
7897

7998
Differences in result counts can be valid, even when filtering appears similar.

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
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.0"
9+
version = "2.13.1"
1010
requires-python = ">= 3.11"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

‎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.0'
2+
__version__ = '2.13.1'
33
USER_AGENT_NAME = 'socket-python-cli'
44
USER_AGENT = f'{USER_AGENT_NAME}/{__version__}'

‎socketsecurity/config.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,12 @@ def create_argument_parser() -> argparse.ArgumentParser:
11191119
dest="include_module_folders",
11201120
action="store_true",
11211121
default=False,
1122-
help="Enabling including module folders like node_modules"
1122+
help="Also discover manifests inside node_modules, bower_components and jspm_packages, "
1123+
"which are skipped by default (same as --include-dirs with those names). Each "
1124+
"package.json found there is uploaded as its own project, and Socket resolves the "
1125+
"dependencies it declares, devDependencies included. This does not list the "
1126+
"installed packages themselves, so it does not find packages that are missing from "
1127+
"your lockfile. See docs/troubleshooting.md."
11231128
)
11241129

11251130
# Reachability Configuration

‎uv.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)