@sentriflow/cli 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -54
- package/dist/index.js +7522 -5041
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -29,6 +29,9 @@ sentriflow -D configs/
|
|
|
29
29
|
# Scan directory recursively
|
|
30
30
|
sentriflow -D configs/ -R
|
|
31
31
|
|
|
32
|
+
# Human-readable output for the terminal
|
|
33
|
+
sentriflow -f human router.conf
|
|
34
|
+
|
|
32
35
|
# Output results in SARIF format
|
|
33
36
|
sentriflow router.conf -f sarif
|
|
34
37
|
|
|
@@ -39,7 +42,7 @@ sentriflow --list-vendors
|
|
|
39
42
|
sentriflow --list-rules
|
|
40
43
|
|
|
41
44
|
# List rules by category
|
|
42
|
-
sentriflow --list-rules --category
|
|
45
|
+
sentriflow --list-rules --category Authentication
|
|
43
46
|
|
|
44
47
|
# List all categories
|
|
45
48
|
sentriflow --list-categories
|
|
@@ -51,24 +54,28 @@ cat router.conf | sentriflow -
|
|
|
51
54
|
## Usage
|
|
52
55
|
|
|
53
56
|
```
|
|
54
|
-
Usage: sentriflow [options] [
|
|
57
|
+
Usage: sentriflow [options] [files...]
|
|
55
58
|
|
|
56
59
|
SentriFlow Network Configuration Validator
|
|
57
60
|
|
|
58
61
|
Arguments:
|
|
59
|
-
|
|
62
|
+
files Path(s) to configuration file(s) (supports
|
|
63
|
+
multiple files)
|
|
60
64
|
|
|
61
65
|
Options:
|
|
62
|
-
-V, --version
|
|
63
|
-
-h, --help
|
|
66
|
+
-V, --version output the version number
|
|
67
|
+
-h, --help display help for command
|
|
64
68
|
```
|
|
65
69
|
|
|
70
|
+
Use `-` as the file to read from stdin.
|
|
71
|
+
|
|
66
72
|
### Output Options
|
|
67
73
|
|
|
68
74
|
| Option | Description |
|
|
69
75
|
|--------|-------------|
|
|
70
|
-
| `-f, --format <format>` | Output format: `json` (default), `sarif` |
|
|
76
|
+
| `-f, --format <format>` | Output format: `json` (default), `human`, `sarif` |
|
|
71
77
|
| `-q, --quiet` | Only output failures (suppress passed results) |
|
|
78
|
+
| `--include-passed` | Include passed results in SARIF output (omitted by default) |
|
|
72
79
|
| `--fail-on <level>` | Exit 1 only if a failed rule is at/above this severity: `error` (default), `warning`, `info`, `never` |
|
|
73
80
|
| `--suppressions <path>` | Suppression file (default: `.sentriflow-suppressions.json` in the current directory, never parent directories) |
|
|
74
81
|
| `--no-suppressions` | Ignore inline `sentriflow-disable` comments and the suppression file |
|
|
@@ -82,7 +89,9 @@ Options:
|
|
|
82
89
|
| `-v, --vendor <vendor>` | Vendor type (default: `auto`) |
|
|
83
90
|
| `--list-vendors` | List all supported vendors and exit |
|
|
84
91
|
|
|
85
|
-
Supported vendors: `cisco-ios`, `juniper-junos`, `
|
|
92
|
+
Supported vendors: `cisco-ios`, `cisco-nxos`, `juniper-junos`, `aruba-aoscx`, `aruba-aosswitch`, `aruba-wlc`, `paloalto-panos`, `arista-eos`, `vyos`, `fortinet-fortigate`, `extreme-exos`, `extreme-voss`, `huawei-vrp`, `mikrotik-routeros`, `nokia-sros`, `cumulus-linux`.
|
|
93
|
+
|
|
94
|
+
With `auto`, a file whose vendor cannot be detected is skipped with a warning and the run exits with code 2. Pass `-v <vendor>` to scan it. Cisco ASA and IOS-XR are not yet supported.
|
|
86
95
|
|
|
87
96
|
### Rule Configuration
|
|
88
97
|
|
|
@@ -93,30 +102,34 @@ Supported vendors: `cisco-ios`, `juniper-junos`, `palo-alto`, `fortinet`, `arist
|
|
|
93
102
|
| `-d, --disable <ids>` | Comma-separated rule IDs to disable |
|
|
94
103
|
| `--list-rules` | List all active rules and exit |
|
|
95
104
|
| `--list-categories` | List all rule categories with counts |
|
|
96
|
-
| `--category <name>` | Filter `--list-rules` by category |
|
|
105
|
+
| `--category <name>` | Filter `--list-rules` by category (case-sensitive, e.g. `Authentication`) |
|
|
97
106
|
| `--list-format <fmt>` | Format for `--list-rules`: `table` (default), `json`, `csv` |
|
|
98
|
-
| `-p, --rule-pack <path>` | Rule pack file to load |
|
|
99
107
|
| `--json-rules <path...>` | Path(s) to JSON rules file(s) |
|
|
100
|
-
| `-r, --rules <path>` | Additional rules
|
|
108
|
+
| `-r, --rules <path>` | Additional rules module (`.js`/`.ts`/`.mjs`/`.cjs`, legacy) |
|
|
101
109
|
|
|
102
|
-
### IP
|
|
110
|
+
### IP Summary
|
|
111
|
+
|
|
112
|
+
JSON and SARIF output include an `ipSummary` of the IP addresses and subnets found in each file.
|
|
103
113
|
|
|
104
114
|
| Option | Description |
|
|
105
115
|
|--------|-------------|
|
|
106
|
-
| `--
|
|
107
|
-
| `--copy-ips` | Copy extracted IPs to clipboard (requires xclip/pbcopy) |
|
|
116
|
+
| `--filter-special-ips` | Leave loopback, multicast, reserved and broadcast addresses out of the IP summary |
|
|
108
117
|
|
|
109
118
|
### Rule Packs and Plugins
|
|
110
119
|
|
|
111
120
|
| Option | Description |
|
|
112
121
|
|--------|-------------|
|
|
113
122
|
| `--pack <path...>` | Path(s) to rule pack module(s) (`.js`/`.ts`), or formats a plugin handles |
|
|
114
|
-
| `--strict-packs` | Deprecated no-op: a
|
|
123
|
+
| `--strict-packs` | Deprecated no-op: a rule source that fails to load always exits 2 |
|
|
124
|
+
|
|
125
|
+
A rule source you name must load, or the CLI prints the reason and exits with code 2 before scanning: a `--pack`, `--json-rules` or `--rules` entry that is missing, invalid or unsafe, and the `rules`, `rulePacks` and `jsonRules` entries of a config file.
|
|
115
126
|
|
|
116
127
|
The CLI loads plain JS/TS rule packs. Encrypted pack files (`.grx2`, `.grpx`) are rejected with `unsupported pack format (encrypted packs need the SentriFlow licensing plugin)` and exit code 2, unless a plugin has registered a loader for them.
|
|
117
128
|
|
|
118
129
|
Plugins are ES modules the CLI imports before parsing the command line: `@sentriflow/licensing/cli` if it is installed, plus any listed in `SENTRIFLOW_PLUGINS` (comma-separated package names or file paths). A plugin exports `registerCommands(program, context)`; it may add commands and options to `program` and call `context.registerPackLoader({ name, canLoad, load })` to handle extra pack formats. Plugins are trusted code. The contract is documented in [`src/plugins.ts`](src/plugins.ts).
|
|
119
130
|
|
|
131
|
+
A plugin that fails to load stops the run with exit code 2 and a message such as `Failed to load plugin './my-plugin.js': <reason>`, naming the plugin as written in `SENTRIFLOW_PLUGINS`. This includes `@sentriflow/licensing/cli` when it is installed but throws on load; when it is not installed, the CLI says nothing.
|
|
132
|
+
|
|
120
133
|
### Directory Scanning
|
|
121
134
|
|
|
122
135
|
| Option | Description |
|
|
@@ -126,6 +139,8 @@ Plugins are ES modules the CLI imports before parsing the command line: `@sentri
|
|
|
126
139
|
| `--glob <pattern>` | Glob pattern for file matching (e.g., `"*.cfg"`) |
|
|
127
140
|
| `--extensions <exts>` | File extensions to include (comma-separated; leading dot optional) |
|
|
128
141
|
| `--exclude <patterns>` | Exclude patterns (comma-separated glob patterns) |
|
|
142
|
+
| `--exclude-pattern <pattern...>` | Regex pattern(s) to exclude files |
|
|
143
|
+
| `--max-depth <number>` | Maximum recursion depth (use with `-R`) |
|
|
129
144
|
| `--progress` | Show progress during directory scanning |
|
|
130
145
|
|
|
131
146
|
### Security Options
|
|
@@ -134,6 +149,29 @@ Plugins are ES modules the CLI imports before parsing the command line: `@sentri
|
|
|
134
149
|
|--------|-------------|
|
|
135
150
|
| `--allow-external` | Allow reading files outside the current directory |
|
|
136
151
|
|
|
152
|
+
## Exit Codes
|
|
153
|
+
|
|
154
|
+
| Code | Meaning |
|
|
155
|
+
|------|---------|
|
|
156
|
+
| `0` | No failed rule at or above the `--fail-on` severity |
|
|
157
|
+
| `1` | At least one failed rule at or above the `--fail-on` severity (default `error`) |
|
|
158
|
+
| `2` | Error: for example a file that cannot be read, a file whose vendor cannot be detected, a rule source (`--rules`, `--pack`, `--json-rules`, config file entries) or plugin that fails to load, or an invalid suppression file |
|
|
159
|
+
|
|
160
|
+
By default only `error`-level findings exit 1. Use `--fail-on warning` or `--fail-on info` for a stricter threshold, or `--fail-on never` to report without failing.
|
|
161
|
+
|
|
162
|
+
## Suppressions
|
|
163
|
+
|
|
164
|
+
Accepted findings can be suppressed with comments in the configuration or in a committed `.sentriflow-suppressions.json` (each entry needs a `reason`):
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
! sentriflow-disable-next-line NET-SNMP-002 -- lab router, read-only community
|
|
168
|
+
snmp-server community public RO
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Directives: `sentriflow-disable-next-line`, `sentriflow-disable-line`, `sentriflow-disable` / `sentriflow-enable` ranges and `sentriflow-disable-file`. When a rule reports several findings on one line, `RULE:word` (inline) or the `message` field (suppression file) targets the finding whose message contains that word; a bare rule ID suppresses all of them. `sentriflow-enable RULE` also ends `RULE:word` ranges.
|
|
172
|
+
|
|
173
|
+
The suppression file is read from the current working directory only (`--suppressions <path>` picks another; `--no-suppressions` ignores all suppressions). Suppressed findings do not affect the exit code and are counted on stderr. See the [suppressions guide](https://docs.sentriflow.com.au/cli/suppressions).
|
|
174
|
+
|
|
137
175
|
## Output Formats
|
|
138
176
|
|
|
139
177
|
### JSON (default)
|
|
@@ -142,25 +180,31 @@ Plugins are ES modules the CLI imports before parsing the command line: `@sentri
|
|
|
142
180
|
{
|
|
143
181
|
"vendor": {
|
|
144
182
|
"id": "cisco-ios",
|
|
145
|
-
"name": "Cisco IOS"
|
|
183
|
+
"name": "Cisco IOS/IOS-XE"
|
|
146
184
|
},
|
|
147
185
|
"results": [
|
|
148
186
|
{
|
|
149
|
-
"ruleId": "SEC-001",
|
|
150
187
|
"passed": false,
|
|
151
|
-
"message": "
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
"
|
|
188
|
+
"message": "Default SNMP community string \"public\" detected. Use a complex string.",
|
|
189
|
+
"ruleId": "NET-SNMP-002",
|
|
190
|
+
"nodeId": "snmp-server community public RO",
|
|
191
|
+
"level": "error",
|
|
192
|
+
"loc": { "startLine": 25, "endLine": 25 },
|
|
193
|
+
"category": "Protocol-Security",
|
|
155
194
|
"tags": [
|
|
156
|
-
{ "type": "
|
|
195
|
+
{ "type": "general", "label": "snmp" },
|
|
196
|
+
{ "type": "general", "label": "default-credentials" }
|
|
157
197
|
]
|
|
158
198
|
}
|
|
159
|
-
]
|
|
199
|
+
],
|
|
200
|
+
"suppressed": [],
|
|
201
|
+
"ipSummary": { ... }
|
|
160
202
|
}
|
|
161
203
|
```
|
|
162
204
|
|
|
163
|
-
|
|
205
|
+
`loc` line numbers are 0-based (SARIF and human output are 1-based).
|
|
206
|
+
|
|
207
|
+
### JSON (multiple files or directory mode)
|
|
164
208
|
|
|
165
209
|
```json
|
|
166
210
|
{
|
|
@@ -168,39 +212,34 @@ Plugins are ES modules the CLI imports before parsing the command line: `@sentri
|
|
|
168
212
|
"filesScanned": 3,
|
|
169
213
|
"totalResults": 15,
|
|
170
214
|
"failures": 5,
|
|
171
|
-
"passed": 10
|
|
215
|
+
"passed": 10,
|
|
216
|
+
"suppressed": 0
|
|
172
217
|
},
|
|
173
218
|
"files": [
|
|
174
219
|
{
|
|
175
220
|
"file": "/path/to/router.conf",
|
|
176
|
-
"vendor": { "id": "cisco-ios", "name": "Cisco IOS" },
|
|
177
|
-
"results": [...]
|
|
221
|
+
"vendor": { "id": "cisco-ios", "name": "Cisco IOS/IOS-XE" },
|
|
222
|
+
"results": [...],
|
|
223
|
+
"suppressed": [],
|
|
224
|
+
"ipSummary": { ... }
|
|
178
225
|
}
|
|
179
226
|
]
|
|
180
227
|
}
|
|
181
228
|
```
|
|
182
229
|
|
|
230
|
+
A file whose vendor cannot be detected appears with `"skipped": true` and a `skipReason`.
|
|
231
|
+
|
|
183
232
|
### SARIF
|
|
184
233
|
|
|
185
|
-
Produces SARIF 2.1.0
|
|
234
|
+
Produces SARIF 2.1.0 output for GitHub Code Scanning and other tools. Passed results are left out unless you add `--include-passed`.
|
|
186
235
|
|
|
187
236
|
```bash
|
|
188
|
-
sentriflow router.conf -f sarif > results.sarif
|
|
237
|
+
sentriflow router.conf -f sarif --relative-paths > results.sarif
|
|
189
238
|
```
|
|
190
239
|
|
|
191
|
-
|
|
240
|
+
Each rule carries its category and tags in `properties`; rules with a CWE also carry a `security-severity` and a CWE relationship (`run.taxonomies`). Each result has a `partialFingerprints.primaryLocationLineHash` built from the rule ID, the message (digits ignored), the text of the reported line and the relative file path, so alerts survive line shifts.
|
|
192
241
|
|
|
193
|
-
|
|
194
|
-
{
|
|
195
|
-
"rules": [{
|
|
196
|
-
"id": "SEC-001",
|
|
197
|
-
"properties": {
|
|
198
|
-
"category": "authentication",
|
|
199
|
-
"tags": ["security:plaintext-protocol"]
|
|
200
|
-
}
|
|
201
|
-
}]
|
|
202
|
-
}
|
|
203
|
-
```
|
|
242
|
+
> Upgrading from 0.7.x or earlier: fingerprints now include the finding message, so after the upgrade GitHub Code Scanning closes the existing SentriFlow alerts and opens the same findings again as new alerts, once. See the [SARIF guide](https://docs.sentriflow.com.au/cli/sarif).
|
|
204
243
|
|
|
205
244
|
## Rule Categories
|
|
206
245
|
|
|
@@ -210,47 +249,60 @@ List all available categories:
|
|
|
210
249
|
sentriflow --list-categories
|
|
211
250
|
```
|
|
212
251
|
|
|
213
|
-
Filter rules by category:
|
|
252
|
+
Filter rules by category (the name is case-sensitive, as `--list-categories` prints it):
|
|
214
253
|
|
|
215
254
|
```bash
|
|
216
255
|
# List only authentication rules
|
|
217
|
-
sentriflow --list-rules --category
|
|
256
|
+
sentriflow --list-rules --category Authentication
|
|
218
257
|
|
|
219
258
|
# Output as JSON
|
|
220
|
-
sentriflow --list-rules --category
|
|
259
|
+
sentriflow --list-rules --category VPN --list-format json
|
|
221
260
|
```
|
|
222
261
|
|
|
223
262
|
## CI/CD Integration
|
|
224
263
|
|
|
225
264
|
### GitHub Actions
|
|
226
265
|
|
|
266
|
+
The SentriFlow Action runs the CLI, uploads SARIF to Code Scanning and fails the job by `--fail-on`:
|
|
267
|
+
|
|
268
|
+
```yaml
|
|
269
|
+
- uses: sentriflow/sentriflow@v0
|
|
270
|
+
with:
|
|
271
|
+
path: configs/
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Or call the CLI yourself:
|
|
275
|
+
|
|
227
276
|
```yaml
|
|
228
277
|
- name: Check network config compliance
|
|
229
|
-
run:
|
|
230
|
-
npx @sentriflow/cli -D configs/ -R -f sarif > results.sarif
|
|
278
|
+
run: npx @sentriflow/cli -D configs/ -R -f sarif --relative-paths > results.sarif
|
|
231
279
|
|
|
232
280
|
- name: Upload SARIF
|
|
233
|
-
|
|
281
|
+
if: always()
|
|
282
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
234
283
|
with:
|
|
235
284
|
sarif_file: results.sarif
|
|
236
285
|
```
|
|
237
286
|
|
|
287
|
+
A Docker image (`ghcr.io/sentriflow/cli`) and a pre-commit hook are also available. See the [integration docs](https://docs.sentriflow.com.au/integrations/).
|
|
288
|
+
|
|
238
289
|
## Configuration File
|
|
239
290
|
|
|
240
291
|
SentriFlow automatically loads a config file (`sentriflow.config.ts`, `sentriflow.config.js`, `.sentriflowrc.ts` or `.sentriflowrc.js`) from the **current working directory only** and prints `Using config: <path>` to stderr. Parent directories and the scanned path are never searched; use `--config <path>` for any other location.
|
|
241
292
|
|
|
242
293
|
> A config file is trusted code. Do not run the tool from inside a directory you do not trust without `--no-config`. The GitHub Action and the Docker image run with `--no-config` unless you opt in (`config` input / `--config <path>`).
|
|
243
294
|
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
295
|
+
```js
|
|
296
|
+
// sentriflow.config.js
|
|
297
|
+
export default {
|
|
298
|
+
disable: ['NET-DOC-001'],
|
|
299
|
+
jsonRules: ['./rules/org-rules.json'],
|
|
300
|
+
directory: { recursive: true, extensions: ['cfg', 'conf'] },
|
|
301
|
+
};
|
|
252
302
|
```
|
|
253
303
|
|
|
304
|
+
See the [configuration reference](https://docs.sentriflow.com.au/cli/configuration) for all options.
|
|
305
|
+
|
|
254
306
|
## Related Packages
|
|
255
307
|
|
|
256
308
|
- [`@sentriflow/core`](https://github.com/sentriflow/sentriflow/tree/main/packages/core) - Core parsing and compliance engine
|