sfscanner 0.0.0-stage → 0.2.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +131 -3
  3. package/THIRD_PARTY_NOTICES.md +48 -0
  4. package/dist/index.d.ts +4 -0
  5. package/dist/index.js +10766 -0
  6. package/dist/index.js.map +7 -0
  7. package/dist/main.js +11941 -0
  8. package/dist/main.js.map +7 -0
  9. package/dist/mcp.js +10468 -0
  10. package/dist/mcp.js.map +7 -0
  11. package/dist/scan-worker.js +11800 -0
  12. package/dist/scan-worker.js.map +7 -0
  13. package/dist/v2/arguments.d.ts +87 -0
  14. package/dist/v2/arguments.js +403 -0
  15. package/dist/v2/arguments.js.map +7 -0
  16. package/dist/v2/atomic-output.d.ts +34 -0
  17. package/dist/v2/batch-runner.d.ts +50 -0
  18. package/dist/v2/cli-runner-internal.d.ts +28 -0
  19. package/dist/v2/cli-runner.d.ts +22 -0
  20. package/dist/v2/cli-runner.js +10037 -0
  21. package/dist/v2/cli-runner.js.map +7 -0
  22. package/dist/v2/commands.d.ts +155 -0
  23. package/dist/v2/config.d.ts +16 -0
  24. package/dist/v2/contracts.d.ts +97 -0
  25. package/dist/v2/exit-reducer.d.ts +23 -0
  26. package/dist/v2/help.d.ts +33 -0
  27. package/dist/v2/help.js +325 -0
  28. package/dist/v2/help.js.map +7 -0
  29. package/dist/v2/input-read.d.ts +26 -0
  30. package/dist/v2/input-selection.d.ts +38 -0
  31. package/dist/v2/json-output.d.ts +97 -0
  32. package/dist/v2/metadata-output.d.ts +37 -0
  33. package/dist/v2/metadata-output.js +7523 -0
  34. package/dist/v2/metadata-output.js.map +7 -0
  35. package/dist/v2/metadata-validation.d.ts +4 -0
  36. package/dist/v2/ndjson-output.d.ts +3 -0
  37. package/dist/v2/path-admission.d.ts +8 -0
  38. package/dist/v2/scan-config-load.d.ts +21 -0
  39. package/dist/v2/scan-worker-host.d.ts +29 -0
  40. package/dist/v2/table-output.d.ts +2 -0
  41. package/dist/v2/worker-host.d.ts +24 -0
  42. package/package.json +74 -6
@@ -0,0 +1,4 @@
1
+ import type { CliMetadataDocumentV2 } from './commands.js';
2
+ export declare function checkPlain(o: unknown): Record<string, unknown>;
3
+ export declare function checkDenseArray<T>(arr: unknown): T[];
4
+ export declare function validateDocumentShape(doc: unknown): asserts doc is CliMetadataDocumentV2;
@@ -0,0 +1,3 @@
1
+ import type { BatchResultV2 } from './batch-runner';
2
+ import { type ProjectionOptionsV2 } from './json-output';
3
+ export declare function serializeNdjsonV2(batch: BatchResultV2, options?: ProjectionOptionsV2): string;
@@ -0,0 +1,8 @@
1
+ /** Normalizes backslashes before classifying, so a Windows drive path is absolute in both forms. */
2
+ export declare function isAbsoluteAdmittedPathV2(value: string): boolean;
3
+ export declare function isAdmittedLocalPath(value: unknown): value is string;
4
+ export declare function isAdmittedRelativePath(value: unknown): value is string;
5
+ export declare function normalizeAdmittedPathV2(value: unknown, relativeOnly?: boolean): string | undefined;
6
+ export declare function admittedLabelV2(raw: string, baseDirectory: string): string;
7
+ export declare function toFsPathV2(baseDirectory: string, normalized: string): string;
8
+ export declare function isWithinBaseV2(target: string, baseDirectory: string): boolean;
@@ -0,0 +1,21 @@
1
+ import { type ScannerLimitsV2 } from '@hub/contracts';
2
+ import type { CliCommandV2 } from './arguments';
3
+ import { type ScanConfigV2 } from './config';
4
+ import type { ProjectionSourceV2 } from './json-output';
5
+ import type { ExitCodeV2 } from './exit-reducer';
6
+ type ScanCommand = Extract<CliCommandV2, {
7
+ kind: 'scan';
8
+ }>;
9
+ export type LoadedScanConfig = Readonly<{
10
+ ok: true;
11
+ config: ScanConfigV2;
12
+ limitsDocument?: ScannerLimitsV2;
13
+ targetDocument?: unknown;
14
+ sources: ProjectionSourceV2;
15
+ }> | Readonly<{
16
+ ok: false;
17
+ exitCode: ExitCodeV2;
18
+ message: string;
19
+ }>;
20
+ export declare function readScanConfig(command: ScanCommand, baseDirectory: string): Promise<LoadedScanConfig>;
21
+ export {};
@@ -0,0 +1,29 @@
1
+ import { Worker } from 'node:worker_threads';
2
+ import type { WorkerHostRun } from './worker-host';
3
+ export type ScanWorkerData = Readonly<{
4
+ bytes: Uint8Array;
5
+ profile: Readonly<{
6
+ id: string;
7
+ version: string;
8
+ }>;
9
+ target?: unknown;
10
+ limits?: unknown;
11
+ approvedDomains?: readonly string[];
12
+ }>;
13
+ export type ScanWorkerFactory = () => Worker;
14
+ export type ScanWorkerOptions = Readonly<{
15
+ timeoutMs?: number;
16
+ signal?: AbortSignal;
17
+ workerFactory?: ScanWorkerFactory;
18
+ }>;
19
+ /**
20
+ * `#sfscanner-worker` is the package's private imports map to the one built
21
+ * `dist/scan-worker.js`. `createRequire(...).resolve` uses the same native
22
+ * package-imports resolution as `import.meta.resolve` (unavailable in
23
+ * vite-node) and checks the target exists, so the same call works from the
24
+ * root bundle, the v2 subpath bundle, and the unbundled source tree after one
25
+ * build. A missing asset throws MODULE_NOT_FOUND; there is no fallback.
26
+ */
27
+ export declare function scanWorkerUrl(): URL;
28
+ export declare function createScanWorker(data: ScanWorkerData): Worker;
29
+ export declare function runScanInWorker<T = unknown>(data: ScanWorkerData, options?: ScanWorkerOptions): Promise<WorkerHostRun<T>>;
@@ -0,0 +1,2 @@
1
+ import type { BatchResultV2 } from './batch-runner';
2
+ export declare function renderTableV2(batch: BatchResultV2): string;
@@ -0,0 +1,24 @@
1
+ export type WorkerHostStatus = 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'TIMEOUT';
2
+ export type WorkerHostRun<T> = Readonly<{
3
+ status: 'COMPLETED';
4
+ value: T;
5
+ } | {
6
+ status: Exclude<WorkerHostStatus, 'COMPLETED'>;
7
+ }>;
8
+ export type SigintSource = Readonly<{
9
+ on: (event: 'SIGINT', listener: () => void) => unknown;
10
+ off?: (event: 'SIGINT', listener: () => void) => unknown;
11
+ removeListener?: (event: 'SIGINT', listener: () => void) => unknown;
12
+ }>;
13
+ export type SigintController = Readonly<{
14
+ signal: AbortSignal;
15
+ dispose: () => void;
16
+ }>;
17
+ export type WorkerHostOptions = Readonly<{
18
+ signal?: AbortSignal;
19
+ sigint?: SigintSource;
20
+ timeoutMs?: number;
21
+ now?: () => number;
22
+ }>;
23
+ export declare function createSigintController(source?: SigintSource): SigintController;
24
+ export declare function runHostedScan<T>(task: () => T | PromiseLike<T>, options?: WorkerHostOptions): Promise<WorkerHostRun<T>>;
package/package.json CHANGED
@@ -1,6 +1,74 @@
1
- {
2
- "name": "sfscanner",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "sfscanner",
3
+ "version": "0.2.0",
4
+ "description": "SecureFlow Scanner — Deterministic, offline security & dataflow analyzer for n8n workflows",
5
+ "keywords": [
6
+ "n8n",
7
+ "security",
8
+ "sast",
9
+ "sarif",
10
+ "scanner",
11
+ "workflow"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/jitwark/n8n-Secureflow.git"
16
+ },
17
+ "homepage": "https://github.com/jitwark/n8n-Secureflow#readme",
18
+ "license": "MIT",
19
+ "private": false,
20
+ "type": "module",
21
+ "engines": {
22
+ "node": ">=22 <23"
23
+ },
24
+ "main": "./dist/index.js",
25
+ "bin": {
26
+ "sfscanner": "dist/main.js",
27
+ "sfscanner-mcp": "dist/mcp.js"
28
+ },
29
+ "imports": {
30
+ "#sfscanner-worker": "./dist/scan-worker.js"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md",
35
+ "LICENSE",
36
+ "THIRD_PARTY_NOTICES.md"
37
+ ],
38
+ "exports": {
39
+ ".": {
40
+ "types": "./dist/index.d.ts",
41
+ "import": "./dist/index.js"
42
+ },
43
+ "./v2/arguments": {
44
+ "types": "./dist/v2/arguments.d.ts",
45
+ "import": "./dist/v2/arguments.js"
46
+ },
47
+ "./v2/cli-runner": {
48
+ "types": "./dist/v2/cli-runner.d.ts",
49
+ "import": "./dist/v2/cli-runner.js"
50
+ },
51
+ "./v2/help": {
52
+ "types": "./dist/v2/help.d.ts",
53
+ "import": "./dist/v2/help.js"
54
+ },
55
+ "./v2/metadata-output": {
56
+ "types": "./dist/v2/metadata-output.d.ts",
57
+ "import": "./dist/v2/metadata-output.js"
58
+ }
59
+ },
60
+ "scripts": {
61
+ "build": "node build.mjs",
62
+ "lint": "eslint .",
63
+ "test": "vitest run --config vitest.config.ts",
64
+ "typecheck": "tsc -p tsconfig.json --noEmit"
65
+ },
66
+ "devDependencies": {
67
+ "@hub/contracts": "*",
68
+ "@hub/scanner-core": "*",
69
+ "@types/node": "^22.0.0",
70
+ "esbuild": "^0.28.2",
71
+ "typescript": "^5.7.2",
72
+ "vitest": "^4.1.11"
73
+ }
74
+ }