From a8d72cc029c015a89eb927cf0ad68daae22824fd Mon Sep 17 00:00:00 2001 From: David Larsen Date: Fri, 20 Nov 2026 15:34:17 -0500 Subject: [PATCH 1/5] 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. --- CHANGELOG.md | 10 ++++++++++ docs/cli-reference.md | 2 +- docs/troubleshooting.md | 19 +++++++++++++++++++ pyproject.toml | 2 +- socketsecurity/__init__.py | 2 +- socketsecurity/config.py | 7 ++++++- uv.lock | 2 +- 7 files changed, 39 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff28e721..6a183fde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 2.13.1 + +### Docs + +- `--include-module-folders` help and docs now say what the flag does: each + `package.json` under `node_modules`, `bower_components` or `jspm_packages` is + uploaded as its own project, and Socket resolves the dependencies it declares. + It does not list installed packages. The troubleshooting guide covers scanning + packages installed outside the lockfile with a CycloneDX SBOM. + ## 2.13.0 ### Upgrade notes diff --git a/docs/cli-reference.md b/docs/cli-reference.md index 066820d2..888b4d5e 100644 --- a/docs/cli-reference.md +++ b/docs/cli-reference.md @@ -308,7 +308,7 @@ If you don't want to provide the Socket API Token every time then you can use th | Parameter | Required | Default | Description | |:-------------------------|:---------|:--------|:------------------------------------------------------------------------------------------------------| | `--default-branch` | False | *auto* | Make this branch the default branch (auto-detected from git and CI environment when not specified) | -| `--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`. | +| `--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`. | #### Output Configuration | Parameter | Required | Default | Description | diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index c2a1b02e..a803ac53 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -74,6 +74,25 @@ total before assuming either path is at fault. - 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`. - See **Reachability network access** in the [CLI reference](cli-reference.md) for the full list of hosts. +## Packages installed outside the lockfile + +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. + +`--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. + +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: + +```bash +npm ci +npx @cyclonedx/cyclonedx-npm --omit dev --ignore-npm-errors --output-format JSON --output-file installed.cdx.json +socketcli --target-path . +``` + +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. + +- 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. +- Packages fetched at runtime, for example by `npx`, are not in `node_modules` and are not covered. + ## Dashboard vs CLI result counts Differences in result counts can be valid, even when filtering appears similar. diff --git a/pyproject.toml b/pyproject.toml index 0924672a..2ba92fb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "socketsecurity" -version = "2.13.0" +version = "2.13.1" requires-python = ">= 3.11" license = {"file" = "LICENSE"} dependencies = [ diff --git a/socketsecurity/__init__.py b/socketsecurity/__init__.py index 08835ec8..a3c8f69d 100644 --- a/socketsecurity/__init__.py +++ b/socketsecurity/__init__.py @@ -1,4 +1,4 @@ __author__ = 'socket.dev' -__version__ = '2.13.0' +__version__ = '2.13.1' USER_AGENT_NAME = 'socket-python-cli' USER_AGENT = f'{USER_AGENT_NAME}/{__version__}' diff --git a/socketsecurity/config.py b/socketsecurity/config.py index a11ad252..07e3008e 100644 --- a/socketsecurity/config.py +++ b/socketsecurity/config.py @@ -1119,7 +1119,12 @@ def create_argument_parser() -> argparse.ArgumentParser: dest="include_module_folders", action="store_true", default=False, - help="Enabling including module folders like node_modules" + help="Also discover manifests inside node_modules, bower_components and jspm_packages, " + "which are skipped by default (same as --include-dirs with those names). Each " + "package.json found there is uploaded as its own project, and Socket resolves the " + "dependencies it declares, devDependencies included. This does not list the " + "installed packages themselves, so it does not find packages that are missing from " + "your lockfile. See docs/troubleshooting.md." ) # Reachability Configuration diff --git a/uv.lock b/uv.lock index a6271a3d..aea1ca6b 100644 --- a/uv.lock +++ b/uv.lock @@ -1334,7 +1334,7 @@ wheels = [ [[package]] name = "socketsecurity" -version = "2.13.0" +version = "2.13.1" source = { editable = "." } dependencies = [ { name = "beautifulsoup4" }, From d4bec77011ffe37256a40aec1b2a81bc695124fb Mon Sep 17 00:00:00 2001 From: David Larsen Date: Fri, 20 Nov 2026 17:07:07 -0500 Subject: [PATCH 2/5] Say every manifest under module folders is scanned, and shorten the help The flag adds every supported manifest under node_modules, bower_components and jspm_packages, at any depth, not only each package's top-level package.json. Those files are added to the same scan; no separate project is created. Say that in the reference, troubleshooting entry and changelog. Cut the help text to two sentences and point to the troubleshooting section on GitHub, since pip installs don't include the docs folder. --- CHANGELOG.md | 8 ++++---- docs/cli-reference.md | 2 +- docs/troubleshooting.md | 2 +- socketsecurity/config.py | 9 +++------ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a183fde..d8b4f96d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,10 @@ ### Docs -- `--include-module-folders` help and docs now say what the flag does: each - `package.json` under `node_modules`, `bower_components` or `jspm_packages` is - uploaded as its own project, and Socket resolves the dependencies it declares. - It does not list installed packages. The troubleshooting guide covers scanning +- `--include-module-folders` help and docs now say what the flag does: every + supported manifest under `node_modules`, `bower_components` or `jspm_packages`, + nested folders included, is added to the scan, and Socket resolves the + dependencies those files declare. It does not list installed packages. The troubleshooting guide covers scanning packages installed outside the lockfile with a CycloneDX SBOM. ## 2.13.0 diff --git a/docs/cli-reference.md b/docs/cli-reference.md index 888b4d5e..0869b672 100644 --- a/docs/cli-reference.md +++ b/docs/cli-reference.md @@ -308,7 +308,7 @@ If you don't want to provide the Socket API Token every time then you can use th | Parameter | Required | Default | Description | |:-------------------------|:---------|:--------|:------------------------------------------------------------------------------------------------------| | `--default-branch` | False | *auto* | Make this branch the default branch (auto-detected from git and CI environment when not specified) | -| `--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`. | +| `--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`. | #### Output Configuration | Parameter | Required | Default | Description | diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index a803ac53..ad3158f4 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -78,7 +78,7 @@ total before assuming either path is at fault. 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. -`--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. +`--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. 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: diff --git a/socketsecurity/config.py b/socketsecurity/config.py index 07e3008e..b97a26f8 100644 --- a/socketsecurity/config.py +++ b/socketsecurity/config.py @@ -1119,12 +1119,9 @@ def create_argument_parser() -> argparse.ArgumentParser: dest="include_module_folders", action="store_true", default=False, - help="Also discover manifests inside node_modules, bower_components and jspm_packages, " - "which are skipped by default (same as --include-dirs with those names). Each " - "package.json found there is uploaded as its own project, and Socket resolves the " - "dependencies it declares, devDependencies included. This does not list the " - "installed packages themselves, so it does not find packages that are missing from " - "your lockfile. See docs/troubleshooting.md." + help="Also scan manifests anywhere under node_modules, bower_components and jspm_packages " + "(same as --include-dirs with those names). Adds the dependencies they declare, not the " + "installed packages. See https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#packages-installed-outside-the-lockfile" ) # Reachability Configuration From 2cad7fabe15851ecdb992c4020fac422fb420fe6 Mon Sep 17 00:00:00 2001 From: David Larsen Date: Fri, 20 Nov 2026 18:08:17 -0500 Subject: [PATCH 3/5] Bump version to 2.13.3 2.13.2 was released from main, so this change needs the next patch version. --- pyproject.toml | 2 +- socketsecurity/__init__.py | 2 +- uv.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5c88c152..82c5bbf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "socketsecurity" -version = "2.13.2" +version = "2.13.3" requires-python = ">= 3.11" license = {"file" = "LICENSE"} dependencies = [ diff --git a/socketsecurity/__init__.py b/socketsecurity/__init__.py index 7ba49e1b..0871adeb 100644 --- a/socketsecurity/__init__.py +++ b/socketsecurity/__init__.py @@ -1,4 +1,4 @@ __author__ = 'socket.dev' -__version__ = '2.13.2' +__version__ = '2.13.3' USER_AGENT_NAME = 'socket-python-cli' USER_AGENT = f'{USER_AGENT_NAME}/{__version__}' diff --git a/uv.lock b/uv.lock index 196ae3c8..b3681e40 100644 --- a/uv.lock +++ b/uv.lock @@ -1334,7 +1334,7 @@ wheels = [ [[package]] name = "socketsecurity" -version = "2.13.2" +version = "2.13.3" source = { editable = "." } dependencies = [ { name = "beautifulsoup4" }, From 23b5ac9a3af79d0c4a24fa588858e0430a5a2bfa Mon Sep 17 00:00:00 2001 From: lelia <2418071+lelia@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:16:18 -0500 Subject: [PATCH 4/5] Add the 2.14.0 upgrade guide to the README --- CHANGELOG.md | 3 +++ README.md | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4dc64bb..26c9770f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ ### Documentation +- The README's [Upgrading to 2.14.0](README.md#upgrading-to-2140) section lists + what changes for `--strict-blocking` pipelines and what to check before + upgrading. - Clarified that `--include-module-folders` discovers dependency manifests. Added a guide to scanning packages installed outside the lockfile with a CycloneDX SBOM. diff --git a/README.md b/README.md index aa22735c..20079de3 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,23 @@ scan exit `0` on *both* findings and outages — the `soft_fail: 100` rule would never match, and real findings would stop blocking. That's usually not what you want. +### Upgrading to 2.14.0 + +2.14.0 changes what `--strict-blocking` evaluates, so jobs that passed on 2.13.x +can now fail on existing Block alerts. That is the intended result. Check these +before upgrading: + +| Change | Affects | What to do | +|--------|---------|------------| +| Each advisory on a package counts separately, findings that persist across a version change count as existing, and Block takes precedence over Warn | `--strict-blocking` | Expect higher existing-blocker counts. | +| Code-only changes run a comparison instead of a non-blocking full scan | `--strict-blocking` without `--ignore-commit-files` | These runs take about as long as `--ignore-commit-files` runs and can fail on existing Block alerts. | +| Without `--scm github` or `--scm gitlab`, that includes default-branch pushes and scans of non-git paths | `--strict-blocking` in Bitbucket, Azure Pipelines, Jenkins and other pipelines without `--scm` | The token needs `full-scans:list` and `repo:list`; see [API token permissions](docs/troubleshooting.md#api-token-permissions). Without them the run exits `3`. | +| A comparison returned with missing or invalid package lists is an infrastructure failure | Every comparison | Exits `3` by default; `--exit-code-on-api-error` and `--disable-blocking` apply. | +| Reopened and ready-for-review pull requests run the PR scan | `--scm github` | If you removed `reopened` from your workflow triggers to avoid unscanned passes, add it back. | +| The GitHub Actions example is split into PR, push and ignore-command workflows | Pipelines copied from the example | Put the [PR workflow](workflows/github-actions.yml) at the existing workflow path and add the [push workflow](workflows/github-actions-push.yml) in the same change. See [Required GitHub checks](docs/ci-cd.md#required-github-checks). | + +See the [release notes](CHANGELOG.md#2140) for the full list. + ### Upgrading to 2.13.0 Update pipeline rules and wrapper scripts that match specific exit codes: From 481a20a98ba260582559ae59fdc556f3a1436c82 Mon Sep 17 00:00:00 2001 From: lelia <2418071+lelia@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:20:24 -0500 Subject: [PATCH 5/5] Combine the 2.13 and 2.14 upgrade notes in the README --- CHANGELOG.md | 5 ++-- README.md | 61 ++++++++++++++++------------------------- docs/ci-cd.md | 2 +- docs/troubleshooting.md | 2 +- 4 files changed, 27 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26c9770f..7d130334 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,9 +18,8 @@ ### Documentation -- The README's [Upgrading to 2.14.0](README.md#upgrading-to-2140) section lists - what changes for `--strict-blocking` pipelines and what to check before - upgrading. +- The README's upgrade notes for 2.13 and 2.14 are combined into one short + [section](README.md#upgrading-from-212-or-earlier). - Clarified that `--include-module-folders` discovers dependency manifests. Added a guide to scanning packages installed outside the lockfile with a CycloneDX SBOM. diff --git a/README.md b/README.md index 20079de3..9fe926f9 100644 --- a/README.md +++ b/README.md @@ -268,44 +268,29 @@ scan exit `0` on *both* findings and outages — the `soft_fail: 100` rule would never match, and real findings would stop blocking. That's usually not what you want. -### Upgrading to 2.14.0 - -2.14.0 changes what `--strict-blocking` evaluates, so jobs that passed on 2.13.x -can now fail on existing Block alerts. That is the intended result. Check these -before upgrading: - -| Change | Affects | What to do | -|--------|---------|------------| -| Each advisory on a package counts separately, findings that persist across a version change count as existing, and Block takes precedence over Warn | `--strict-blocking` | Expect higher existing-blocker counts. | -| Code-only changes run a comparison instead of a non-blocking full scan | `--strict-blocking` without `--ignore-commit-files` | These runs take about as long as `--ignore-commit-files` runs and can fail on existing Block alerts. | -| Without `--scm github` or `--scm gitlab`, that includes default-branch pushes and scans of non-git paths | `--strict-blocking` in Bitbucket, Azure Pipelines, Jenkins and other pipelines without `--scm` | The token needs `full-scans:list` and `repo:list`; see [API token permissions](docs/troubleshooting.md#api-token-permissions). Without them the run exits `3`. | -| A comparison returned with missing or invalid package lists is an infrastructure failure | Every comparison | Exits `3` by default; `--exit-code-on-api-error` and `--disable-blocking` apply. | -| Reopened and ready-for-review pull requests run the PR scan | `--scm github` | If you removed `reopened` from your workflow triggers to avoid unscanned passes, add it back. | -| The GitHub Actions example is split into PR, push and ignore-command workflows | Pipelines copied from the example | Put the [PR workflow](workflows/github-actions.yml) at the existing workflow path and add the [push workflow](workflows/github-actions-push.yml) in the same change. See [Required GitHub checks](docs/ci-cd.md#required-github-checks). | - -See the [release notes](CHANGELOG.md#2140) for the full list. - -### Upgrading to 2.13.0 - -Update pipeline rules and wrapper scripts that match specific exit codes: - -| Outcome | Before 2.13.0 | From 2.13.0 | -|---------|---------------|-------------| -| Invalid flags or configuration | CLI validation: `1`; argparse: `2` | `2` for both; never suppressed by `--disable-blocking` | -| Ctrl+C | `2` | `130`, or `0` with `--disable-blocking` | -| Missing token or other setup failure | Fixed `2` or `3`, depending on the failure | Infrastructure-error code (`3` by default); both exit-code flags now apply | - -Blocking findings still exit `1`. With `--strict-blocking`, existing blocking -alerts can now fail jobs that previously passed. GitLab report findings also get -new IDs once; see the [release notes](CHANGELOG.md#2130). - -Configuration is validated before credentials or network setup. Use native -JSON/TOML booleans such as `false`, a positive integer `timeout`, and an array of -file paths for `files`. Invalid or unreadable configuration exits `2` even when -credentials are missing or blocking is disabled. - -For a compact comparison of failure-handling policies, see -[Exit codes in CI](docs/ci-cd.md#exit-codes-in-ci). +### Upgrading from 2.12 or earlier + +2.13 and 2.14 change exit codes and what `--strict-blocking` checks: + +- **Exit codes:** invalid flags or configuration exit `2`, Ctrl+C exits `130`, + and setup failures such as a missing token use the infrastructure-error code + (`3` by default). Blocking findings still exit `1`. See + [Exit codes in CI](docs/ci-cd.md#exit-codes-in-ci). +- **Config files** are validated before credentials or network setup. Use native + JSON/TOML booleans, a positive integer `timeout` and an array for `files`. +- **`--strict-blocking`** fails on existing Block alerts, counts each advisory + separately, and compares code-only changes too, so pipelines can fail on + alerts they used to pass. Without `--scm github` or `--scm gitlab`, that + includes default-branch pushes, which need the `full-scans:list` and + `repo:list` token scopes; see + [API token permissions](docs/troubleshooting.md#api-token-permissions). +- **GitHub Actions example:** if you copied it, put the + [PR workflow](workflows/github-actions.yml) at the existing path and add the + [push workflow](workflows/github-actions-push.yml) in the same change. See + [Required GitHub checks](docs/ci-cd.md#required-github-checks). + +GitLab report findings get new IDs once. The [release notes](CHANGELOG.md) have +the details. ## Common gotchas diff --git a/docs/ci-cd.md b/docs/ci-cd.md index def55470..14fae508 100644 --- a/docs/ci-cd.md +++ b/docs/ci-cd.md @@ -88,7 +88,7 @@ SCM event filters can also skip unsupported events with exit `0`; confirm a repo was created when validating a new workflow. `--strict-blocking` also checks existing blocking alerts; an incomplete comparison or incomplete existing-alert data is an infrastructure failure. See the -[2.13.0 migration table](../README.md#upgrading-to-2130) when updating existing CI rules. +[upgrade notes](../README.md#upgrading-from-212-or-earlier) when updating existing CI rules. ## Config file usage in CI diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index b714db85..c80a3c64 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -10,7 +10,7 @@ | Exit `0` despite expected blockers | Check `--disable-blocking`, remapping to `0`, and whether the run produced a full scan instead of a diff. Full scans do not gate on findings. | See [Exit codes in CI](ci-cd.md#exit-codes-in-ci) for the flag combinations and -[upgrade guidance](../README.md#upgrading-to-2130) for older pipeline rules. +[upgrade notes](../README.md#upgrading-from-212-or-earlier) for older pipeline rules. ## Repository lookup or creation fails