Skip to content

Commit 43ab7ff

Browse files
committed
Docs refactor for better readability, dedicated guides for CLI + CI/CD usage
Signed-off-by: lelia <lelia@socket.dev>
1 parent 3098639 commit 43ab7ff

File tree

4 files changed

+101
-16
lines changed

4 files changed

+101
-16
lines changed

README.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,19 @@ socketcli \
7979
--disable-blocking
8080
```
8181

82-
## Scope and behavior matrix
82+
## Choose your mode
8383

84-
| Goal | Key flags | Notes |
84+
| Use case | Recommended mode | Key flags |
8585
|:--|:--|:--|
86-
| Match dashboard-style reachable view | `--sarif-scope full --sarif-grouping alert --sarif-reachability reachable` | Best parity path for customer evaluations |
87-
| Capture all reachability findings | `--sarif-scope full --sarif-grouping instance --sarif-reachability all` | Most verbose output |
88-
| Gate only on new findings | `--sarif-scope diff` | Diff mode can validly return empty SARIF |
89-
| Filter to reachable only (legacy syntax) | `--sarif-reachable-only` | Backward-compatible alias for `--sarif-reachability reachable` |
86+
| Basic policy enforcement in CI | Diff-based policy check | `--strict-blocking` |
87+
| Reachable-focused SARIF for reporting | Full-scope grouped SARIF | `--reach --sarif-scope full --sarif-grouping alert --sarif-reachability reachable --sarif-file <path>` |
88+
| Detailed reachability export for investigations | Full-scope instance SARIF | `--reach --sarif-scope full --sarif-grouping instance --sarif-reachability all --sarif-file <path>` |
89+
| Net-new PR findings only | Diff-scope SARIF | `--reach --sarif-scope diff --sarif-reachability reachable --sarif-file <path>` |
90+
91+
Dashboard parity note:
92+
- Full-scope SARIF is the closest match for dashboard-style filtering.
93+
- Exact result counts can still differ from the dashboard due to backend/API consolidation differences and grouping semantics.
94+
- See [`docs/troubleshooting.md#dashboard-vs-cli-result-counts`](docs/troubleshooting.md#dashboard-vs-cli-result-counts).
9095

9196
## Config files (`--config`)
9297

@@ -108,6 +113,21 @@ sarif_reachability = "reachable"
108113
sarif_file = "reachable.sarif"
109114
```
110115

116+
Equivalent JSON:
117+
118+
```json
119+
{
120+
"socketcli": {
121+
"repo": "example-repo",
122+
"reach": true,
123+
"sarif_scope": "full",
124+
"sarif_grouping": "alert",
125+
"sarif_reachability": "reachable",
126+
"sarif_file": "reachable.sarif"
127+
}
128+
}
129+
```
130+
111131
Run:
112132

113133
```bash
@@ -116,10 +136,16 @@ socketcli --config .socketcli.toml --target-path .
116136

117137
Reference sample configs:
118138

139+
TOML:
119140
- [`examples/config/sarif-dashboard-parity.toml`](examples/config/sarif-dashboard-parity.toml)
120141
- [`examples/config/sarif-instance-detail.toml`](examples/config/sarif-instance-detail.toml)
121142
- [`examples/config/sarif-diff-ci-cd.toml`](examples/config/sarif-diff-ci-cd.toml)
122143

144+
JSON:
145+
- [`examples/config/sarif-dashboard-parity.json`](examples/config/sarif-dashboard-parity.json)
146+
- [`examples/config/sarif-instance-detail.json`](examples/config/sarif-instance-detail.json)
147+
- [`examples/config/sarif-diff-ci-cd.json`](examples/config/sarif-diff-ci-cd.json)
148+
123149
## CI/CD examples
124150

125151
Prebuilt workflow examples:

docs/ci-cd.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ socketcli \
2929

3030
## Config file usage in CI
3131

32-
Use `--config .socketcli.toml` to keep pipeline commands small.
32+
Use `--config .socketcli.toml` or `--config .socketcli.json` to keep pipeline commands small.
3333

3434
Precedence order:
3535

@@ -46,6 +46,20 @@ sarif_reachability = "reachable"
4646
sarif_file = "results.sarif"
4747
```
4848

49+
Equivalent JSON:
50+
51+
```json
52+
{
53+
"socketcli": {
54+
"reach": true,
55+
"sarif_scope": "full",
56+
"sarif_grouping": "alert",
57+
"sarif_reachability": "reachable",
58+
"sarif_file": "results.sarif"
59+
}
60+
}
61+
```
62+
4963
## Platform examples
5064

5165
### GitHub Actions
@@ -98,7 +112,7 @@ Prebuilt examples in this repo:
98112

99113
## CI gotchas
100114

101-
- `--strict-blocking` changes pass/fail policy, not SARIF dataset semantics.
115+
- `--strict-blocking` enables strict diff behavior (`new + unchanged`) for blocking evaluation and diff-based output selection.
102116
- `--sarif-scope full` requires `--reach`.
103117
- `--sarif-grouping alert` currently applies to `--sarif-scope full`.
104118
- Diff-based SARIF can validly be empty when there are no matching net-new alerts.

docs/cli-reference.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ This will simultaneously generate:
122122
- SARIF report to `results.sarif` (and stdout)
123123
- GitLab Security Dashboard report to `gl-dependency-scanning-report.json`
124124

125-
> **Note:** `--enable-sarif` prints SARIF to stdout only. Use `--sarif-file <path>` to save to a file (this also implies `--enable-sarif`). Add `--sarif-reachable-only` (requires `--reach`) to filter results down to only reachable findings. Use `--sarif-scope diff|full` to choose between diff alerts (default) and full reachability facts scope. These flags are independent from `--enable-gitlab-security`, which produces a separate GitLab-specific Dependency Scanning report.
125+
> **Note:** `--enable-sarif` prints SARIF to stdout only. Use `--sarif-file <path>` to save to a file (this also implies `--enable-sarif`). Use `--sarif-reachability` (requires `--reach` when not `all`) to filter by reachability state. Use `--sarif-scope diff|full` to choose between diff alerts (default) and full reachability facts scope. These flags are independent from `--enable-gitlab-security`, which produces a separate GitLab-specific Dependency Scanning report.
126126
>
127-
> `--strict-blocking` affects pass/fail behavior, not SARIF result population.
127+
> In diff scope, `--strict-blocking` expands selection to include `new + unchanged` diff alerts for evaluation/output paths.
128128
>
129129
> SARIF scope examples:
130-
> - Diff-only reachable findings: `socketcli --reach --sarif-file out.sarif --sarif-scope diff --sarif-reachable-only`
131-
> - Full reachability scope, reachable only: `socketcli --reach --sarif-file out.sarif --sarif-scope full --sarif-reachable-only`
130+
> - Diff-only reachable findings: `socketcli --reach --sarif-file out.sarif --sarif-scope diff --sarif-reachability reachable`
131+
> - Full reachability scope, reachable only: `socketcli --reach --sarif-file out.sarif --sarif-scope full --sarif-reachability reachable`
132132
> - Full reachability scope, all reachability states: `socketcli --reach --sarif-file out.sarif --sarif-scope full`
133133
> - Dashboard-style grouping (one result per alert key): `socketcli --reach --sarif-file out.sarif --sarif-scope full --sarif-grouping alert --sarif-reachability reachable`
134134
>
@@ -149,7 +149,7 @@ socketcli [-h] [--api-token API_TOKEN] [--repo REPO] [--workspace WORKSPACE] [--
149149
[--target-path TARGET_PATH] [--sbom-file SBOM_FILE] [--license-file-name LICENSE_FILE_NAME] [--save-submitted-files-list SAVE_SUBMITTED_FILES_LIST]
150150
[--save-manifest-tar SAVE_MANIFEST_TAR] [--files FILES] [--sub-path SUB_PATH] [--workspace-name WORKSPACE_NAME]
151151
[--excluded-ecosystems EXCLUDED_ECOSYSTEMS] [--default-branch] [--pending-head] [--generate-license] [--enable-debug]
152-
[--enable-json] [--enable-sarif] [--sarif-file <path>] [--sarif-reachable-only] [--sarif-scope {diff,full}] [--sarif-grouping {instance,alert}] [--sarif-reachability {all,reachable,potentially,reachable-or-potentially}] [--enable-gitlab-security] [--gitlab-security-file <path>]
152+
[--enable-json] [--enable-sarif] [--sarif-file <path>] [--sarif-scope {diff,full}] [--sarif-grouping {instance,alert}] [--sarif-reachability {all,reachable,potentially,reachable-or-potentially}] [--enable-gitlab-security] [--gitlab-security-file <path>]
153153
[--disable-overview] [--exclude-license-details] [--allow-unverified] [--disable-security-issue]
154154
[--ignore-commit-files] [--disable-blocking] [--enable-diff] [--scm SCM] [--timeout TIMEOUT] [--include-module-folders]
155155
[--reach] [--reach-version REACH_VERSION] [--reach-timeout REACH_ANALYSIS_TIMEOUT]
@@ -219,7 +219,6 @@ If you don't want to provide the Socket API Token every time then you can use th
219219
| `--enable-json` | False | False | Output in JSON format |
220220
| `--enable-sarif` | False | False | Enable SARIF output of results instead of table or JSON format (prints to stdout) |
221221
| `--sarif-file` | False | | Output file path for SARIF report (implies --enable-sarif). Use this to save SARIF output to a file for upload to GitHub Code Scanning, SonarQube, VS Code, or other SARIF-compatible tools |
222-
| `--sarif-reachable-only` | False | False | Filter SARIF output to only include reachable findings (requires --reach) |
223222
| `--sarif-scope` | False | diff | SARIF source scope: `diff` for net-new diff alerts, or `full` for full reachability facts scope (requires --reach for full) |
224223
| `--sarif-grouping` | False | instance| SARIF grouping mode: `instance` (one entry per package/version/advisory instance) or `alert` (grouped alert-style output, full scope only) |
225224
| `--sarif-reachability` | False | all | SARIF reachability selector: `all`, `reachable`, `potentially`, or `reachable-or-potentially` (requires --reach when not `all`) |
@@ -273,6 +272,29 @@ sarif_reachability = "reachable"
273272
sarif_file = "reachable.sarif"
274273
```
275274

275+
Equivalent `socketcli.json`:
276+
277+
```json
278+
{
279+
"socketcli": {
280+
"repo": "example-repo",
281+
"reach": true,
282+
"sarif_scope": "full",
283+
"sarif_grouping": "alert",
284+
"sarif_reachability": "reachable",
285+
"sarif_file": "reachable.sarif"
286+
}
287+
}
288+
```
289+
290+
Sample config files:
291+
- [`../examples/config/sarif-dashboard-parity.toml`](../examples/config/sarif-dashboard-parity.toml)
292+
- [`../examples/config/sarif-dashboard-parity.json`](../examples/config/sarif-dashboard-parity.json)
293+
- [`../examples/config/sarif-instance-detail.toml`](../examples/config/sarif-instance-detail.toml)
294+
- [`../examples/config/sarif-instance-detail.json`](../examples/config/sarif-instance-detail.json)
295+
- [`../examples/config/sarif-diff-ci-cd.toml`](../examples/config/sarif-diff-ci-cd.toml)
296+
- [`../examples/config/sarif-diff-ci-cd.json`](../examples/config/sarif-diff-ci-cd.json)
297+
276298
### CI/CD usage tips
277299

278300
For CI-specific examples and guidance, see [`ci-cd.md`](ci-cd.md).
@@ -407,7 +429,7 @@ export SOCKET_SLACK_BOT_TOKEN="xoxb-your-bot-token-here"
407429
**Configuration Options:**
408430

409431
Webhook mode (`url_configs`):
410-
- `reachability_alerts_only` (boolean, default: false): When `--reach` is enabled, only send blocking alerts (error=true) from diff scans
432+
- `reachability_alerts_only` (boolean, default: false): When `--reach` is enabled, only send reachable vulnerabilities from the selected diff alert set (uses reachability facts when available; otherwise falls back to blocking-status behavior)
411433
- `repos` (array): Only send alerts for specific repositories (e.g., `["owner/repo1", "owner/repo2"]`)
412434
- `alert_types` (array): Only send specific alert types (e.g., `["malware", "typosquat"]`)
413435
- `severities` (array): Only send alerts with specific severities (e.g., `["high", "critical"]`)

docs/troubleshooting.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,34 @@
22

33
## Common gotchas
44

5-
- `--strict-blocking` changes pass/fail policy, not SARIF dataset source.
5+
- In diff scope, `--strict-blocking` uses a stricter alert set (`new + unchanged`) for blocking checks and diff-based output selection.
66
- `--sarif-scope full` requires `--reach`.
77
- In `--sarif-scope full` with `--sarif-file`, SARIF JSON is written to file and stdout JSON is suppressed.
88
- `--sarif-grouping alert` currently applies to `--sarif-scope full`.
99

10+
## Dashboard vs CLI result counts
11+
12+
Differences in result counts can be valid, even when filtering appears similar.
13+
14+
Common reasons:
15+
16+
- `diff` vs `full` data source:
17+
- `--sarif-scope diff` is based on diff alerts (typically net-new in the compared scan context).
18+
- `--sarif-scope full` is based on full reachability facts data.
19+
- Consolidation differences:
20+
- Dashboard and API/CLI can apply different consolidation/grouping rules.
21+
- `--sarif-grouping alert` and `--sarif-grouping instance` intentionally produce different row counts.
22+
- Policy vs dataset:
23+
- `--strict-blocking` only affects diff-scope behavior and does not make diff output equivalent to full dashboard data.
24+
- Reachability data availability:
25+
- If reachability analysis partially fails and falls back to precomputed tiers, counts can shift.
26+
27+
Recommended comparison path:
28+
29+
1. Use full-scope SARIF for parity-oriented comparisons.
30+
2. Keep grouping fixed (`alert` for dashboard-style rollups, `instance` for detailed exports).
31+
3. Compare reachability filters with the same mode and grouping across runs.
32+
1033
## Save submitted file list
1134

1235
Use `--save-submitted-files-list` to inspect exactly what was sent for scanning.

0 commit comments

Comments
 (0)