Skip to content

Commit f8c17a7

Browse files
committed
Clarify strict blocking on pushes with PR context
1 parent 96173cd commit f8c17a7

4 files changed

Lines changed: 28 additions & 16 deletions

File tree

‎docs/ci-cd.md‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,18 +499,20 @@ pipelines:
499499

500500
## Scan type by pipeline
501501

502-
With `--scm github` or `--scm gitlab`, the detected event controls which
503-
pipelines can run a comparison. The table assumes changed-file detection:
502+
With `--scm github` or `--scm gitlab`, the adapter uses the event and PR/MR
503+
context to select the scan type. A push given a PR/MR number can use the
504+
comparison path.
504505

505506
| Event | Scan | Blocks the build |
506507
|:------|:-----|:-----------------|
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`.
508+
| Pull request / merge request | Diff scan against the repository's baseline | Yes, on new blocking alerts; also existing blockers with `--strict-blocking` |
509+
| Any other pipeline, including default-branch pushes | Full scan | No |
510+
511+
With changed-file detection, a PR/MR with no supported manifest change runs a
512+
full scan by default. Use `--strict-blocking` or `--ignore-commit-files` to
513+
compare it. Full scans report through the Dashboard. A branch pipeline without
514+
PR/MR context stays in full-scan mode even with `--enable-diff`,
515+
`--ignore-commit-files`, or `--strict-blocking`.
514516

515517
Without a GitHub or GitLab SCM adapter, `--strict-blocking` runs a comparison
516518
even when no supported manifest changed. This includes default-branch pushes and

‎docs/cli-reference.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ Security issues detected by Socket Security:
660660
661661
### Important Notes
662662
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).
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. With `--scm`, GitHub and GitLab branch pipelines without PR/MR context perform non-blocking full scans. See [Scan type by pipeline](ci-cd.md#scan-type-by-pipeline).
664664
- **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.
665665
- **Policy actions**. Warn findings are reported. If the same finding has both Warn and Block actions, Block takes precedence.
666666
- **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.
@@ -773,7 +773,7 @@ uses the configured scan scope, including any `--sub-path` restrictions.
773773
### Scanning Modes
774774
775775
- **Differential Mode**: When manifest files are detected in changes, performs a diff scan with PR/MR comment integration
776-
- **Full Scan**: Reports findings to the Dashboard. SCM branch pipelines use this mode.
776+
- **Full Scan**: Reports findings to the Dashboard. SCM branch pipelines without PR/MR context use this mode.
777777
- **Force Mode**: With `--ignore-commit-files`, compares regardless of which files changed on pipelines eligible for comparison.
778778
- **Forced Diff Mode**: With `--enable-diff`, forces differential mode even when using `--integration api` (without SCM integration)
779779
@@ -782,7 +782,7 @@ uses the configured scan scope, including any `--sub-path` restrictions.
782782
- **Commit with manifest file**: If your commit includes changes to `package.json`, a differential scan will be triggered automatically with PR comment integration.
783783
- **Code-only commit**: The CLI runs a full scan by default. `--strict-blocking` selects a comparison on pipelines eligible for comparison.
784784
- **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.
785-
- **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.
785+
- **Using `--ignore-commit-files`**: Compare the configured scan scope regardless of which files changed when the pipeline supports comparison.
786786
- **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`
787787
- **Auto-detection**: Most CI/CD scenarios now work with just `socketcli --target-path /path/to/repo --scm github --pr-number $PR_NUM`
788788

‎socketsecurity/config.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ def create_argument_parser() -> argparse.ArgumentParser:
10591059
dest="strict_blocking",
10601060
action="store_true",
10611061
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."
1062+
"With --scm, branch pipelines without PR/MR context run non-blocking full scans."
10631063
)
10641064
advanced_group.add_argument(
10651065
"--enable-diff",

‎tests/core/test_strict_blocking_no_manifest_change.py‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,20 @@ def github_pull_request(cli_runtime, monkeypatch):
234234
return add_comments
235235

236236

237-
@pytest.mark.parametrize("extra", [[], ["--ignore-commit-files"]])
238-
def test_code_only_pull_request_comments_on_each_existing_blocker(
239-
cli_runtime, github_pull_request, comparison, extra
237+
@pytest.mark.parametrize(
238+
"event, extra",
239+
[
240+
pytest.param("pull_request", [], id="pull-request"),
241+
pytest.param(
242+
"pull_request", ["--ignore-commit-files"], id="ignore-commit-files"
243+
),
244+
pytest.param("push", [], id="push-with-pr-number"),
245+
],
246+
)
247+
def test_code_only_scan_with_pr_context_comments_on_each_existing_blocker(
248+
cli_runtime, github_pull_request, comparison, monkeypatch, event, extra
240249
):
250+
monkeypatch.setenv("GITHUB_EVENT_NAME", event)
241251
resolved, *blocking = HANDLEBARS_CRITICAL_ADVISORIES[:3]
242252
alerts = [_cve_alert(*resolved, action="ignore")]
243253
alerts.extend(_cve_alert(ghsa, cve) for ghsa, cve in blocking)

0 commit comments

Comments
 (0)