Skip to content

Commit 96173cd

Browse files
committed
Prepare code-only strict blocking for CLI 2.14.0
Exercise the comparison and SDK parser from the CLI. Verify that incomplete comparisons and missing existing-alert data use the configured exit policy. Document scan scope, baseline selection, and the upgrade impact.
2 parents 009a605 + 4e28391 commit 96173cd

14 files changed

Lines changed: 546 additions & 232 deletions

‎CHANGELOG.md‎

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

3-
## 2.13.3
3+
## 2.14.0
44

55
### Upgrade notes
66

7-
- Under `--strict-blocking`, runs without `--scm` now compare against the head
8-
scan even when no manifest changed, and fail on existing blocking alerts. That
9-
covers default-branch pushes in Bitbucket, Azure Pipelines, Jenkins and other
10-
pipelines that don't set `--scm`, and target paths that aren't git
11-
repositories. Those runs used to pass with a full scan. `--ignore-commit-files`
12-
already behaved this way.
7+
- Without a GitHub or GitLab SCM adapter, `--strict-blocking` now compares scans
8+
even when no manifest changed. This includes default-branch pushes and scans of
9+
non-git paths. These runs can now fail on Block findings or comparison errors
10+
and need the [API token scopes for comparison runs](docs/troubleshooting.md#api-token-permissions).
11+
12+
### Changed
13+
14+
- Updated the Socket Python SDK (`socketdev`) to 3.6.4. This can increase
15+
advisory counts in full-scan JSON, SARIF, and GitLab security reports, and
16+
in the existing findings shown in GitLab security and FOSSA diff reports.
1317

1418
### Fixed
1519

16-
- `--strict-blocking` fails on existing blocking alerts when the change touches no
17-
manifest. Without `--ignore-commit-files`, such a change used to get a full scan
18-
with blocking turned off, so code-only pull requests passed. The comparison now
19-
runs over every manifest in the target path, and PR/MR comments list the existing
20+
- `--strict-blocking` checks existing Block findings on code-only changes.
21+
GitHub and GitLab pull request comments show those findings under Existing
2022
alerts.
23+
- `--strict-blocking` counts distinct advisories on unchanged dependencies and
24+
lists findings that persist after a version change in the Existing alerts
25+
table. When a finding has both Warn and Block actions, Block takes precedence.
26+
- SARIF reports use advisory IDs to distinguish findings on the same package
27+
and manifest.
2128

2229
## 2.13.2
2330

‎docs/ci-cd.md‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -499,25 +499,24 @@ pipelines:
499499

500500
## Scan type by pipeline
501501

502-
With `--scm github` or `--scm gitlab`, the detected event decides the scan type:
502+
With `--scm github` or `--scm gitlab`, the detected event controls which
503+
pipelines can run a comparison. The table assumes changed-file detection:
503504

504505
| Event | Scan | Blocks the build |
505506
|:------|:-----|:-----------------|
506-
| Pull request / merge request | Diff scan against the repository's baseline | Yes, on new blocking alerts; also existing blockers with `--strict-blocking` |
507-
| Any other pipeline, including default-branch pushes | Full scan | No |
508-
509-
A full scan has no baseline, so it cannot tell a newly introduced alert from one
510-
that was already there. Rather than block on a number that would mean something
511-
different depending on which output format was enabled, those runs behave as if
512-
`--disable-blocking` was supplied and report through the Dashboard instead. This
513-
matches how the CLI treats a change with no supported manifest files, except under
514-
`--strict-blocking`: there a pull request or merge request that touches no manifest
515-
still gets the comparison, so existing blocking alerts fail it.
516-
517-
The event type is authoritative once `--scm` is set: `--enable-diff` and
518-
`--ignore-commit-files` do not turn a branch pipeline into a comparison. To diff
519-
a branch build, drop `--scm` and use `--enable-diff` with `--integration`, which
520-
runs the comparison without the PR comment adapter.
507+
| Pull request / merge request with a supported manifest change | Comparison | New Block findings, plus existing Block findings with `--strict-blocking` |
508+
| Pull request / merge request with no supported manifest change | Full scan by default. Comparison with `--strict-blocking` or `--ignore-commit-files` | In a comparison, new Block findings, plus existing Block findings with `--strict-blocking` |
509+
| Branch pipeline, including a default-branch push | Full scan | No |
510+
511+
Full scans report through the Dashboard. The SCM adapter keeps branch pipelines
512+
in full-scan mode even with `--enable-diff`, `--ignore-commit-files`, or
513+
`--strict-blocking`.
514+
515+
Without a GitHub or GitLab SCM adapter, `--strict-blocking` runs a comparison
516+
even when no supported manifest changed. This includes default-branch pushes and
517+
scans of non-git paths. A Block finding exits `1`. A comparison infrastructure
518+
error exits `3` by default. Check the [API token scopes for comparison runs](troubleshooting.md#api-token-permissions)
519+
when upgrading a pipeline that previously ran only full scans.
521520

522521
`--generate-license` and `--legal-format fossa` work on both paths; a full scan
523522
fetches the package list for them.

‎docs/cli-reference.md‎

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,12 @@ The CLI runs a pinned version of the Coana CLI, the analysis engine; it does **n
461461
#### Advanced Configuration
462462
| Parameter | Required | Default | Description |
463463
|:-------------------------|:---------|:--------|:----------------------------------------------------------------------|
464-
| `--ignore-commit-files` | False | False | Compare regardless of which files changed, scanning every manifest |
464+
| `--ignore-commit-files` | False | False | Skip the changed-file check for comparisons eligible under the SCM event rules. |
465465
| `--exit-code-on-api-error` | False | 3 | Remap infrastructure failures, including missing tokens, setup failures, incomplete scan data and unexpected runtime errors. Findings (`1`), usage errors (`2`) and Ctrl+C (`130`) are unaffected. `--disable-blocking` takes precedence. |
466466
| `--disable-blocking` | False | False | Non-blocking CI mode: the CLI exits **0** even when blocking alerts are present (including with `--strict-blocking`). Also exits 0 on infrastructure errors (missing API or SCM token, Socket API failures, uncaught runtime errors) and interrupts, so the job is treated as successful while findings and errors are still logged. Invalid flags still exit **2**. Takes precedence over `--strict-blocking`. |
467467
| `--disable-ignore` | False | False | Disable support for `@SocketSecurity ignore` commands in PR comments. When set, alerts cannot be suppressed via comments and ignore instructions are hidden from comment output. See [Who can ignore an alert](#who-can-ignore-an-alert). |
468468
| `--ignore-authorization` | False | enforce | Who may suppress alerts with `@SocketSecurity ignore`. `enforce` requires write access and honors the command with a warning when the provider cannot report it; `strict` rejects it in that case; `off` honors any commenter. See [Who can ignore an alert](#who-can-ignore-an-alert). |
469-
| `--strict-blocking` | False | False | Fail on ANY security policy violations (blocking severity), not just new ones. Runs a comparison even when no manifest changed. See [Strict Blocking Mode](#strict-blocking-mode) for details. |
469+
| `--strict-blocking` | False | False | Fail on new and existing Block findings, including on changes that touch no manifest. See [Strict Blocking Mode](#strict-blocking-mode). |
470470
| `--enable-diff` | False | False | Enable diff mode even when using `--integration api` (forces diff mode without SCM integration) |
471471
| `--scm` | False | api | Source control management type |
472472
| `--timeout` | False | 1200 | Positive integer timeout in seconds for each API request. This is not a total CLI runtime limit and does not limit local discovery, Git, or reachability analysis. |
@@ -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
@@ -667,11 +660,10 @@ Security issues detected by Socket Security:
667660
668661
### Important Notes
669662
670-
- **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-
- **No manifest changed**: When the changed files include no supported manifest, the CLI still runs the comparison over every manifest in the target path, as with `--ignore-commit-files`, instead of falling back to a full scan. Code-only pull requests fail on existing blocking alerts and list them in the PR/MR comment. Without `--scm`, this also applies to default-branch pushes and to target paths that aren't git repositories, so those runs fail on existing blocking alerts where they used to pass. This adds the comparison and existing-alert requests to those runs.
672-
- **With `--reach`**: The comparison uses the last default-branch scan made with `--reach` as its baseline. If the default branch is scanned without `--reach`, the baseline is empty and every alert is reported as new. The exit code is the same under `--strict-blocking`, but the PR/MR comment says the change introduced them. Scan the default branch with `--reach` too.
673-
- **Error-Level Only**: Only fails on `error=True` alerts (blocking severity), not warnings.
674-
- **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.
663+
- **Scan scope**. Strict mode compares the configured scan scope even when no supported manifest changed. Scan options such as `--sub-path` and `--reach-use-only-pregenerated-sboms` still control what the CLI submits. GitHub and GitLab branch pipelines using `--scm` perform non-blocking full scans. See [Scan type by pipeline](ci-cd.md#scan-type-by-pipeline).
664+
- **With `--reach`**. With no explicit baseline, the CLI looks for a default-branch head scan with reachability enabled. If none exists, the CLI compares against an empty baseline and classifies all findings as new. Scan the default branch with `--reach` too.
665+
- **Policy actions**. Warn findings are reported. If the same finding has both Warn and Block actions, Block takes precedence.
666+
- **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.
675667
- **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.
676668
- **Priority**: `--disable-blocking` takes precedence - if both flags are set, the build will always pass.
677669
- **First Scan**: On the very first scan of a repository, there are no "existing" violations, so behavior is identical to standard mode.
@@ -771,23 +763,24 @@ The CLI determines which files to scan based on the following logic:
771763
772764
2. **`--files` Parameter Override**: When specified, this parameter takes precedence over git commit detection. It accepts a JSON array of file paths to check for manifest files.
773765
774-
3. **`--ignore-commit-files` Flag**: When set, the changed-file check is skipped entirely. The CLI runs the comparison regardless of what changed, and scans every manifest file in the target directory.
766+
3. **`--ignore-commit-files` Flag**: Skip the changed-file check for comparisons, subject to the SCM event type.
775767
776-
4. **Automatic Fallback**: If no manifest files are found in git commit changes and no `--files` are specified, the CLI automatically switches to "API mode" and performs a full repository scan. With `--strict-blocking`, it runs the comparison instead, as `--ignore-commit-files` does, so existing blocking alerts are still checked.
768+
4. **Automatic Fallback**: When the changed-file check finds no supported manifest, the CLI normally runs a full scan. Strict mode compares scans so it can evaluate existing findings. See [Scan type by pipeline](ci-cd.md#scan-type-by-pipeline) for SCM event rules.
777769
778-
> **Important**: The CLI doesn't scan only the specified files - it uses them to determine whether a scan should be performed and what type of scan to run. When triggered, it searches the entire `--target-path` for all supported manifest files.
770+
The changed-file list and `--files` select the scan type. Manifest discovery
771+
uses the configured scan scope, including any `--sub-path` restrictions.
779772
780773
### Scanning Modes
781774
782775
- **Differential Mode**: When manifest files are detected in changes, performs a diff scan with PR/MR comment integration
783-
- **API Mode**: When no manifest files are in changes, creates a full scan report without PR comments but still scans the entire repository. With `--strict-blocking`, the CLI runs a comparison instead (see Automatic Fallback above); SCM branch pipelines still create a full scan
784-
- **Force Mode**: With `--ignore-commit-files`, always runs a comparison regardless of which files changed, over every manifest in the target path
776+
- **Full Scan**: Reports findings to the Dashboard. SCM branch pipelines use this mode.
777+
- **Force Mode**: With `--ignore-commit-files`, compares regardless of which files changed on pipelines eligible for comparison.
785778
- **Forced Diff Mode**: With `--enable-diff`, forces differential mode even when using `--integration api` (without SCM integration)
786779
787780
### Examples
788781
789782
- **Commit with manifest file**: If your commit includes changes to `package.json`, a differential scan will be triggered automatically with PR comment integration.
790-
- **Commit without manifest files**: If your commit only changes non-manifest files (like `.github/workflows/socket.yaml`), the CLI automatically switches to API mode and performs a full repository scan.
783+
- **Code-only commit**: The CLI runs a full scan by default. `--strict-blocking` selects a comparison on pipelines eligible for comparison.
791784
- **Using `--files`**: If you specify `--files '["package.json"]'`, the CLI will check if this file exists and is a manifest file before determining scan type.
792785
- **Using `--ignore-commit-files`**: This runs the comparison regardless of what's in your commit, over all manifest files in the target path. Use it when the changed-file check would otherwise skip a comparison you need.
793786
- **Using `--enable-diff`**: Forces diff mode without SCM integration - useful when you want differential scanning but are using `--integration api`. For example: `socketcli --integration api --enable-diff --target-path /path/to/repo`
@@ -901,13 +894,11 @@ The GitLab Security Dashboard report and the JSON/SARIF diff outputs use differe
901894

902895
| Output Format | Default Alerts | With `--strict-blocking` |
903896
|:---|:---|:---|
904-
| `--enable-gitlab-security` | **All** alerts (new + existing) | All alerts (same) |
897+
| `--enable-gitlab-security` | New alerts and existing alerts on unchanged dependencies | Also includes findings that persist after a version change |
905898
| `--enable-json` | New alerts only | New + existing alerts |
906899
| `--enable-sarif` (diff scope) | New alerts only | New + existing alerts |
907900

908-
**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.
909-
910-
> **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`.
901+
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.
911902

912903
### Alert Ignoring via PR/MR Comments
913904

‎docs/troubleshooting.md‎

Lines changed: 1 addition & 1 deletion
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`.

‎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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,8 +1058,8 @@ def create_argument_parser() -> argparse.ArgumentParser:
10581058
"--strict-blocking",
10591059
dest="strict_blocking",
10601060
action="store_true",
1061-
help="Fail on ANY security policy violations (blocking severity), not just new ones. Runs a comparison even "
1062-
"when no manifest changed. SCM branch (non-PR/MR) pipelines create a full scan and do not block."
1061+
help="Fail on new and existing Block findings. Compare even when no manifest changed. "
1062+
"GitHub and GitLab branch pipelines using --scm run non-blocking full scans."
10631063
)
10641064
advanced_group.add_argument(
10651065
"--enable-diff",

0 commit comments

Comments
 (0)