sfscanner 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 n8n-secureflow contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,214 @@
1
- # Temporary Holding Version
1
+ # sfscanner — The n8n-SecureFlow Command-Line Interface & Native AI MCP Server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **CLI Executable:** `sfscanner`
4
+ > **Native AI MCP Server:** `sfscanner-mcp` (`dist/mcp.js`)
5
+ > **Licensing:** MIT for this package's code and scanner tooling. The catalogue dataset has separate Personal / Non-Commercial terms; see the [canonical policy](https://github.com/jitwark/n8n-Secureflow/blob/main/docs/LICENSING.md).
6
+
7
+ ---
8
+
9
+ ## 1. Overview
10
+
11
+ `sfscanner` is a high-performance, deterministic offline command-line scanner and native **Model Context Protocol (MCP)** server for n8n workflows. Built directly on `@hub/scanner-core`, it allows individual developers, DevOps engineers, and autonomous AI coding agents to audit workflow security without uploading workflow JSON to external servers.
12
+
13
+ ### Core Highlights
14
+ * ⚡ **Sub-15ms Latency:** Audits typical workflows in ~12–15 milliseconds on modern CPUs.
15
+ * 🛡️ **Zero Network Telemetry:** Operates 100% offline; zero outbound calls or analytics pings.
16
+ * 📊 **Enterprise SARIF 2.1.0:** Generates standard SARIF reports that integrate directly with GitHub Code Scanning, GitLab Security Dashboards, and VS Code.
17
+ * 🤖 **Built-In AI MCP Server:** Connects directly to Claude Desktop, Cursor, and agentic workflows to inspect workflows before importing.
18
+
19
+ ---
20
+
21
+ ## 2. Installation & Quickstart
22
+
23
+ ### Personal Use Installation
24
+ ```bash
25
+ # The repository is private: cloning requires access you have been granted.
26
+ git clone https://github.com/jitwark/n8n-community.git
27
+ cd n8n-community/community-hub
28
+
29
+ # Install dependencies and build CLI & MCP binaries
30
+ npm install
31
+ npm run build --workspace=sfscanner
32
+
33
+ # Link globally for local personal use
34
+ npm link --workspace=sfscanner
35
+ ```
36
+
37
+ `sfscanner` is published on the public npm registry. `private: false` in this package's manifest is a
38
+ packaging flag, not an availability claim. To install the tarball instead of the registry copy, use
39
+ `npm pack --workspace sfscanner`, or run the workspace build above. v2 inputs must be
40
+ selection-root-relative paths; [docs/scanner/cli-v2.md](../../docs/scanner/cli-v2.md) states that rule
41
+ and carries a verified Windows example.
42
+
43
+ ### Basic Command-Line Usage
44
+ ```bash
45
+ # Scan a single workflow
46
+ sfscanner scan path/to/workflow.json
47
+
48
+ # Scan a directory of workflows with SARIF output
49
+ sfscanner scan ./workflows --format sarif > results.sarif
50
+
51
+ # Scan via standard input (piped from curl or cat)
52
+ cat my-workflow.json | sfscanner scan -
53
+
54
+ # Inspect admitted security policies
55
+ sfscanner rules --format table
56
+
57
+ # Explain a specific rule and its remediation
58
+ sfscanner explain TAINTED_COMMAND
59
+ ```
60
+
61
+ ---
62
+
63
+ ## 3. CLI Command Reference & Grammar
64
+
65
+ ```text
66
+ sfscanner --schema v2 scan <file|directory|-> [options]
67
+ sfscanner --schema v2 rules [--format json|table]
68
+ sfscanner --schema v2 explain <rule-id> [--format json|table]
69
+ sfscanner --schema v2 profiles [--format json|table]
70
+ sfscanner --schema v2 validate-config <config-file> [--format json|table]
71
+ sfscanner --schema v2 version [--format json|table]
72
+ ```
73
+
74
+ `--schema v2` is **required for `--fail-on`, `--output` and directory scans**. Omitting it
75
+ runs only the single-document form: `--fail-on` and `--output` then exit `2`, and a directory
76
+ argument exits `3`. Pass it explicitly.
77
+
78
+ ### Command Options for `scan`
79
+ * `--format <json|ndjson|sarif|table>`: Choose output format (Default: `json`). The CLI does not
80
+ detect a terminal, so `table` is never selected for you — pass `--format table` to get it.
81
+ * `--fail-on <CRITICAL|HIGH|MEDIUM|LOW|INFO>`: Set exit-code failure threshold (Default: `HIGH`).
82
+ * `--profile <beta-default>`: Select scanning profile (Default: `beta-default@2.0.0`).
83
+ * `--include <glob>` / `--exclude <glob>`: Filter workflow paths during directory scans.
84
+ * `--output <file>`: Atomic write destination using temporary files to prevent partial file corruption.
85
+
86
+ ### Supported platforms
87
+
88
+ **Node 22 is the only supported line**, and it has only been verified on Windows; Linux and
89
+ macOS runs are pending. `engines.node` accepts `>=22 <23`, so the installer admits the 22
90
+ series and refuses 23 and 24 outright rather than admitting lines that were never run. Pin
91
+ Node 22 in CI until a matrix result exists for another line.
92
+
93
+ ---
94
+
95
+ ## 4. Exit Code Lattice
96
+
97
+ The CLI uses a deterministic exit code lattice to communicate scan results to CI/CD pipelines:
98
+
99
+ | Exit Code | Classification | Meaning |
100
+ | :---: | :--- | :--- |
101
+ | `0` | **CLEAN / SUCCESS** | Scan completed; no findings met or exceeded the `--fail-on` threshold. |
102
+ | `1` | **FINDINGS_EXCEEDED** | One or more findings met or exceeded the configured threshold. |
103
+ | `2` | **USAGE_OR_CONFIG_ERROR** | Invalid CLI arguments, bad config file, or unknown rule profile. |
104
+ | `3` | **INPUT_OR_INDETERMINATE** | Input JSON is malformed, or missing dependencies forced an `INDETERMINATE` state under strict mode. |
105
+ | `4` | **INTERNAL_ERROR** | Uncaught scanner error or memory ceiling violation. |
106
+ | `130` | **INTERRUPTED** | Execution cancelled via SIGINT (Ctrl+C). |
107
+
108
+ ---
109
+
110
+ ## 5. Continuous Integration (CI/CD) Integration
111
+
112
+ ### GitHub Actions Workflow
113
+ Export SARIF 2.1.0 reports directly into the GitHub Repository **Security** tab:
114
+
115
+ ```yaml
116
+ name: n8n Workflow Security Scan
117
+
118
+ on:
119
+ push:
120
+ paths: ['**.json']
121
+ pull_request:
122
+
123
+ jobs:
124
+ scan:
125
+ runs-on: ubuntu-latest
126
+ steps:
127
+ - name: Checkout Code
128
+ uses: actions/checkout@v4
129
+
130
+ - name: Setup Node.js
131
+ uses: actions/setup-node@v4
132
+ with:
133
+ node-version: 22
134
+
135
+ - name: Install sfscanner
136
+ run: |
137
+ cd community-hub && npm ci && npm run build --workspace=sfscanner
138
+ npm link --workspace=sfscanner
139
+
140
+ - name: Run Scan
141
+ run: |
142
+ sfscanner scan ./workflows --format sarif > sfscanner.sarif
143
+
144
+ - name: Upload SARIF to GitHub Security Tab
145
+ uses: github/codeql-action/upload-sarif@v3
146
+ with:
147
+ sarif_file: sfscanner.sarif
148
+ ```
149
+
150
+ ---
151
+
152
+ ## 6. Native AI MCP Server (`sfscanner-mcp`)
153
+
154
+ `sfscanner` includes a production-ready, native **Model Context Protocol (MCP)** server (`dist/mcp.js`) running over standard I/O JSON-RPC 2.0. It gives AI coding assistants the power to audit n8n workflows before executing or importing them.
155
+
156
+ ```mermaid
157
+ graph LR
158
+ User["Developer / Operator"] --> Agent["AI Assistant (Claude / Cursor)"]
159
+ Agent -->|MCP stdio JSON-RPC| Server["sfscanner-mcp (dist/mcp.js)"]
160
+ Server -->|Static In-Memory Scan| Core["@hub/scanner-core Engine"]
161
+ Core -->|SARIF / JSON Finding| Server
162
+ Server -->|Diagnostic Report| Agent
163
+ Agent -->|Safe Workflow Advice| User
164
+ ```
165
+
166
+ ### Tool Definition
167
+ * **Tool Name:** `n8n_scan`
168
+ * **Description:** *"Scan local n8n workflow JSON with the admitted deterministic offline v2 profile."*
169
+ * **Parameters:**
170
+ * `inputs` (array of strings, required): Local workflow file paths.
171
+ * `format` (optional string): `'json' | 'ndjson' | 'sarif' | 'table'`.
172
+ * `failOn` (optional string): `'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW' | 'INFO'`.
173
+
174
+ ### Connecting to Claude Desktop
175
+ Add this entry to your `claude_desktop_config.json`:
176
+
177
+ ```json
178
+ {
179
+ "mcpServers": {
180
+ "sfscanner": {
181
+ "command": "node",
182
+ "args": [
183
+ "/absolute/path/to/n8n-community/community-hub/packages/scanner-cli/dist/mcp.js"
184
+ ]
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ ### Connecting to Cursor
191
+ Add this entry to your Cursor Settings (`.cursor/mcp.json`):
192
+
193
+ ```json
194
+ {
195
+ "mcpServers": {
196
+ "sfscanner": {
197
+ "command": "node",
198
+ "args": [
199
+ "d:/projects/n8n-community/community-hub/packages/scanner-cli/dist/mcp.js"
200
+ ]
201
+ }
202
+ }
203
+ }
204
+ ```
205
+
206
+ ### Example AI Prompting
207
+ Once configured, you can prompt your AI agent:
208
+ > *"Before we deploy this automation, use the `n8n_scan` tool to check `workflows/lead-sync.json` for prompt injection or leaked credentials."*
209
+
210
+ ---
211
+
212
+ ## 7. Licensing Terms
213
+
214
+ `sfscanner` code and scanner tooling are MIT-licensed; see [`LICENSE`](LICENSE). The aggregated workflow catalogue dataset (`data/`) has separate Personal / Non-Commercial terms and is not included in this package. See the [canonical licensing policy](https://github.com/jitwark/n8n-Secureflow/blob/main/docs/LICENSING.md).
@@ -0,0 +1,48 @@
1
+ # Third-party notices
2
+
3
+ This package ships a built CLI bundle plus its own documentation. The package's own code is licensed
4
+ under [`LICENSE`](LICENSE) (MIT). No workflow corpus, private repository data, or runtime network
5
+ client is included in this package.
6
+
7
+ The classification below is derived from the packed artifact, not from declared intent: a module
8
+ counts as shipped only when the bundle's shipped `dist/*.js.map` sources name it. The same split is
9
+ machine-readable in `outputs/distribution/scanner-sbom.cyclonedx.json`
10
+ (`scope` plus the `sfscanner:observed-in-packed-artifact` property).
11
+
12
+ ## Inlined in the packed bundle
13
+
14
+ | Component | Version | License |
15
+ | --- | --- | --- |
16
+ | `@humanwhocodes/momoa` | 3.3.10 | Apache-2.0 |
17
+ | `@noble/hashes` | 2.3.0 | MIT |
18
+ | `@hub/contracts` | 0.1.0 | MIT — this project's workspace package |
19
+ | `@hub/scanner-core` | 0.1.0 | MIT — this project's workspace package |
20
+
21
+ `@hub/contracts` and `@hub/scanner-core` are this project's own MIT-licensed workspace packages. Their
22
+ code is compiled into `dist/main.js` and `dist/mcp.js`; they are not runtime package dependencies.
23
+
24
+ ## Declared runtime dependencies this build does not ship
25
+
26
+ These packages are installed as runtime dependencies of `@hub/scanner-core` and are imported by its
27
+ optional code-analysis modules, but they are unreachable from this CLI's admitted profile
28
+ (`beta-default` only, `packages/scanner-cli/src/v2/commands.ts`), so they are tree-shaken out of the
29
+ packed bundle. They are listed because their absence is a verified property of this artifact: the
30
+ string `acorn` / `@lezer` occurs zero times anywhere under `packages/scanner-cli/dist`, and the
31
+ shipped source maps name none of their modules.
32
+
33
+ | Component | Version | License |
34
+ | --- | --- | --- |
35
+ | `acorn` | 8.17.0 | MIT |
36
+ | `@lezer/common` | 1.5.2 | MIT |
37
+ | `@lezer/highlight` | 1.2.3 | MIT |
38
+ | `@lezer/lr` | 1.4.10 | MIT |
39
+ | `@lezer/python` | 1.1.19 | MIT |
40
+
41
+ The scanner package's build/test-only tooling (`esbuild`, `typescript`, `vitest`, `@types/node` and
42
+ their transitive dependencies) is likewise absent from the packed artifact and carries no notice
43
+ obligation for it.
44
+
45
+ This is a prepared dependency inventory, not a claim that the release's notice obligations are
46
+ complete. A release owner must reconcile these versions against the exact lockfile, attach the
47
+ verbatim upstream license texts, and complete the legal review (`PENDING_OWNER`). This package is
48
+ published on npm as `sfscanner`.