@zivis/cli 0.1.0-alpha.5 → 0.1.0-alpha.52
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 +201 -0
- package/README.md +31 -0
- package/dist/commands/app/index.d.ts +0 -8
- package/dist/commands/app/index.js +8 -18
- package/dist/commands/assurance/index.d.ts +35 -0
- package/dist/commands/assurance/index.js +154 -0
- package/dist/commands/auth/bind.d.ts +4 -0
- package/dist/commands/auth/bind.js +97 -0
- package/dist/commands/auth/index.js +21 -2
- package/dist/commands/auth/init.d.ts +2 -0
- package/dist/commands/auth/init.js +248 -96
- package/dist/commands/auth/login.d.ts +2 -0
- package/dist/commands/auth/login.js +136 -18
- package/dist/commands/auth/logout.js +19 -7
- package/dist/commands/auth/sessions.js +7 -4
- package/dist/commands/auth/status.js +33 -12
- package/dist/commands/auth/token.d.ts +4 -0
- package/dist/commands/auth/token.js +73 -0
- package/dist/commands/check/index.d.ts +2 -0
- package/dist/commands/check/index.js +463 -0
- package/dist/commands/credits/index.js +2 -3
- package/dist/commands/gate/index.d.ts +2 -0
- package/dist/commands/gate/index.js +171 -0
- package/dist/commands/inspect/index.d.ts +2 -0
- package/dist/commands/inspect/index.js +136 -0
- package/dist/commands/mcp/index.js +113 -14
- package/dist/commands/open/index.d.ts +0 -8
- package/dist/commands/open/index.js +0 -11
- package/dist/commands/run/index.d.ts +2 -0
- package/dist/commands/run/index.js +206 -0
- package/dist/commands/scan/index.js +3 -8
- package/dist/commands/share/index.d.ts +14 -0
- package/dist/commands/share/index.js +100 -0
- package/dist/commands/sync/index.d.ts +2 -0
- package/dist/commands/sync/index.js +193 -0
- package/dist/commands/target/index.js +0 -3
- package/dist/commands/test/index.d.ts +2 -0
- package/dist/commands/test/index.js +198 -0
- package/dist/commands/threatmodel/index.d.ts +2 -0
- package/dist/commands/threatmodel/index.js +167 -0
- package/dist/index.js +28 -3
- package/dist/internal/application-binding.d.ts +8 -0
- package/dist/internal/application-binding.js +167 -0
- package/dist/internal/binding-token-mint.d.ts +33 -0
- package/dist/internal/binding-token-mint.js +174 -0
- package/dist/internal/change-recommendation.d.ts +6 -0
- package/dist/internal/change-recommendation.js +113 -0
- package/dist/internal/cli-output.d.ts +16 -0
- package/dist/internal/cli-output.js +39 -0
- package/dist/internal/devx-run.d.ts +129 -0
- package/dist/internal/devx-run.js +39 -0
- package/dist/internal/extractor/adapters/go/index.d.ts +0 -4
- package/dist/internal/extractor/adapters/go/index.js +0 -6
- package/dist/internal/extractor/adapters/go/manifest.d.ts +0 -17
- package/dist/internal/extractor/adapters/go/manifest.js +19 -25
- package/dist/internal/extractor/adapters/go/parser.d.ts +0 -4
- package/dist/internal/extractor/adapters/go/parser.js +0 -5
- package/dist/internal/extractor/adapters/go/scanner.d.ts +0 -20
- package/dist/internal/extractor/adapters/go/scanner.js +0 -43
- package/dist/internal/extractor/adapters/python/index.d.ts +0 -3
- package/dist/internal/extractor/adapters/python/index.js +0 -4
- package/dist/internal/extractor/adapters/python/manifest.d.ts +0 -8
- package/dist/internal/extractor/adapters/python/manifest.js +21 -18
- package/dist/internal/extractor/adapters/python/parser.d.ts +0 -3
- package/dist/internal/extractor/adapters/python/parser.js +0 -4
- package/dist/internal/extractor/adapters/python/scanner.d.ts +0 -18
- package/dist/internal/extractor/adapters/python/scanner.js +1 -54
- package/dist/internal/extractor/adapters/typescript/index.d.ts +0 -7
- package/dist/internal/extractor/adapters/typescript/index.js +1 -21
- package/dist/internal/extractor/adapters/typescript/manifest.d.ts +0 -14
- package/dist/internal/extractor/adapters/typescript/manifest.js +26 -17
- package/dist/internal/extractor/adapters/typescript/parser.d.ts +0 -8
- package/dist/internal/extractor/adapters/typescript/parser.js +0 -9
- package/dist/internal/extractor/adapters/typescript/scanner.d.ts +0 -24
- package/dist/internal/extractor/adapters/typescript/scanner.js +0 -43
- package/dist/internal/extractor/graph-builder.d.ts +10 -0
- package/dist/internal/extractor/graph-builder.js +245 -0
- package/dist/internal/extractor/graph-types.d.ts +89 -0
- package/dist/internal/extractor/graph-types.js +1 -0
- package/dist/internal/extractor/index.d.ts +0 -14
- package/dist/internal/extractor/index.js +0 -13
- package/dist/internal/extractor/types.d.ts +0 -45
- package/dist/internal/extractor/types.js +0 -27
- package/dist/internal/extractor/walker.d.ts +0 -18
- package/dist/internal/extractor/walker.js +0 -18
- package/dist/internal/gate-evaluate.d.ts +50 -0
- package/dist/internal/gate-evaluate.js +111 -0
- package/dist/internal/gate-policy.d.ts +38 -0
- package/dist/internal/gate-policy.js +167 -0
- package/dist/internal/git-metadata.d.ts +8 -0
- package/dist/internal/git-metadata.js +38 -0
- package/dist/internal/git.d.ts +9 -0
- package/dist/internal/git.js +45 -0
- package/dist/internal/github-linkage-prompt.d.ts +7 -0
- package/dist/internal/github-linkage-prompt.js +95 -0
- package/dist/internal/ide-setup.d.ts +17 -7
- package/dist/internal/ide-setup.js +379 -46
- package/dist/internal/inventory-sync.d.ts +74 -0
- package/dist/internal/inventory-sync.js +189 -0
- package/dist/internal/org-picker.d.ts +11 -0
- package/dist/internal/org-picker.js +34 -0
- package/dist/internal/orgs.js +0 -1
- package/dist/internal/packs/cache.d.ts +8 -0
- package/dist/internal/packs/cache.js +60 -0
- package/dist/internal/packs/index.d.ts +10 -0
- package/dist/internal/packs/index.js +8 -0
- package/dist/internal/packs/integrity.d.ts +9 -0
- package/dist/internal/packs/integrity.js +24 -0
- package/dist/internal/packs/jcs.d.ts +2 -0
- package/dist/internal/packs/jcs.js +57 -0
- package/dist/internal/packs/local-paths.d.ts +4 -0
- package/dist/internal/packs/local-paths.js +26 -0
- package/dist/internal/packs/npm-registry-client.d.ts +14 -0
- package/dist/internal/packs/npm-registry-client.js +87 -0
- package/dist/internal/packs/registry-client.d.ts +9 -0
- package/dist/internal/packs/registry-client.js +25 -0
- package/dist/internal/packs/resolve.d.ts +8 -0
- package/dist/internal/packs/resolve.js +89 -0
- package/dist/internal/packs/semver.d.ts +9 -0
- package/dist/internal/packs/semver.js +57 -0
- package/dist/internal/packs/signing.d.ts +5 -0
- package/dist/internal/packs/signing.js +56 -0
- package/dist/internal/packs/types.d.ts +77 -0
- package/dist/internal/packs/types.js +20 -0
- package/dist/internal/project-binding.d.ts +1 -0
- package/dist/internal/project-binding.js +16 -11
- package/dist/internal/resolve-init-session.d.ts +8 -0
- package/dist/internal/resolve-init-session.js +36 -0
- package/dist/internal/run-workdir.d.ts +2 -0
- package/dist/internal/run-workdir.js +19 -0
- package/dist/internal/security-context.d.ts +63 -0
- package/dist/internal/security-context.js +50 -0
- package/dist/internal/sync-outbox.d.ts +40 -0
- package/dist/internal/sync-outbox.js +66 -0
- package/dist/internal/target-auth/api-config.d.ts +0 -17
- package/dist/internal/target-auth/api-config.js +0 -18
- package/dist/internal/target-auth/config.d.ts +0 -12
- package/dist/internal/target-auth/config.js +0 -13
- package/dist/internal/target-auth/index.d.ts +0 -18
- package/dist/internal/target-auth/index.js +0 -19
- package/dist/internal/target-auth/keychain.d.ts +0 -18
- package/dist/internal/target-auth/keychain.js +3 -23
- package/dist/internal/target-auth/types.d.ts +0 -26
- package/dist/internal/target-auth/types.js +0 -10
- package/dist/internal/target-auth/workos.d.ts +0 -15
- package/dist/internal/target-auth/workos.js +9 -18
- package/dist/internal/test-scope.d.ts +99 -0
- package/dist/internal/test-scope.js +101 -0
- package/dist/internal/threatmodel-run-state.d.ts +15 -0
- package/dist/internal/threatmodel-run-state.js +43 -0
- package/dist/internal/threatmodel-run.d.ts +85 -0
- package/dist/internal/threatmodel-run.js +159 -0
- package/dist/internal/trust-room-link.d.ts +10 -0
- package/dist/internal/trust-room-link.js +15 -0
- package/dist/internal/zivis-local-state.d.ts +1 -0
- package/dist/internal/zivis-local-state.js +22 -0
- package/package.json +21 -5
- package/dist/commands/app/index.js.map +0 -1
- package/dist/commands/auth/index.js.map +0 -1
- package/dist/commands/auth/init.js.map +0 -1
- package/dist/commands/auth/login.js.map +0 -1
- package/dist/commands/auth/logout.js.map +0 -1
- package/dist/commands/auth/sessions.js.map +0 -1
- package/dist/commands/auth/status.js.map +0 -1
- package/dist/commands/credits/index.js.map +0 -1
- package/dist/commands/mcp/index.js.map +0 -1
- package/dist/commands/open/index.js.map +0 -1
- package/dist/commands/scan/index.js.map +0 -1
- package/dist/commands/target/index.js.map +0 -1
- package/dist/commands/tm/index.d.ts +0 -2
- package/dist/commands/tm/index.js +0 -266
- package/dist/commands/tm/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/extractor/adapters/go/index.js.map +0 -1
- package/dist/internal/extractor/adapters/go/manifest.js.map +0 -1
- package/dist/internal/extractor/adapters/go/parser.js.map +0 -1
- package/dist/internal/extractor/adapters/go/scanner.js.map +0 -1
- package/dist/internal/extractor/adapters/python/index.js.map +0 -1
- package/dist/internal/extractor/adapters/python/manifest.js.map +0 -1
- package/dist/internal/extractor/adapters/python/parser.js.map +0 -1
- package/dist/internal/extractor/adapters/python/scanner.js.map +0 -1
- package/dist/internal/extractor/adapters/typescript/index.js.map +0 -1
- package/dist/internal/extractor/adapters/typescript/manifest.js.map +0 -1
- package/dist/internal/extractor/adapters/typescript/parser.js.map +0 -1
- package/dist/internal/extractor/adapters/typescript/scanner.js.map +0 -1
- package/dist/internal/extractor/index.js.map +0 -1
- package/dist/internal/extractor/types.js.map +0 -1
- package/dist/internal/extractor/walker.js.map +0 -1
- package/dist/internal/ide-setup.js.map +0 -1
- package/dist/internal/orgs.js.map +0 -1
- package/dist/internal/project-binding.js.map +0 -1
- package/dist/internal/target-auth/api-config.js.map +0 -1
- package/dist/internal/target-auth/config.js.map +0 -1
- package/dist/internal/target-auth/index.js.map +0 -1
- package/dist/internal/target-auth/keychain.js.map +0 -1
- package/dist/internal/target-auth/types.js.map +0 -1
- package/dist/internal/target-auth/workos.js.map +0 -1
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tree-sitter-go loader. Lazy-init, reuses the same WASM directory as
|
|
3
|
-
* the TypeScript adapter (both come from @vscode/tree-sitter-wasm).
|
|
4
|
-
*/
|
|
5
1
|
import { createRequire } from "node:module";
|
|
6
2
|
import * as path from "node:path";
|
|
7
3
|
import { Parser, Language } from "web-tree-sitter";
|
|
@@ -20,4 +16,3 @@ export function getGoParser() {
|
|
|
20
16
|
}
|
|
21
17
|
return parserPromise;
|
|
22
18
|
}
|
|
23
|
-
//# sourceMappingURL=parser.js.map
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AST scanner for Go source files.
|
|
3
|
-
*
|
|
4
|
-
* Walks tree-sitter-go for two things:
|
|
5
|
-
*
|
|
6
|
-
* 1. import declarations naming any tracked module (AI SDKs, web
|
|
7
|
-
* frameworks, DB clients) → ImportEvidence
|
|
8
|
-
* 2. HTTP route calls. Three flavors:
|
|
9
|
-
* net/http : http.HandleFunc("/path", h)
|
|
10
|
-
* chi : r.Get("/path", h), r.Post(…) (TitleCase)
|
|
11
|
-
* echo/gin : e.GET("/path", h), r.POST(…) (UPPER)
|
|
12
|
-
* fiber : app.Get("/path", h), app.Post(…) (TitleCase)
|
|
13
|
-
*
|
|
14
|
-
* Method-name normalization happens after we identify the call-shape;
|
|
15
|
-
* output is always UPPERCASE in the JSON.
|
|
16
|
-
*
|
|
17
|
-
* Privacy invariant: same as the TS adapter — only identifier names,
|
|
18
|
-
* file paths, line numbers, package paths, and route method/path strings.
|
|
19
|
-
* Function bodies are never read.
|
|
20
|
-
*/
|
|
21
1
|
import type { EvidenceLocation, Evidence, HttpRouteEvidence, ImportEvidence } from "../../types.js";
|
|
22
2
|
export interface FileScanResult {
|
|
23
3
|
file: string;
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AST scanner for Go source files.
|
|
3
|
-
*
|
|
4
|
-
* Walks tree-sitter-go for two things:
|
|
5
|
-
*
|
|
6
|
-
* 1. import declarations naming any tracked module (AI SDKs, web
|
|
7
|
-
* frameworks, DB clients) → ImportEvidence
|
|
8
|
-
* 2. HTTP route calls. Three flavors:
|
|
9
|
-
* net/http : http.HandleFunc("/path", h)
|
|
10
|
-
* chi : r.Get("/path", h), r.Post(…) (TitleCase)
|
|
11
|
-
* echo/gin : e.GET("/path", h), r.POST(…) (UPPER)
|
|
12
|
-
* fiber : app.Get("/path", h), app.Post(…) (TitleCase)
|
|
13
|
-
*
|
|
14
|
-
* Method-name normalization happens after we identify the call-shape;
|
|
15
|
-
* output is always UPPERCASE in the JSON.
|
|
16
|
-
*
|
|
17
|
-
* Privacy invariant: same as the TS adapter — only identifier names,
|
|
18
|
-
* file paths, line numbers, package paths, and route method/path strings.
|
|
19
|
-
* Function bodies are never read.
|
|
20
|
-
*/
|
|
21
1
|
import * as fs from "node:fs/promises";
|
|
22
2
|
import { getGoParser } from "./parser.js";
|
|
23
3
|
import { AI_SDK_MODULES, DATA_STORE_MODULES, WEB_FRAMEWORK_MODULES, STDLIB_FRAMEWORKS, } from "./manifest.js";
|
|
@@ -74,64 +54,45 @@ function walk(node, visit) {
|
|
|
74
54
|
walk(child, visit);
|
|
75
55
|
}
|
|
76
56
|
}
|
|
77
|
-
/** Pull the quoted module path out of an import_spec node. */
|
|
78
57
|
function extractImportPath(node) {
|
|
79
|
-
// import_spec → optional package_identifier + interpreted_string_literal
|
|
80
58
|
const stringNode = node.namedChildren.find((c) => c?.type === "interpreted_string_literal");
|
|
81
59
|
if (!stringNode)
|
|
82
60
|
return null;
|
|
83
|
-
// text is the quoted form; strip the surrounding quotes.
|
|
84
61
|
const text = stringNode.text;
|
|
85
62
|
return text.length >= 2 ? text.slice(1, -1) : null;
|
|
86
63
|
}
|
|
87
64
|
function trackedModuleMatch(pkg) {
|
|
88
65
|
if (TRACKED_MODULES.has(pkg))
|
|
89
66
|
return pkg;
|
|
90
|
-
// Sub-package import — e.g., "github.com/jackc/pgx/v5/pgxpool"
|
|
91
67
|
for (const tracked of TRACKED_MODULES) {
|
|
92
68
|
if (pkg.startsWith(tracked + "/"))
|
|
93
69
|
return tracked;
|
|
94
70
|
}
|
|
95
71
|
return null;
|
|
96
72
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Match an HTTP-route call by inspecting the call-expression shape.
|
|
99
|
-
* Two AST patterns to handle:
|
|
100
|
-
* - selector_expression(operand=identifier, field=field_identifier) called with args
|
|
101
|
-
* ⇒ http.HandleFunc, app.Get, e.GET, r.Post …
|
|
102
|
-
* - identifier called with args (rare for routes; ignored)
|
|
103
|
-
*/
|
|
104
73
|
function extractRouteCall(node) {
|
|
105
|
-
// call_expression has: function (selector_expression | identifier) + argument_list
|
|
106
74
|
const fn = node.namedChildren.find((c) => c?.type === "selector_expression");
|
|
107
75
|
const args = node.namedChildren.find((c) => c?.type === "argument_list");
|
|
108
76
|
if (!fn || !args)
|
|
109
77
|
return null;
|
|
110
|
-
// selector_expression: operand (any) . field (field_identifier)
|
|
111
78
|
const operand = fn.namedChildren[0];
|
|
112
79
|
const field = fn.namedChildren.find((c) => c?.type === "field_identifier");
|
|
113
80
|
if (!operand || !field)
|
|
114
81
|
return null;
|
|
115
82
|
const operandText = operand.text;
|
|
116
83
|
const fieldName = field.text;
|
|
117
|
-
// Determine the HTTP method from the field name + operand shape.
|
|
118
84
|
let method = null;
|
|
119
85
|
if (HTTP_METHODS_UPPER.has(fieldName)) {
|
|
120
|
-
// echo/gin: e.GET, r.POST … — operand is a router-like local var
|
|
121
86
|
method = fieldName === "ANY" ? "ALL" : fieldName;
|
|
122
87
|
}
|
|
123
88
|
else if (HTTP_METHODS_TITLE.has(fieldName)) {
|
|
124
|
-
// chi/fiber: r.Get, app.Post …
|
|
125
89
|
method = fieldName.toUpperCase();
|
|
126
90
|
}
|
|
127
91
|
else if (STDLIB_HANDLER_FNS.has(fieldName) && operandText === "http") {
|
|
128
|
-
// net/http: http.HandleFunc("/x", h) / http.Handle("/x", h)
|
|
129
|
-
// We don't know the HTTP verb statically — emit "ALL".
|
|
130
92
|
method = "ALL";
|
|
131
93
|
}
|
|
132
94
|
if (!method)
|
|
133
95
|
return null;
|
|
134
|
-
// First arg = string literal route path.
|
|
135
96
|
const firstArg = args.namedChildren[0];
|
|
136
97
|
if (!firstArg)
|
|
137
98
|
return null;
|
|
@@ -150,7 +111,6 @@ export function aggregate(scans) {
|
|
|
150
111
|
if (s.routes.length === 0 && s.imports.length === 0)
|
|
151
112
|
continue;
|
|
152
113
|
for (const imp of s.imports) {
|
|
153
|
-
// Match against the FULL tracked module (allowing sub-paths).
|
|
154
114
|
const matched = matchTracked(imp.package);
|
|
155
115
|
if (!matched)
|
|
156
116
|
continue;
|
|
@@ -191,8 +151,6 @@ function matchTracked(pkg) {
|
|
|
191
151
|
}
|
|
192
152
|
function deriveComponentName(filePath) {
|
|
193
153
|
const segs = filePath.split("/");
|
|
194
|
-
// Go convention: cmd/foo/main.go → "foo"; internal/auth/handler.go → "auth"
|
|
195
|
-
// Use the deepest directory that isn't a stdlib-ish folder name.
|
|
196
154
|
const skipPrefixes = new Set(["cmd", "internal", "pkg", "src", "app"]);
|
|
197
155
|
const start = skipPrefixes.has(segs[0]) ? 1 : 0;
|
|
198
156
|
if (segs.length - start >= 2)
|
|
@@ -213,4 +171,3 @@ function detectFrameworkFromImports(imports) {
|
|
|
213
171
|
}
|
|
214
172
|
return undefined;
|
|
215
173
|
}
|
|
216
|
-
//# sourceMappingURL=scanner.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Python language adapter. Same shape as TS/Go.
|
|
3
|
-
*/
|
|
4
1
|
import * as path from "node:path";
|
|
5
2
|
import { readManifests, summarizeManifests, findExternalServices, findDataStores, detectFrameworkFromManifest, } from "./manifest.js";
|
|
6
3
|
import { scanFile, aggregate } from "./scanner.js";
|
|
@@ -65,4 +62,3 @@ function frameworkFromOwningManifest(sourceFile, manifests) {
|
|
|
65
62
|
.sort((a, b) => b.dir.length - a.dir.length);
|
|
66
63
|
return candidates[0] ? detectFrameworkFromManifest(candidates[0].m) : undefined;
|
|
67
64
|
}
|
|
68
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Python manifest analysis.
|
|
3
|
-
*
|
|
4
|
-
* Reads pyproject.toml (PEP 621 + Poetry sections) and requirements.txt.
|
|
5
|
-
* Other formats (Pipfile, setup.py) deferred — they're either rare in
|
|
6
|
-
* modern projects (setup.py) or layer on top of these two.
|
|
7
|
-
*/
|
|
8
1
|
import type { ExtractedExternalService, ExtractedDataStore, ManifestSummary } from "../../types.js";
|
|
9
2
|
export declare const WEB_FRAMEWORK_PACKAGES: Record<string, string>;
|
|
10
3
|
export declare const DATA_STORE_PACKAGES: Record<string, {
|
|
@@ -15,7 +8,6 @@ export declare const AI_SDK_PACKAGES: Record<string, string>;
|
|
|
15
8
|
export interface ParsedPyManifest {
|
|
16
9
|
filePath: string;
|
|
17
10
|
format: "pyproject.toml" | "requirements.txt";
|
|
18
|
-
/** package name → version specifier (verbatim, e.g. "^0.30.0", ">=2.0,<3"). */
|
|
19
11
|
deps: Record<string, string>;
|
|
20
12
|
}
|
|
21
13
|
export declare function readManifests(rootDir: string, manifestFiles: string[]): Promise<ParsedPyManifest[]>;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Python manifest analysis.
|
|
3
|
-
*
|
|
4
|
-
* Reads pyproject.toml (PEP 621 + Poetry sections) and requirements.txt.
|
|
5
|
-
* Other formats (Pipfile, setup.py) deferred — they're either rare in
|
|
6
|
-
* modern projects (setup.py) or layer on top of these two.
|
|
7
|
-
*/
|
|
8
1
|
import * as fs from "node:fs/promises";
|
|
9
2
|
import * as path from "node:path";
|
|
10
3
|
import TOML from "@iarna/toml";
|
|
@@ -20,7 +13,7 @@ export const WEB_FRAMEWORK_PACKAGES = {
|
|
|
20
13
|
quart: "quart",
|
|
21
14
|
};
|
|
22
15
|
export const DATA_STORE_PACKAGES = {
|
|
23
|
-
sqlalchemy: { kind: "postgres", client: "sqlalchemy" },
|
|
16
|
+
sqlalchemy: { kind: "postgres", client: "sqlalchemy" },
|
|
24
17
|
asyncpg: { kind: "postgres", client: "asyncpg" },
|
|
25
18
|
psycopg: { kind: "postgres", client: "psycopg" },
|
|
26
19
|
psycopg2: { kind: "postgres", client: "psycopg2" },
|
|
@@ -45,7 +38,7 @@ export const AI_SDK_PACKAGES = {
|
|
|
45
38
|
vertexai: "Vertex AI",
|
|
46
39
|
"google-generativeai": "Google Generative AI",
|
|
47
40
|
cohere: "Cohere",
|
|
48
|
-
"boto3": "AWS (boto3)",
|
|
41
|
+
"boto3": "AWS (boto3)",
|
|
49
42
|
};
|
|
50
43
|
export async function readManifests(rootDir, manifestFiles) {
|
|
51
44
|
const out = [];
|
|
@@ -61,7 +54,6 @@ export async function readManifests(rootDir, manifestFiles) {
|
|
|
61
54
|
}
|
|
62
55
|
}
|
|
63
56
|
catch {
|
|
64
|
-
// skip unreadable / unparsable
|
|
65
57
|
}
|
|
66
58
|
}
|
|
67
59
|
return out;
|
|
@@ -79,7 +71,6 @@ function parsePyproject(filePath, rootDir, raw) {
|
|
|
79
71
|
catch {
|
|
80
72
|
return result;
|
|
81
73
|
}
|
|
82
|
-
// PEP 621: project.dependencies = ["fastapi >=0.100", ...]
|
|
83
74
|
const projectDeps = parsed?.project?.dependencies;
|
|
84
75
|
if (Array.isArray(projectDeps)) {
|
|
85
76
|
for (const spec of projectDeps) {
|
|
@@ -90,7 +81,6 @@ function parsePyproject(filePath, rootDir, raw) {
|
|
|
90
81
|
result.deps[name] = version;
|
|
91
82
|
}
|
|
92
83
|
}
|
|
93
|
-
// PEP 621: optional-dependencies = { test = [...], dev = [...] }
|
|
94
84
|
const opt = parsed?.project?.["optional-dependencies"];
|
|
95
85
|
if (opt && typeof opt === "object") {
|
|
96
86
|
for (const groupSpec of Object.values(opt)) {
|
|
@@ -105,7 +95,6 @@ function parsePyproject(filePath, rootDir, raw) {
|
|
|
105
95
|
}
|
|
106
96
|
}
|
|
107
97
|
}
|
|
108
|
-
// Poetry: tool.poetry.dependencies = { fastapi = "^0.100" } (also dev-dependencies)
|
|
109
98
|
const poetryDeps = parsed?.tool?.poetry?.dependencies;
|
|
110
99
|
if (poetryDeps && typeof poetryDeps === "object") {
|
|
111
100
|
for (const [name, value] of Object.entries(poetryDeps)) {
|
|
@@ -137,8 +126,7 @@ function parseRequirementsTxt(filePath, rootDir, raw) {
|
|
|
137
126
|
if (!line || line.startsWith("#"))
|
|
138
127
|
continue;
|
|
139
128
|
if (line.startsWith("-"))
|
|
140
|
-
continue;
|
|
141
|
-
// strip inline comments
|
|
129
|
+
continue;
|
|
142
130
|
const hashAt = line.indexOf(" #");
|
|
143
131
|
if (hashAt > 0)
|
|
144
132
|
line = line.slice(0, hashAt).trim();
|
|
@@ -148,9 +136,7 @@ function parseRequirementsTxt(filePath, rootDir, raw) {
|
|
|
148
136
|
}
|
|
149
137
|
return result;
|
|
150
138
|
}
|
|
151
|
-
/** "fastapi>=0.100,<0.110" → ["fastapi", ">=0.100,<0.110"] */
|
|
152
139
|
function splitPep508(spec) {
|
|
153
|
-
// strip extras like fastapi[all]
|
|
154
140
|
const cleaned = spec.replace(/\[[^\]]*\]/g, "").trim();
|
|
155
141
|
const m = cleaned.match(/^([A-Za-z0-9_.\-]+)\s*(.*)$/);
|
|
156
142
|
if (!m)
|
|
@@ -185,6 +171,24 @@ export function findExternalServices(parsed) {
|
|
|
185
171
|
callSites: [{ file: m.filePath, line: 1 }],
|
|
186
172
|
});
|
|
187
173
|
}
|
|
174
|
+
for (const [pkg, vendor] of Object.entries(WEB_FRAMEWORK_PACKAGES)) {
|
|
175
|
+
const ver = m.deps[pkg];
|
|
176
|
+
if (!ver)
|
|
177
|
+
continue;
|
|
178
|
+
const key = `web_framework::${pkg}`;
|
|
179
|
+
const existing = seen.get(key);
|
|
180
|
+
if (existing) {
|
|
181
|
+
existing.callSites.push({ file: m.filePath, line: 1 });
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
seen.set(key, {
|
|
185
|
+
name: vendor,
|
|
186
|
+
kind: "web_framework",
|
|
187
|
+
package: pkg,
|
|
188
|
+
version: ver,
|
|
189
|
+
callSites: [{ file: m.filePath, line: 1 }],
|
|
190
|
+
});
|
|
191
|
+
}
|
|
188
192
|
}
|
|
189
193
|
return [...seen.values()];
|
|
190
194
|
}
|
|
@@ -233,4 +237,3 @@ function relPosix(rootDir, abs) {
|
|
|
233
237
|
const rel = path.relative(rootDir, abs);
|
|
234
238
|
return rel.split(path.sep).join("/");
|
|
235
239
|
}
|
|
236
|
-
//# sourceMappingURL=manifest.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tree-sitter-python loader.
|
|
3
|
-
*/
|
|
4
1
|
import { createRequire } from "node:module";
|
|
5
2
|
import * as path from "node:path";
|
|
6
3
|
import { Parser, Language } from "web-tree-sitter";
|
|
@@ -19,4 +16,3 @@ export function getPythonParser() {
|
|
|
19
16
|
}
|
|
20
17
|
return parserPromise;
|
|
21
18
|
}
|
|
22
|
-
//# sourceMappingURL=parser.js.map
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AST scanner for Python source files.
|
|
3
|
-
*
|
|
4
|
-
* Patterns covered:
|
|
5
|
-
* 1. import_statement / import_from_statement → tracked-package imports
|
|
6
|
-
* (AI SDKs, web frameworks, DB clients).
|
|
7
|
-
* 2. Decorator-based routes (FastAPI, Flask):
|
|
8
|
-
* @app.get("/path") → method=GET
|
|
9
|
-
* @app.post("/path") → method=POST
|
|
10
|
-
* @app.route("/path", …) → method=ALL (Flask default; verbs in `methods=` kw not parsed yet)
|
|
11
|
-
* @router.get("/x", …) → method=GET (FastAPI APIRouter convention)
|
|
12
|
-
* 3. Django urls.py-style call: path("/route", view, …) / re_path(…) → method=ALL
|
|
13
|
-
* 4. aiohttp: app.router.add_get("/path", h) / add_post(…) / etc.
|
|
14
|
-
*
|
|
15
|
-
* Privacy invariant: identifier names + dotted attribute names + string
|
|
16
|
-
* literals on routes only. Function bodies and decorator args beyond the
|
|
17
|
-
* route path are never inspected.
|
|
18
|
-
*/
|
|
19
1
|
import type { EvidenceLocation, Evidence, HttpRouteEvidence, ImportEvidence } from "../../types.js";
|
|
20
2
|
export interface FileScanResult {
|
|
21
3
|
file: string;
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AST scanner for Python source files.
|
|
3
|
-
*
|
|
4
|
-
* Patterns covered:
|
|
5
|
-
* 1. import_statement / import_from_statement → tracked-package imports
|
|
6
|
-
* (AI SDKs, web frameworks, DB clients).
|
|
7
|
-
* 2. Decorator-based routes (FastAPI, Flask):
|
|
8
|
-
* @app.get("/path") → method=GET
|
|
9
|
-
* @app.post("/path") → method=POST
|
|
10
|
-
* @app.route("/path", …) → method=ALL (Flask default; verbs in `methods=` kw not parsed yet)
|
|
11
|
-
* @router.get("/x", …) → method=GET (FastAPI APIRouter convention)
|
|
12
|
-
* 3. Django urls.py-style call: path("/route", view, …) / re_path(…) → method=ALL
|
|
13
|
-
* 4. aiohttp: app.router.add_get("/path", h) / add_post(…) / etc.
|
|
14
|
-
*
|
|
15
|
-
* Privacy invariant: identifier names + dotted attribute names + string
|
|
16
|
-
* literals on routes only. Function bodies and decorator args beyond the
|
|
17
|
-
* route path are never inspected.
|
|
18
|
-
*/
|
|
19
1
|
import * as fs from "node:fs/promises";
|
|
20
2
|
import { getPythonParser } from "./parser.js";
|
|
21
3
|
import { AI_SDK_PACKAGES, DATA_STORE_PACKAGES, WEB_FRAMEWORK_PACKAGES, } from "./manifest.js";
|
|
@@ -87,22 +69,9 @@ function walk(node, visit) {
|
|
|
87
69
|
walk(child, visit);
|
|
88
70
|
}
|
|
89
71
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Pull the top-level package(s) out of an import statement.
|
|
92
|
-
*
|
|
93
|
-
* - `import anthropic` → ["anthropic"]
|
|
94
|
-
* - `import langchain.chat_models` → ["langchain"] (we track the root)
|
|
95
|
-
* - `from fastapi import FastAPI` → ["fastapi"]
|
|
96
|
-
* - `from langchain.schema import HumanMessage` → ["langchain"]
|
|
97
|
-
*
|
|
98
|
-
* Sub-modules collapse to the root because the manifest table is keyed
|
|
99
|
-
* by distribution name, which is also the import root for the packages
|
|
100
|
-
* we care about.
|
|
101
|
-
*/
|
|
102
72
|
function extractImportPackages(node) {
|
|
103
73
|
const out = [];
|
|
104
74
|
if (node.type === "import_from_statement") {
|
|
105
|
-
// import_from_statement → module_name as the "module" field
|
|
106
75
|
const moduleField = node.childForFieldName("module_name");
|
|
107
76
|
if (moduleField) {
|
|
108
77
|
const root = topLevelImportName(moduleField);
|
|
@@ -111,7 +80,6 @@ function extractImportPackages(node) {
|
|
|
111
80
|
}
|
|
112
81
|
return out;
|
|
113
82
|
}
|
|
114
|
-
// import_statement: one or more dotted_name (or aliased_import wrapping it)
|
|
115
83
|
for (const child of node.namedChildren) {
|
|
116
84
|
if (!child)
|
|
117
85
|
continue;
|
|
@@ -141,13 +109,7 @@ function topLevelImportName(node) {
|
|
|
141
109
|
function trackedPackageMatch(pkg) {
|
|
142
110
|
return TRACKED_PACKAGES.has(pkg) ? pkg : null;
|
|
143
111
|
}
|
|
144
|
-
/**
|
|
145
|
-
* Match @app.get("/path"), @router.post(…), @app.route("/x", …).
|
|
146
|
-
* Returns the route + method, or null if it isn't a known shape.
|
|
147
|
-
*/
|
|
148
112
|
function extractDecoratorRoute(node) {
|
|
149
|
-
// decorator → `@` + (call | attribute | identifier)
|
|
150
|
-
// We only care about call shapes: @app.get("/path", …)
|
|
151
113
|
const callNode = node.namedChildren.find((c) => c?.type === "call");
|
|
152
114
|
if (!callNode)
|
|
153
115
|
return null;
|
|
@@ -163,37 +125,28 @@ function extractDecoratorRoute(node) {
|
|
|
163
125
|
return null;
|
|
164
126
|
const objectName = objectNode.text.toLowerCase();
|
|
165
127
|
const attrName = attrNode.text.toLowerCase();
|
|
166
|
-
// Object must be a router-y identifier — keep the false-positive surface
|
|
167
|
-
// tight even though we'd lose decorators on uncommon names like `myapi`.
|
|
168
128
|
if (!ROUTER_IDENTIFIERS.has(objectName))
|
|
169
129
|
return null;
|
|
170
130
|
let method = null;
|
|
171
131
|
if (HTTP_METHODS.has(attrName))
|
|
172
132
|
method = attrName.toUpperCase();
|
|
173
133
|
else if (attrName === "route")
|
|
174
|
-
method = "ALL";
|
|
134
|
+
method = "ALL";
|
|
175
135
|
if (!method)
|
|
176
136
|
return null;
|
|
177
137
|
return readRoutePath(args, method);
|
|
178
138
|
}
|
|
179
|
-
/**
|
|
180
|
-
* Match Django path("/route", view, …) / re_path(…) and aiohttp
|
|
181
|
-
* app.router.add_get("/path", h) / add_post(…) etc.
|
|
182
|
-
*/
|
|
183
139
|
function extractCallRoute(node) {
|
|
184
140
|
const fn = node.childForFieldName("function");
|
|
185
141
|
const args = node.childForFieldName("arguments");
|
|
186
142
|
if (!fn || !args)
|
|
187
143
|
return null;
|
|
188
|
-
// Django: bare identifier function, e.g. `path("/route", view)`.
|
|
189
144
|
if (fn.type === "identifier") {
|
|
190
145
|
const name = fn.text;
|
|
191
146
|
if (!DJANGO_PATH_FNS.has(name))
|
|
192
147
|
return null;
|
|
193
148
|
return readRoutePath(args, "ALL");
|
|
194
149
|
}
|
|
195
|
-
// aiohttp: app.router.add_get("/path", h) — attribute call where the
|
|
196
|
-
// method name is encoded into the attribute (add_get, add_post, …).
|
|
197
150
|
if (fn.type === "attribute") {
|
|
198
151
|
const attrNode = fn.childForFieldName("attribute");
|
|
199
152
|
if (!attrNode)
|
|
@@ -205,20 +158,16 @@ function extractCallRoute(node) {
|
|
|
205
158
|
}
|
|
206
159
|
return null;
|
|
207
160
|
}
|
|
208
|
-
/** Pull the first positional string-literal argument as the route path. */
|
|
209
161
|
function readRoutePath(argsNode, method) {
|
|
210
162
|
for (const arg of argsNode.namedChildren) {
|
|
211
163
|
if (!arg)
|
|
212
164
|
continue;
|
|
213
|
-
// Skip kwargs (we only want the first positional).
|
|
214
165
|
if (arg.type === "keyword_argument")
|
|
215
166
|
continue;
|
|
216
167
|
if (arg.type !== "string")
|
|
217
168
|
return null;
|
|
218
|
-
// string → string_start, string_content, string_end
|
|
219
169
|
const content = arg.namedChildren.find((c) => c?.type === "string_content");
|
|
220
170
|
if (!content) {
|
|
221
|
-
// fall back: strip leading/trailing quote chars from raw text
|
|
222
171
|
const text = arg.text;
|
|
223
172
|
if (text.length >= 2 && (text.startsWith('"') || text.startsWith("'"))) {
|
|
224
173
|
return { method, path: text.slice(1, -1) };
|
|
@@ -265,7 +214,6 @@ export function aggregate(scans) {
|
|
|
265
214
|
}
|
|
266
215
|
function deriveComponentName(filePath) {
|
|
267
216
|
const segs = filePath.split("/");
|
|
268
|
-
// Skip common project-layout prefixes.
|
|
269
217
|
const skipPrefixes = new Set(["src", "app", "apps", "backend", "api"]);
|
|
270
218
|
const start = skipPrefixes.has(segs[0]) ? 1 : 0;
|
|
271
219
|
if (segs.length - start >= 2)
|
|
@@ -281,4 +229,3 @@ function detectFrameworkFromImports(imports) {
|
|
|
281
229
|
}
|
|
282
230
|
return undefined;
|
|
283
231
|
}
|
|
284
|
-
//# sourceMappingURL=scanner.js.map
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript / JavaScript language adapter.
|
|
3
|
-
*
|
|
4
|
-
* Handles .ts/.tsx/.js/.jsx + package.json. Combines manifest analysis
|
|
5
|
-
* (cheap, runs against package.json) with AST scanning (per source file)
|
|
6
|
-
* to produce components, external services, and data stores.
|
|
7
|
-
*/
|
|
8
1
|
import type { LanguageAdapter } from "../../types.js";
|
|
9
2
|
export declare const typescriptAdapter: LanguageAdapter;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript / JavaScript language adapter.
|
|
3
|
-
*
|
|
4
|
-
* Handles .ts/.tsx/.js/.jsx + package.json. Combines manifest analysis
|
|
5
|
-
* (cheap, runs against package.json) with AST scanning (per source file)
|
|
6
|
-
* to produce components, external services, and data stores.
|
|
7
|
-
*/
|
|
8
1
|
import * as path from "node:path";
|
|
9
2
|
import { readManifests, summarizeManifests, findExternalServices, findDataStores, detectFrameworkFromManifest, } from "./manifest.js";
|
|
10
3
|
import { scanFile, aggregate } from "./scanner.js";
|
|
@@ -15,13 +8,10 @@ export const typescriptAdapter = {
|
|
|
15
8
|
manifests: ["package.json"],
|
|
16
9
|
async extract(input) {
|
|
17
10
|
const { rootDir, sourceFiles, manifestFiles } = input;
|
|
18
|
-
// Manifest pass — fast, runs entirely on package.json contents.
|
|
19
11
|
const parsedManifests = await readManifests(rootDir, manifestFiles);
|
|
20
12
|
const manifestSummaries = summarizeManifests(parsedManifests);
|
|
21
13
|
const manifestExternalServices = findExternalServices(parsedManifests);
|
|
22
14
|
const manifestDataStores = findDataStores(parsedManifests);
|
|
23
|
-
// AST pass — only on source files. Cap at MAX_SOURCE_FILES per run
|
|
24
|
-
// for the Phase J <60s budget on a 100k-LOC monorepo.
|
|
25
15
|
const MAX_SOURCE_FILES = 5_000;
|
|
26
16
|
const filesToScan = sourceFiles.slice(0, MAX_SOURCE_FILES);
|
|
27
17
|
const scans = await Promise.all(filesToScan.map(async (abs) => {
|
|
@@ -33,10 +23,7 @@ export const typescriptAdapter = {
|
|
|
33
23
|
}
|
|
34
24
|
}));
|
|
35
25
|
const agg = aggregate(scans);
|
|
36
|
-
// Map scanner output → ExtractedComponent shape.
|
|
37
26
|
const components = agg.components.map((c) => {
|
|
38
|
-
// Best-effort framework inference: scanner picks up imports; manifest
|
|
39
|
-
// picks up the dep. Either signal counts.
|
|
40
27
|
const framework = c.framework ?? frameworkFromOwningManifest(c.sourceFile, parsedManifests);
|
|
41
28
|
return {
|
|
42
29
|
name: c.name,
|
|
@@ -47,13 +34,11 @@ export const typescriptAdapter = {
|
|
|
47
34
|
evidence: [...c.routes, ...c.imports],
|
|
48
35
|
};
|
|
49
36
|
});
|
|
50
|
-
// Augment manifest-derived ExternalServices with AST call sites.
|
|
51
37
|
for (const svc of manifestExternalServices) {
|
|
52
38
|
const sites = agg.aiSdkCallSites.get(svc.package);
|
|
53
39
|
if (sites)
|
|
54
40
|
svc.callSites.push(...sites);
|
|
55
41
|
}
|
|
56
|
-
// Augment manifest-derived DataStores with import-evidence from source.
|
|
57
42
|
for (const store of manifestDataStores) {
|
|
58
43
|
if (!store.client)
|
|
59
44
|
continue;
|
|
@@ -69,16 +54,11 @@ export const typescriptAdapter = {
|
|
|
69
54
|
};
|
|
70
55
|
},
|
|
71
56
|
};
|
|
72
|
-
/**
|
|
73
|
-
* Walk up from a source file's path to find the closest package.json
|
|
74
|
-
* we parsed; return the framework hint from that manifest.
|
|
75
|
-
*/
|
|
76
57
|
function frameworkFromOwningManifest(sourceFile, manifests) {
|
|
77
58
|
const sourceDir = path.posix.dirname(sourceFile);
|
|
78
59
|
const candidates = manifests
|
|
79
60
|
.map((m) => ({ m, dir: path.posix.dirname(m.filePath) }))
|
|
80
61
|
.filter(({ dir }) => sourceDir === dir || sourceDir.startsWith(dir + "/"))
|
|
81
|
-
.sort((a, b) => b.dir.length - a.dir.length);
|
|
62
|
+
.sort((a, b) => b.dir.length - a.dir.length);
|
|
82
63
|
return candidates[0] ? detectFrameworkFromManifest(candidates[0].m) : undefined;
|
|
83
64
|
}
|
|
84
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript / JavaScript manifest analysis.
|
|
3
|
-
*
|
|
4
|
-
* Reads package.json files (root + workspaces) to classify dependencies
|
|
5
|
-
* into the categories the threat-model graph cares about. Used both for
|
|
6
|
-
* the manifests block of the output and as a hint for which AST queries
|
|
7
|
-
* are worth running on which files.
|
|
8
|
-
*/
|
|
9
1
|
import type { ExtractedExternalService, ExtractedDataStore, ManifestSummary } from "../../types.js";
|
|
10
2
|
export interface PackageJson {
|
|
11
3
|
name?: string;
|
|
@@ -28,14 +20,8 @@ export interface ParsedManifest {
|
|
|
28
20
|
packageName?: string;
|
|
29
21
|
deps: Record<string, string>;
|
|
30
22
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Read every package.json, return per-file dependency maps. Combines
|
|
33
|
-
* dependencies + devDependencies (we want both — devDeps include things
|
|
34
|
-
* like @types that signal use, plus dev-only auth packages).
|
|
35
|
-
*/
|
|
36
23
|
export declare function readManifests(rootDir: string, manifestFiles: string[]): Promise<ParsedManifest[]>;
|
|
37
24
|
export declare function summarizeManifests(parsed: ParsedManifest[]): ManifestSummary[];
|
|
38
25
|
export declare function findExternalServices(parsed: ParsedManifest[]): ExtractedExternalService[];
|
|
39
26
|
export declare function findDataStores(parsed: ParsedManifest[]): ExtractedDataStore[];
|
|
40
|
-
/** Pick the most likely web framework for a manifest's owning package. */
|
|
41
27
|
export declare function detectFrameworkFromManifest(m: ParsedManifest): string | undefined;
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript / JavaScript manifest analysis.
|
|
3
|
-
*
|
|
4
|
-
* Reads package.json files (root + workspaces) to classify dependencies
|
|
5
|
-
* into the categories the threat-model graph cares about. Used both for
|
|
6
|
-
* the manifests block of the output and as a hint for which AST queries
|
|
7
|
-
* are worth running on which files.
|
|
8
|
-
*/
|
|
9
1
|
import * as fs from "node:fs/promises";
|
|
10
2
|
import * as path from "node:path";
|
|
11
3
|
export const WEB_FRAMEWORK_PACKAGES = {
|
|
@@ -15,9 +7,14 @@ export const WEB_FRAMEWORK_PACKAGES = {
|
|
|
15
7
|
"@trpc/server": "trpc",
|
|
16
8
|
hono: "hono",
|
|
17
9
|
koa: "koa",
|
|
10
|
+
"@nestjs/core": "nestjs",
|
|
11
|
+
"@nestjs/common": "nestjs",
|
|
12
|
+
"@hapi/hapi": "hapi",
|
|
13
|
+
"express-graphql": "express",
|
|
14
|
+
"apollo-server-express": "express",
|
|
18
15
|
};
|
|
19
16
|
export const DATA_STORE_PACKAGES = {
|
|
20
|
-
"@prisma/client": { kind: "postgres", client: "@prisma/client" },
|
|
17
|
+
"@prisma/client": { kind: "postgres", client: "@prisma/client" },
|
|
21
18
|
pg: { kind: "postgres", client: "pg" },
|
|
22
19
|
postgres: { kind: "postgres", client: "postgres" },
|
|
23
20
|
mongoose: { kind: "mongo", client: "mongoose" },
|
|
@@ -38,11 +35,6 @@ export const AI_SDK_PACKAGES = {
|
|
|
38
35
|
"@langchain/core": "LangChain",
|
|
39
36
|
llamaindex: "LlamaIndex",
|
|
40
37
|
};
|
|
41
|
-
/**
|
|
42
|
-
* Read every package.json, return per-file dependency maps. Combines
|
|
43
|
-
* dependencies + devDependencies (we want both — devDeps include things
|
|
44
|
-
* like @types that signal use, plus dev-only auth packages).
|
|
45
|
-
*/
|
|
46
38
|
export async function readManifests(rootDir, manifestFiles) {
|
|
47
39
|
const out = [];
|
|
48
40
|
for (const file of manifestFiles) {
|
|
@@ -63,7 +55,6 @@ export async function readManifests(rootDir, manifestFiles) {
|
|
|
63
55
|
});
|
|
64
56
|
}
|
|
65
57
|
catch {
|
|
66
|
-
// Skip broken JSON; not our job to validate the customer's manifests.
|
|
67
58
|
}
|
|
68
59
|
}
|
|
69
60
|
return out;
|
|
@@ -98,6 +89,26 @@ export function findExternalServices(parsed) {
|
|
|
98
89
|
callSites: [{ file: m.filePath, line: 1 }],
|
|
99
90
|
});
|
|
100
91
|
}
|
|
92
|
+
for (const [pkg, vendor] of Object.entries(WEB_FRAMEWORK_PACKAGES)) {
|
|
93
|
+
const ver = m.deps[pkg];
|
|
94
|
+
if (!ver)
|
|
95
|
+
continue;
|
|
96
|
+
const key = `web_framework::${pkg}`;
|
|
97
|
+
const existing = seen.get(key);
|
|
98
|
+
if (existing) {
|
|
99
|
+
existing.callSites.push({ file: m.filePath, line: 1 });
|
|
100
|
+
if (!existing.version)
|
|
101
|
+
existing.version = ver;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
seen.set(key, {
|
|
105
|
+
name: vendor,
|
|
106
|
+
kind: "web_framework",
|
|
107
|
+
package: pkg,
|
|
108
|
+
version: ver,
|
|
109
|
+
callSites: [{ file: m.filePath, line: 1 }],
|
|
110
|
+
});
|
|
111
|
+
}
|
|
101
112
|
}
|
|
102
113
|
return [...seen.values()];
|
|
103
114
|
}
|
|
@@ -125,7 +136,6 @@ export function findDataStores(parsed) {
|
|
|
125
136
|
}
|
|
126
137
|
return [...seen.values()];
|
|
127
138
|
}
|
|
128
|
-
/** Pick the most likely web framework for a manifest's owning package. */
|
|
129
139
|
export function detectFrameworkFromManifest(m) {
|
|
130
140
|
for (const [pkg, framework] of Object.entries(WEB_FRAMEWORK_PACKAGES)) {
|
|
131
141
|
if (m.deps[pkg])
|
|
@@ -153,4 +163,3 @@ function relPosix(rootDir, abs) {
|
|
|
153
163
|
const rel = path.relative(rootDir, abs);
|
|
154
164
|
return rel.split(path.sep).join("/");
|
|
155
165
|
}
|
|
156
|
-
//# sourceMappingURL=manifest.js.map
|