You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve monorepo scan diagnostics and guidance (#325)
* Improve monorepo scan diagnostics
* Bump version to 2.6.9
* Bump version to 2.7.0
* docs: document the monorepo scan layout trade-off
The mechanics of --sub-path and --workspace-name were documented, but not the
choice they force. One combined scan gives a single dashboard entry and no
per-component attribution; one scan per component gives attribution, baselines
and per-component policy, but adds a repository entry per component, which grows
the dashboard's repository list. There is no layout that provides both today.
Customers hit this at a dozen-plus components and reasonably assume they have
configured something wrong. Naming the trade-off, and adding rules of thumb for
picking a side, is cheaper than each of them discovering it.
Cross-referenced from the CI/CD guide's independent-workspace pattern, which is
the layout that grows the list.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/cli-reference.md
+69-6Lines changed: 69 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,18 +53,67 @@ Pre-configured workflow files are in [`../workflows/`](../workflows/).
53
53
54
54
> **Note:** If you're looking to associate a scan with a named Socket workspace (e.g. because your repo is identified as `org/repo`), see the [`--workspace` flag](#repository) instead. The `--workspace-name` flag described in this section is an unrelated monorepo feature.
55
55
56
-
The Socket CLI supports scanning specific workspaces within monorepo structures while preserving git context from the repository root. This is useful for organizations that maintain multiple applications or services in a single repository.
56
+
The Socket CLI supports scanning selected directories within a monorepo while preserving git context from the repository root. Scan scope is controlled by `--target-path` and `--sub-path`; CI workflow path filters and the CLI's changed-file detection do not narrow the manifests uploaded after a scan starts.
57
57
58
58
### Key Features
59
59
60
-
-**Multiple Sub-paths**: Specify multiple `--sub-path`options to scan different directories within your monorepo
61
-
-**Combined Workspace**: All sub-paths are scanned together as a single workspace in Socket
60
+
-**Target path**: Supplies repository/Git context and is the discovery root when no `--sub-path`is present
61
+
-**Multiple Sub-paths**: Restrict discovery to those directories, but combine every repeated `--sub-path` into one upload and one server-side dependency graph
62
62
-**Git Context Preserved**: Repository metadata (commits, branches, etc.) comes from the main target-path
63
-
-**Workspace Naming**: Use `--workspace-name` to differentiate scans from different parts of your monorepo
63
+
-**Workspace Naming**: Use a stable, unique `--workspace-name` for each independently scanned logical workspace; it suffixes the repository slug and therefore gives that workspace its own repository head/baseline
64
+
65
+
`--workspace` is different: it sends Socket organization workspace context with the full-scan API request. It does not narrow client-side filesystem discovery, split the upload into independent scans, or change the repository suffix. Backend policy/routing for that workspace remains server-owned.
66
+
67
+
> **Performance consequence:** If the goal is smaller independently resolvable graphs, run one CLI invocation per logical workspace, with a distinct `--workspace-name`. Adding several unrelated directories to one command with repeated `--sub-path` flags still asks the backend to resolve one combined graph.
68
+
69
+
Normal scan logs include the effective repository and Socket workspace context,
70
+
repository-relative discovery roots, aggregate manifest count, and selected baseline.
71
+
Individual manifest paths remain opt-in through `--save-submitted-files-list`.
72
+
73
+
### Choosing a scan layout
74
+
75
+
`--sub-path` and `--workspace-name` support two layouts, and picking between them
76
+
is a trade-off rather than a preference. There is no third option today.
77
+
78
+
**One combined scan** — a single invocation, no `--workspace-name`, with
79
+
`--target-path` at the repository root or several repeated `--sub-path` values
80
+
sharing one workspace name:
81
+
82
+
- One dashboard entry for the repository, named after the repository
83
+
- One server-side dependency graph covering everything that was uploaded
84
+
- Alerts are **not** broken out by component, so a finding does not tell you which
85
+
part of the monorepo introduced it
86
+
- Transitive findings can surface without a clear owning component, because the
87
+
combined graph has no component boundaries to attribute them to
88
+
89
+
**One scan per component** — a separate invocation per component, each with its
90
+
own `--sub-path` and a distinct `--workspace-name`:
91
+
92
+
- Per-component alerts, baselines, and policy
93
+
- Each component gets its own dependency graph, which is also the faster option
94
+
(see the performance note above)
95
+
- But `--workspace-name` suffixes the repository slug, so *N* components produce
96
+
*N* separate entries in the dashboard's repository list
97
+
98
+
The second point is what makes this a real choice: a monorepo with a dozen or more
99
+
independently scanned components produces a dozen or more repository entries, which
100
+
gets hard to navigate as the list grows. A single consolidated entry that still
101
+
preserves per-component attribution is a known request and is not available today.
102
+
103
+
Rules of thumb:
104
+
105
+
-**Few components, or components that share a release cycle** — use one combined
106
+
scan and accept coarser attribution.
107
+
-**Many components, or components with different owners or policies** — use
108
+
per-component scans and accept the extra dashboard entries. Per-component policy
109
+
is only possible in this layout.
110
+
-**Components that are genuinely one application** — group them under a single
111
+
`--workspace-name`, as in the first example below. Grouping is per logical
112
+
application, not per directory.
64
113
65
114
### Usage Examples
66
115
67
-
**Scan multiple frontend and backend workspaces:**
116
+
**Scan several directories that belong to one logical application:**
68
117
```bash
69
118
socketcli --target-path /path/to/monorepo \
70
119
--sub-path frontend \
@@ -89,6 +138,19 @@ This will:
89
138
- Create a repository in Socket named like `my-repo-mobile-web`
90
139
- Preserve git context (commits, branch info) from the repository root
91
140
141
+
**Create independent frontend and backend scans:**
142
+
```bash
143
+
socketcli --target-path /path/to/monorepo \
144
+
--sub-path frontend \
145
+
--workspace-name frontend
146
+
147
+
socketcli --target-path /path/to/monorepo \
148
+
--sub-path backend \
149
+
--workspace-name backend
150
+
```
151
+
152
+
These are two full-scan uploads, two server-side graphs, and two repository head/baseline sequences. In CI they can run as separate matrix jobs. See [GitHub Actions: scan changed monorepo workspaces independently](ci-cd.md#github-actions-scan-changed-monorepo-workspaces-independently).
153
+
92
154
**Generate GitLab Security Dashboard report:**
93
155
```bash
94
156
socketcli --enable-gitlab-security \
@@ -138,6 +200,7 @@ This will simultaneously generate:
138
200
139
201
- Both `--sub-path` and `--workspace-name` must be specified together
140
202
-`--sub-path` can be used multiple times to include multiple directories
203
+
- Repeated `--sub-path` values are combined into one scan; they do not create independent workspace scans
141
204
- All specified sub-paths must exist within the target-path
142
205
143
206
## Usage
@@ -372,7 +435,7 @@ The launcher can be tuned via the `SOCKET_CLI_COANA_LAUNCHER` environment variab
372
435
|`--strict-blocking`| False | False | Fail on ANY security policy violations (blocking severity), not just new ones. Only works in diff mode. See [Strict Blocking Mode](#strict-blocking-mode) for details. |
373
436
|`--enable-diff`| False | False | Enable diff mode even when using `--integration api` (forces diff mode without SCM integration) |
374
437
|`--scm`| False | api | Source control management type|
375
-
|`--timeout`| False || Timeout in seconds for API requests |
438
+
|`--timeout`| False |1200| Timeout in seconds foreach API request. This is not a total CLI runtime limit and does not limit local discovery, Git, or reachability analysis.|
0 commit comments