@dataparade/cli 0.0.26 → 0.0.28

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 (108) hide show
  1. package/README.md +52 -12
  2. package/dist/package.json +7 -7
  3. package/dist/src/ai-enrichment/providers/platform-proxy-provider.js +0 -1
  4. package/dist/src/cli.js +37 -37
  5. package/dist/src/discoveries/contract/ocsf-discovery-record.d.ts +1 -1
  6. package/dist/src/discoveries/load-ocsf-discoveries.d.ts +0 -8
  7. package/dist/src/discoveries/load-ocsf-discoveries.js +0 -31
  8. package/dist/src/discoveries/write-ocsf-discoveries.d.ts +0 -8
  9. package/dist/src/discoveries/write-ocsf-discoveries.js +0 -38
  10. package/dist/src/evals/run-model-matrix.js +0 -1
  11. package/dist/src/export/export-ocsf.d.ts +18 -0
  12. package/dist/src/export/export-ocsf.js +104 -0
  13. package/dist/src/export/register-export-commands.d.ts +2 -0
  14. package/dist/src/export/register-export-commands.js +30 -0
  15. package/dist/src/facts/apply-answers.d.ts +29 -0
  16. package/dist/src/facts/apply-answers.js +202 -0
  17. package/dist/src/facts/build-facts.d.ts +24 -0
  18. package/dist/src/facts/build-facts.js +198 -0
  19. package/dist/src/facts/io.d.ts +17 -0
  20. package/dist/src/facts/io.js +67 -0
  21. package/dist/src/facts/layout.d.ts +29 -0
  22. package/dist/src/facts/layout.js +38 -0
  23. package/dist/src/facts/schema.d.ts +265 -0
  24. package/dist/src/facts/schema.js +122 -0
  25. package/dist/src/facts/slug.d.ts +7 -0
  26. package/dist/src/facts/slug.js +47 -0
  27. package/dist/src/kb/brief.d.ts +1 -2
  28. package/dist/src/kb/brief.js +2 -4
  29. package/dist/src/kb/interview-record.d.ts +18 -0
  30. package/dist/src/kb/interview-record.js +70 -0
  31. package/dist/src/kb/kb-store.d.ts +24 -18
  32. package/dist/src/kb/kb-store.js +89 -28
  33. package/dist/src/kb/land.d.ts +32 -12
  34. package/dist/src/kb/land.js +97 -90
  35. package/dist/src/kb/migrate.d.ts +23 -0
  36. package/dist/src/kb/migrate.js +91 -0
  37. package/dist/src/kb/project-diagram.js +4 -4
  38. package/dist/src/kb/register-kb-commands.js +71 -20
  39. package/dist/src/observability/scan-sentry.js +0 -1
  40. package/dist/src/output/scan-output-excludes.d.ts +1 -1
  41. package/dist/src/output/scan-output-excludes.js +14 -5
  42. package/dist/src/output/write-scan-knowledge.d.ts +33 -0
  43. package/dist/src/output/write-scan-knowledge.js +115 -0
  44. package/dist/src/platform-api/estimate-scan-footprint.d.ts +31 -0
  45. package/dist/src/platform-api/estimate-scan-footprint.js +75 -2
  46. package/dist/src/ui/scan-progress-renderer.d.ts +2 -0
  47. package/dist/src/ui/scan-progress-renderer.js +10 -0
  48. package/dist/src/ui/teaching-lines.js +18 -6
  49. package/dist/src/upload/collect-scan-sidecars.d.ts +2 -27
  50. package/dist/src/upload/collect-scan-sidecars.js +25 -121
  51. package/dist/src/upload/run-upload.js +0 -3
  52. package/dist/tests/cli/cli.spec.js +30 -13
  53. package/dist/tests/helpers/facts-fixture.d.ts +9 -0
  54. package/dist/tests/helpers/facts-fixture.js +72 -0
  55. package/dist/tests/unit/export/export-ocsf.spec.js +72 -0
  56. package/dist/tests/unit/facts/apply-answers.spec.js +128 -0
  57. package/dist/tests/unit/facts/build-facts.spec.d.ts +1 -0
  58. package/dist/tests/unit/facts/build-facts.spec.js +161 -0
  59. package/dist/tests/unit/facts/slug.spec.d.ts +1 -0
  60. package/dist/tests/unit/facts/slug.spec.js +30 -0
  61. package/dist/tests/unit/kb/kb-interview-loop.spec.js +83 -35
  62. package/dist/tests/unit/kb/migrate.spec.d.ts +1 -0
  63. package/dist/tests/unit/kb/migrate.spec.js +108 -0
  64. package/dist/tests/unit/output/graphify-cache-dir.spec.d.ts +1 -0
  65. package/dist/tests/unit/output/graphify-cache-dir.spec.js +20 -0
  66. package/dist/tests/unit/output/scan-output-excludes.spec.js +4 -2
  67. package/dist/tests/unit/platform-api/estimate-scan-footprint.spec.js +77 -0
  68. package/dist/tests/unit/platform-api/upload-client.spec.js +2 -2
  69. package/dist/tests/unit/ui/teaching-lines.spec.js +16 -0
  70. package/dist/tests/unit/upload/collect-scan-sidecars.spec.js +46 -46
  71. package/dist/tests/unit/upload/pack-scan-upload.spec.js +6 -6
  72. package/dist/vendor/scanner/dist/src/classifier/component-factory.js +6 -14
  73. package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.d.ts +1 -0
  74. package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.js +32 -1
  75. package/dist/vendor/scanner/dist/src/classifier/naming.d.ts +5 -0
  76. package/dist/vendor/scanner/dist/src/classifier/naming.js +8 -4
  77. package/dist/vendor/scanner/dist/src/core/pipeline/build-scan-personal-data-layers.js +26 -14
  78. package/dist/vendor/scanner/dist/src/core/pipeline/enrich-personal-data-layers.js +3 -1
  79. package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.d.ts +18 -0
  80. package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.js +125 -66
  81. package/dist/vendor/scanner/dist/src/index.d.ts +2 -0
  82. package/dist/vendor/scanner/dist/src/index.js +7 -2
  83. package/dist/vendor/scanner/dist/src/ingest/file-system.d.ts +5 -0
  84. package/dist/vendor/scanner/dist/src/ingest/file-system.js +5 -0
  85. package/dist/vendor/scanner/dist/src/ingest/gitignore.d.ts +17 -0
  86. package/dist/vendor/scanner/dist/src/ingest/gitignore.js +47 -9
  87. package/dist/vendor/scanner/dist/src/ingest/schema-files.d.ts +10 -2
  88. package/dist/vendor/scanner/dist/src/ingest/schema-files.js +24 -7
  89. package/dist/vendor/scanner/dist/src/patterns/frontend-frameworks.d.ts +3 -0
  90. package/dist/vendor/scanner/dist/src/patterns/frontend-frameworks.js +45 -0
  91. package/dist/vendor/scanner/dist/src/patterns/scan-exclusions.js +7 -0
  92. package/dist/vendor/scanner/patterns/classifier/third-party.classifier.yaml +8 -0
  93. package/dist/vendor/scanner/patterns/third-party.patterns.yaml +9 -0
  94. package/package.json +7 -7
  95. package/dist/src/discoveries/project-collected-diagram.d.ts +0 -7
  96. package/dist/src/discoveries/project-collected-diagram.js +0 -182
  97. package/dist/src/discoveries/project-ocsf-to-discoveries-document.d.ts +0 -16
  98. package/dist/src/discoveries/project-ocsf-to-discoveries-document.js +0 -269
  99. package/dist/src/discoveries/scan-result-to-discovery-input.d.ts +0 -13
  100. package/dist/src/discoveries/scan-result-to-discovery-input.js +0 -60
  101. package/dist/src/output/write-knowledge-graph.d.ts +0 -20
  102. package/dist/src/output/write-knowledge-graph.js +0 -53
  103. package/dist/src/output/write-scan-discoveries.d.ts +0 -17
  104. package/dist/src/output/write-scan-discoveries.js +0 -61
  105. package/dist/tests/unit/discoveries/project-collected-diagram.spec.js +0 -97
  106. package/dist/tests/unit/discoveries/rescan-replaces-scan-records.spec.js +0 -89
  107. /package/dist/tests/unit/{discoveries/project-collected-diagram.spec.d.ts → export/export-ocsf.spec.d.ts} +0 -0
  108. /package/dist/tests/unit/{discoveries/rescan-replaces-scan-records.spec.d.ts → facts/apply-answers.spec.d.ts} +0 -0
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enclosingScopeFinder = enclosingScopeFinder;
3
4
  exports.detectIntraComponentLineage = detectIntraComponentLineage;
4
5
  const pii_signal_rules_1 = require("../pii-signals/pii-signal-rules");
5
6
  const component_evidence_resolution_1 = require("./component-evidence-resolution");
@@ -295,9 +296,15 @@ function countIndent(line) {
295
296
  return match ? match[1].replace(/\t/g, " ").length : 0;
296
297
  }
297
298
  /**
298
- * The enclosing scope of each line of one file. Scope headers are found in one pass and
299
- * scope bodies are cached by header line, so a file costs linear time rather than a
300
- * backward search and a forward brace scan for every line.
299
+ * The enclosing scope of each line of one file, in O(n log n) per file.
300
+ *
301
+ * A line with no scope header above it is its own scope start, so a file without
302
+ * function or class headers (a generated PHP baseline, a config array) has one scope
303
+ * per line, each running to the end of the file. Caching the joined text of those
304
+ * scopes kept O(lines^2) bytes alive and exhausted the heap on a 1.7 MB file. Only scope
305
+ * end lines are cached; `text` is joined on read and only for lines that need it. Scope
306
+ * ends come from a min segment tree over brace depth and a per-indent index of Ruby
307
+ * `end` lines, so no lookup scans forward through the file.
301
308
  */
302
309
  function enclosingScopeFinder(lines) {
303
310
  const nearestHeader = new Array(lines.length);
@@ -310,78 +317,130 @@ function enclosingScopeFinder(lines) {
310
317
  }
311
318
  nearestHeader[index] = last;
312
319
  }
313
- const cache = new Map();
320
+ const findScopeEnd = scopeEndFinder(lines);
321
+ // Scope start -> last line index of the scope; null for a Ruby scope without its `end`.
322
+ const ends = new Map();
314
323
  return (lineIndex) => {
315
324
  const header = nearestHeader[lineIndex] ?? -1;
316
325
  const scopeStart = header >= 0 ? header : lineIndex;
317
- const cached = cache.get(scopeStart);
318
- if (cached)
319
- return cached;
320
- const scope = findEnclosingScope(lines, lineIndex, scopeStart);
321
- // A Ruby scope without its closing `end` ends at the line asked about: not cacheable.
322
- cache.set(scopeStart, scope.unclosed ? null : scope.result);
323
- return scope.result;
326
+ let end = ends.get(scopeStart);
327
+ if (end === undefined) {
328
+ end = findScopeEnd(scopeStart);
329
+ ends.set(scopeStart, end);
330
+ }
331
+ // A Ruby scope without its closing `end` ends at the line asked about.
332
+ const scopeEnd = end ?? lineIndex;
333
+ return {
334
+ startLine: scopeStart + 1,
335
+ endLine: scopeEnd + 1,
336
+ get text() {
337
+ return lines.slice(scopeStart, scopeEnd + 1).join("\n");
338
+ },
339
+ };
324
340
  };
325
341
  }
326
- function findEnclosingScope(lines, lineIndex, scopeStart) {
327
- let scopeEnd = lineIndex;
328
- let unclosed = false;
329
- const scopeLine = lines[scopeStart] ?? "";
330
- const isRubyScope = /^\s*(?:def|class|module)\s+/.test(scopeLine);
331
- let bodyStart = scopeStart;
332
- if (!isRubyScope) {
333
- for (let index = scopeStart; index < lines.length; index += 1) {
334
- if ((lines[index] ?? "").includes("{")) {
335
- bodyStart = index;
336
- break;
337
- }
342
+ /**
343
+ * Last line index of the scope that starts at `scopeStart`, or null for a Ruby scope
344
+ * without a matching `end`.
345
+ *
346
+ * Brace scopes: the body starts at the first line at or after the scope start that holds
347
+ * a `{` and ends at the first later line where the running brace depth, counted from the
348
+ * body start, is back to zero or below. Without such a line (or without any `{`) the
349
+ * scope runs to the end of the file. Ruby scopes (`def`/`class`/`module`) end at the first
350
+ * later `end` line with the same indent.
351
+ */
352
+ function scopeEndFinder(lines) {
353
+ const count = lines.length;
354
+ const lastIndex = count - 1;
355
+ // depthAfter[i]: net `{` minus `}` over lines 0..i.
356
+ const depthAfter = new Int32Array(count);
357
+ // nextOpenLine[i]: first line index >= i that holds a `{`, or -1.
358
+ const nextOpenLine = new Int32Array(count + 1);
359
+ let depth = 0;
360
+ for (let index = 0; index < count; index += 1) {
361
+ const line = lines[index] ?? "";
362
+ for (let offset = 0; offset < line.length; offset += 1) {
363
+ const code = line.charCodeAt(offset);
364
+ if (code === 123)
365
+ depth += 1;
366
+ else if (code === 125)
367
+ depth -= 1;
338
368
  }
339
- }
340
- let braceDepth = 0;
341
- let foundOpenBrace = false;
342
- if (!isRubyScope) {
343
- for (let index = bodyStart; index < lines.length; index += 1) {
344
- const line = lines[index] ?? "";
345
- for (const char of line) {
346
- if (char === "{") {
347
- braceDepth += 1;
348
- foundOpenBrace = true;
349
- }
350
- else if (char === "}") {
351
- braceDepth -= 1;
352
- }
353
- }
354
- scopeEnd = index;
355
- if (foundOpenBrace && braceDepth <= 0 && index > bodyStart) {
356
- break;
357
- }
369
+ depthAfter[index] = depth;
370
+ }
371
+ nextOpenLine[count] = -1;
372
+ for (let index = count - 1; index >= 0; index -= 1) {
373
+ nextOpenLine[index] = (lines[index] ?? "").includes("{") ? index : nextOpenLine[index + 1];
374
+ }
375
+ const firstDepthAtMost = firstAtMostFinder(depthAfter);
376
+ let rubyEndsByIndent;
377
+ return (scopeStart) => {
378
+ const scopeLine = lines[scopeStart] ?? "";
379
+ if (/^\s*(?:def|class|module)\s+/.test(scopeLine)) {
380
+ rubyEndsByIndent ??= rubyEndLinesByIndent(lines);
381
+ const candidates = rubyEndsByIndent.get(countIndent(scopeLine)) ?? [];
382
+ const position = firstGreaterThan(candidates, scopeStart);
383
+ return position < candidates.length ? candidates[position] : null;
358
384
  }
359
- }
360
- if (!foundOpenBrace) {
361
- if (isRubyScope) {
362
- unclosed = true;
363
- const scopeIndent = countIndent(scopeLine);
364
- for (let index = scopeStart + 1; index < lines.length; index += 1) {
365
- const line = lines[index] ?? "";
366
- if (!/^\s*end\b/.test(line)) {
367
- continue;
368
- }
369
- if (countIndent(line) === scopeIndent) {
370
- scopeEnd = index;
371
- unclosed = false;
372
- break;
373
- }
374
- }
385
+ const bodyStart = nextOpenLine[scopeStart];
386
+ if (bodyStart < 0 || bodyStart >= lastIndex) {
387
+ return lastIndex;
375
388
  }
376
- }
377
- return {
378
- result: {
379
- startLine: scopeStart + 1,
380
- endLine: scopeEnd + 1,
381
- text: lines.slice(scopeStart, scopeEnd + 1).join("\n"),
382
- },
383
- unclosed,
389
+ const depthBeforeBody = bodyStart > 0 ? depthAfter[bodyStart - 1] : 0;
390
+ const closing = firstDepthAtMost(bodyStart + 1, depthBeforeBody);
391
+ return closing >= 0 ? closing : lastIndex;
392
+ };
393
+ }
394
+ function rubyEndLinesByIndent(lines) {
395
+ const byIndent = new Map();
396
+ lines.forEach((line, index) => {
397
+ if (!/^\s*end\b/.test(line))
398
+ return;
399
+ const indent = countIndent(line);
400
+ const list = byIndent.get(indent);
401
+ if (list)
402
+ list.push(index);
403
+ else
404
+ byIndent.set(indent, [index]);
405
+ });
406
+ return byIndent;
407
+ }
408
+ /** Position of the first value in ascending `values` that is greater than `target`. */
409
+ function firstGreaterThan(values, target) {
410
+ let low = 0;
411
+ let high = values.length;
412
+ while (low < high) {
413
+ const middle = (low + high) >> 1;
414
+ if (values[middle] > target)
415
+ high = middle;
416
+ else
417
+ low = middle + 1;
418
+ }
419
+ return low;
420
+ }
421
+ /**
422
+ * Returns a lookup for the first index >= `from` whose value is <= `limit` (or -1), in
423
+ * O(log n) per lookup over a min segment tree.
424
+ */
425
+ function firstAtMostFinder(values) {
426
+ let size = 1;
427
+ while (size < values.length)
428
+ size *= 2;
429
+ const tree = new Int32Array(size * 2).fill(0x7fffffff);
430
+ tree.set(values, size);
431
+ for (let node = size - 1; node >= 1; node -= 1) {
432
+ tree[node] = Math.min(tree[node * 2], tree[node * 2 + 1]);
433
+ }
434
+ const search = (node, low, high, from, limit) => {
435
+ if (high < from || tree[node] > limit)
436
+ return -1;
437
+ if (low === high)
438
+ return low;
439
+ const middle = (low + high) >> 1;
440
+ const left = search(node * 2, low, middle, from, limit);
441
+ return left >= 0 ? left : search(node * 2 + 1, middle + 1, high, from, limit);
384
442
  };
443
+ return (from, limit) => (from >= values.length ? -1 : search(1, 0, size - 1, from, limit));
385
444
  }
386
445
  function isClassScopeLine(line) {
387
446
  return CLASS_DEF_PATTERNS.some((pattern) => pattern.test(line));
@@ -24,6 +24,8 @@ export { dedupeDataFlows } from "./data-flow/dedupe";
24
24
  export { loadClassifierConfig } from "./classifier/config";
25
25
  export { hostMatchesOrganizationDomains, normalizeOrganizationDomains, } from "./classifier/external-url-third-party";
26
26
  export { DETECTABLE_PROPERTY_KEYS } from "./classifier/enhance-defaults";
27
+ export { canonicalFrameworkId, frameworkDisplayName, } from "./patterns/frontend-frameworks";
28
+ export { toDisplayName } from "./classifier/naming";
27
29
  export { runAnalyzers } from "./analyzers/registry";
28
30
  export * from "./core/schema";
29
31
  export * from "./core/types";
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.DATA_ACTIONS = exports.tagFindingsWithServiceSections = exports.discoverServiceSections = exports.runAnalyzers = exports.DETECTABLE_PROPERTY_KEYS = exports.normalizeOrganizationDomains = exports.hostMatchesOrganizationDomains = exports.loadClassifierConfig = exports.dedupeDataFlows = exports.appendTerraformBareProviderAttachmentFlows = exports.shouldSkipDirectoryName = exports.DEFAULT_EXCLUDED_FILE_GLOBS = exports.toPosixPath = exports.isPathIgnored = exports.gitignoreRulesForDir = exports.gitignorePatternToRegex = exports.isSensitiveEnvPath = exports.resolveScanFilesystemEntry = exports.ingestFileSystem = exports.sortDataFlowsDeterministically = exports.STABLE_FLOW_ID_PREFIX = exports.STABLE_FLOW_ID_PATTERN = exports.STABLE_COMPONENT_ID_PREFIX = exports.STABLE_COMPONENT_ID_PATTERN = exports.stableFlowKey = exports.stableFlowId = exports.stableComponentId = exports.resolvedStableComponentKey = exports.normalizeFlowEndpoint = exports.buildComponentKeyById = exports.assignStableEntityIdsWithMaps = exports.assignStableEntityIds = exports.assignStableComponentIds = exports.stableComponentKey = exports.collectEvalFindings = exports.DATAPARADE_GRAPH_SCHEMA = exports.DATAPARADE_GRAPH_FILE = exports.writeKnowledgeGraph = exports.buildDataParadeGraph = exports.loadGraphifyGraph = exports.runGraphify = exports.selectPrimaryDataAction = exports.buildDiagramGraphFromScanResult = exports.buildScanPersonalDataLayers = exports.enrichOrchestratorResultWithPersonalDataLayers = exports.runDeterministicScanPhases = exports.finalizeDeterministicScanResult = exports.emitScanProgress = exports.scan = exports.createDefaultScanConfiguration = void 0;
18
- exports.runDataActionPhase = exports.hasVerb = exports.readDataActions = exports.mergeOneAssignment = exports.mergeAssignmentsOntoComponents = exports.DATA_ACTION_RULE_LANGUAGES = exports.ruleAppliesToLanguage = exports.clearDataActionRulesCacheForTest = exports.loadDataActionRules = exports.loadDataActionRuleCatalog = exports.TERRAFORM_GATEWAY_SUBTYPES = exports.SUBTYPE_STORE_SUBTYPES = exports.deriveFromSubtypes = exports.pathsReferToSameFile = exports.deriveFromPatterns = exports.STORAGE_SUBTYPES = exports.deriveFromTopology = exports.normalizeDataActionToken = exports.normalizeDataAction = exports.isDataAction = exports.DATA_ACTION_SET = exports.DATA_ACTION_FRAMEWORK_ANCHORS = exports.DATA_ACTION_ALIASES = void 0;
17
+ exports.runAnalyzers = exports.toDisplayName = exports.frameworkDisplayName = exports.canonicalFrameworkId = exports.DETECTABLE_PROPERTY_KEYS = exports.normalizeOrganizationDomains = exports.hostMatchesOrganizationDomains = exports.loadClassifierConfig = exports.dedupeDataFlows = exports.appendTerraformBareProviderAttachmentFlows = exports.shouldSkipDirectoryName = exports.DEFAULT_EXCLUDED_FILE_GLOBS = exports.toPosixPath = exports.isPathIgnored = exports.gitignoreRulesForDir = exports.gitignorePatternToRegex = exports.isSensitiveEnvPath = exports.resolveScanFilesystemEntry = exports.ingestFileSystem = exports.sortDataFlowsDeterministically = exports.STABLE_FLOW_ID_PREFIX = exports.STABLE_FLOW_ID_PATTERN = exports.STABLE_COMPONENT_ID_PREFIX = exports.STABLE_COMPONENT_ID_PATTERN = exports.stableFlowKey = exports.stableFlowId = exports.stableComponentId = exports.resolvedStableComponentKey = exports.normalizeFlowEndpoint = exports.buildComponentKeyById = exports.assignStableEntityIdsWithMaps = exports.assignStableEntityIds = exports.assignStableComponentIds = exports.stableComponentKey = exports.collectEvalFindings = exports.DATAPARADE_GRAPH_SCHEMA = exports.DATAPARADE_GRAPH_FILE = exports.writeKnowledgeGraph = exports.buildDataParadeGraph = exports.loadGraphifyGraph = exports.runGraphify = exports.selectPrimaryDataAction = exports.buildDiagramGraphFromScanResult = exports.buildScanPersonalDataLayers = exports.enrichOrchestratorResultWithPersonalDataLayers = exports.runDeterministicScanPhases = exports.finalizeDeterministicScanResult = exports.emitScanProgress = exports.scan = exports.createDefaultScanConfiguration = void 0;
18
+ exports.runDataActionPhase = exports.hasVerb = exports.readDataActions = exports.mergeOneAssignment = exports.mergeAssignmentsOntoComponents = exports.DATA_ACTION_RULE_LANGUAGES = exports.ruleAppliesToLanguage = exports.clearDataActionRulesCacheForTest = exports.loadDataActionRules = exports.loadDataActionRuleCatalog = exports.TERRAFORM_GATEWAY_SUBTYPES = exports.SUBTYPE_STORE_SUBTYPES = exports.deriveFromSubtypes = exports.pathsReferToSameFile = exports.deriveFromPatterns = exports.STORAGE_SUBTYPES = exports.deriveFromTopology = exports.normalizeDataActionToken = exports.normalizeDataAction = exports.isDataAction = exports.DATA_ACTION_SET = exports.DATA_ACTION_FRAMEWORK_ANCHORS = exports.DATA_ACTION_ALIASES = exports.DATA_ACTIONS = exports.tagFindingsWithServiceSections = exports.discoverServiceSections = void 0;
19
19
  var orchestrator_1 = require("./core/pipeline/orchestrator");
20
20
  Object.defineProperty(exports, "createDefaultScanConfiguration", { enumerable: true, get: function () { return orchestrator_1.createDefaultScanConfiguration; } });
21
21
  Object.defineProperty(exports, "scan", { enumerable: true, get: function () { return orchestrator_1.scan; } });
@@ -82,6 +82,11 @@ Object.defineProperty(exports, "hostMatchesOrganizationDomains", { enumerable: t
82
82
  Object.defineProperty(exports, "normalizeOrganizationDomains", { enumerable: true, get: function () { return external_url_third_party_1.normalizeOrganizationDomains; } });
83
83
  var enhance_defaults_1 = require("./classifier/enhance-defaults");
84
84
  Object.defineProperty(exports, "DETECTABLE_PROPERTY_KEYS", { enumerable: true, get: function () { return enhance_defaults_1.DETECTABLE_PROPERTY_KEYS; } });
85
+ var frontend_frameworks_1 = require("./patterns/frontend-frameworks");
86
+ Object.defineProperty(exports, "canonicalFrameworkId", { enumerable: true, get: function () { return frontend_frameworks_1.canonicalFrameworkId; } });
87
+ Object.defineProperty(exports, "frameworkDisplayName", { enumerable: true, get: function () { return frontend_frameworks_1.frameworkDisplayName; } });
88
+ var naming_1 = require("./classifier/naming");
89
+ Object.defineProperty(exports, "toDisplayName", { enumerable: true, get: function () { return naming_1.toDisplayName; } });
85
90
  var registry_1 = require("./analyzers/registry");
86
91
  Object.defineProperty(exports, "runAnalyzers", { enumerable: true, get: function () { return registry_1.runAnalyzers; } });
87
92
  __exportStar(require("./core/schema"), exports);
@@ -10,6 +10,11 @@ export interface IngestOptions {
10
10
  excludePaths?: string[];
11
11
  onWarning?: (warning: string) => void;
12
12
  }
13
+ /**
14
+ * True when a path relative to the scan root matches one of the exclude patterns
15
+ * (defaults plus `--exclude`). Walks call it on directories to prune them.
16
+ */
17
+ export declare function isExcludedByUserPatterns(relativePath: string, isDirectory: boolean, excludePaths: readonly string[]): boolean;
13
18
  /**
14
19
  * Resolve a user-supplied scan path to a directory (for config, Terraform cwd,
15
20
  * section discovery) and an ingest target (directory walk or a single file).
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DEFAULT_MAX_TOTAL_BYTES = exports.DEFAULT_MAX_FILE_COUNT = exports.DEFAULT_MAX_FILE_SIZE_BYTES = void 0;
37
+ exports.isExcludedByUserPatterns = isExcludedByUserPatterns;
37
38
  exports.resolveScanFilesystemEntry = resolveScanFilesystemEntry;
38
39
  exports.ingestFileSystemWithOutcomes = ingestFileSystemWithOutcomes;
39
40
  exports.ingestFileSystem = ingestFileSystem;
@@ -49,6 +50,10 @@ exports.DEFAULT_MAX_TOTAL_BYTES = 200 * 1024 * 1024; // 200MB
49
50
  function normalizeUserPattern(pattern) {
50
51
  return (0, gitignore_1.toPosixPath)(pattern.replace(/^\.\/+/, "").trim());
51
52
  }
53
+ /**
54
+ * True when a path relative to the scan root matches one of the exclude patterns
55
+ * (defaults plus `--exclude`). Walks call it on directories to prune them.
56
+ */
52
57
  function isExcludedByUserPatterns(relativePath, isDirectory, excludePaths) {
53
58
  const rel = (0, gitignore_1.toPosixPath)(relativePath);
54
59
  for (const rawPattern of excludePaths) {
@@ -6,7 +6,24 @@ export type IgnoreRule = {
6
6
  regex: RegExp;
7
7
  };
8
8
  export declare function toPosixPath(p: string): string;
9
+ /**
10
+ * Glob to regex for user exclude patterns, matched against the path relative to the
11
+ * scan root:
12
+ * - * matches any chars except path separator
13
+ * - ** matches across directories
14
+ * - ? matches a single non-separator
15
+ */
9
16
  export declare function gitignorePatternToRegex(pattern: string, dirOnly: boolean): RegExp;
17
+ /**
18
+ * Regex for one `.gitignore` line, matched against the path relative to the
19
+ * `.gitignore`'s directory, following git's rules:
20
+ * - a leading `/` anchors the pattern to that directory;
21
+ * - a pattern with no other `/` matches a name at any depth (`build`, `*.log`);
22
+ * - a pattern with a `/` in the middle is anchored (`src/gen`);
23
+ * - a leading or inner `**` segment matches zero or more directories.
24
+ * A match on a directory also ignores everything under it.
25
+ */
26
+ export declare function gitignoreLineToRegex(line: string): RegExp;
10
27
  export declare function readGitignore(dir: string): Promise<IgnoreRule[]>;
11
28
  export declare function gitignoreRulesForDir(currentDir: string, accumulatedRules: IgnoreRule[]): Promise<IgnoreRule[]>;
12
29
  export declare function isPathIgnored(absolutePath: string, isDirectory: boolean, rules: IgnoreRule[]): boolean;
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.toPosixPath = toPosixPath;
37
37
  exports.gitignorePatternToRegex = gitignorePatternToRegex;
38
+ exports.gitignoreLineToRegex = gitignoreLineToRegex;
38
39
  exports.readGitignore = readGitignore;
39
40
  exports.gitignoreRulesForDir = gitignoreRulesForDir;
40
41
  exports.isPathIgnored = isPathIgnored;
@@ -43,20 +44,55 @@ const path = __importStar(require("path"));
43
44
  function toPosixPath(p) {
44
45
  return p.split(path.sep).join("/");
45
46
  }
46
- function gitignorePatternToRegex(pattern, dirOnly) {
47
- // Very small subset of .gitignore-style patterns:
48
- // - * matches any chars except path separator
49
- // - ** matches across directories
50
- // - ? matches a single non-separator
51
- // - pattern without leading slash matches anywhere under baseDir
47
+ function globToRegexBody(pattern) {
52
48
  let escaped = pattern.replace(/[-\\^$+?.()|[\]{}*?]/g, "\\$&");
53
49
  // Restore globs
54
50
  escaped = escaped.replace(/\\\*\\\*/g, ".*"); // **
55
51
  escaped = escaped.replace(/\\\*/g, "[^/]*"); // *
56
52
  escaped = escaped.replace(/\\\?/g, "[^/]"); // ?
53
+ return escaped;
54
+ }
55
+ /**
56
+ * Glob to regex for user exclude patterns, matched against the path relative to the
57
+ * scan root:
58
+ * - * matches any chars except path separator
59
+ * - ** matches across directories
60
+ * - ? matches a single non-separator
61
+ */
62
+ function gitignorePatternToRegex(pattern, dirOnly) {
57
63
  const suffix = dirOnly ? "(?:/.*)?$" : "$";
58
64
  // Match from start of the relative path
59
- return new RegExp(`^${escaped}${suffix}`);
65
+ return new RegExp(`^${globToRegexBody(pattern)}${suffix}`);
66
+ }
67
+ /**
68
+ * Regex for one `.gitignore` line, matched against the path relative to the
69
+ * `.gitignore`'s directory, following git's rules:
70
+ * - a leading `/` anchors the pattern to that directory;
71
+ * - a pattern with no other `/` matches a name at any depth (`build`, `*.log`);
72
+ * - a pattern with a `/` in the middle is anchored (`src/gen`);
73
+ * - a leading or inner `**` segment matches zero or more directories.
74
+ * A match on a directory also ignores everything under it.
75
+ */
76
+ function gitignoreLineToRegex(line) {
77
+ let pattern = toPosixPath(line);
78
+ let anchored = false;
79
+ if (pattern.startsWith("/")) {
80
+ anchored = true;
81
+ pattern = pattern.replace(/^\/+/, "");
82
+ }
83
+ else if (pattern.startsWith("**/")) {
84
+ pattern = pattern.slice(3);
85
+ }
86
+ else if (pattern.includes("/")) {
87
+ anchored = true;
88
+ }
89
+ let body = globToRegexBody(pattern);
90
+ // `a/**/b` also matches `a/b`.
91
+ body = body.replace(/\/\.\*\//g, "/(?:.*/)?");
92
+ const prefix = anchored ? "" : "(?:.*/)?";
93
+ // `dirOnly` rules are only applied to directories (see isPathIgnored); either kind
94
+ // also covers what lies under the matched path.
95
+ return new RegExp(`^${prefix}${body}(?:/.*)?$`);
60
96
  }
61
97
  async function readGitignore(dir) {
62
98
  const gitignorePath = path.join(dir, ".gitignore");
@@ -82,7 +118,7 @@ async function readGitignore(dir) {
82
118
  if (!line)
83
119
  continue;
84
120
  }
85
- const regex = gitignorePatternToRegex(toPosixPath(line), dirOnly);
121
+ const regex = gitignoreLineToRegex(line);
86
122
  rules.push({
87
123
  baseDir: dir,
88
124
  pattern: line,
@@ -103,7 +139,9 @@ async function readGitignore(dir) {
103
139
  }
104
140
  async function gitignoreRulesForDir(currentDir, accumulatedRules) {
105
141
  const localRules = await readGitignore(currentDir);
106
- return accumulatedRules.concat(localRules);
142
+ // Most directories have no .gitignore: share the parent's array instead of copying it
143
+ // once per directory.
144
+ return localRules.length === 0 ? accumulatedRules : accumulatedRules.concat(localRules);
107
145
  }
108
146
  function isPathIgnored(absolutePath, isDirectory, rules) {
109
147
  const normalizedPath = toPosixPath(absolutePath);
@@ -12,5 +12,13 @@ export interface SchemaFile {
12
12
  kind: "prisma" | "sql" | "rails" | "laravel";
13
13
  }
14
14
  export declare function schemaFileKind(filePath: string): SchemaFile["kind"] | undefined;
15
- /** Every `*.prisma` and `*.sql` file under the root, outside excluded, test and fixture directories. */
16
- export declare function readSchemaFiles(rootPath: string): Promise<SchemaFile[]>;
15
+ export interface ReadSchemaFilesOptions {
16
+ /** The scan's exclude patterns (`--exclude`); the default file globs are always added. */
17
+ excludePaths?: readonly string[];
18
+ }
19
+ /**
20
+ * Every `*.prisma` and `*.sql` file under the root, outside excluded, test and fixture
21
+ * directories. Uses the same pruning as ingest: default excluded directories, the exclude
22
+ * patterns and `.gitignore` are applied to each directory before it is entered.
23
+ */
24
+ export declare function readSchemaFiles(rootPath: string, options?: ReadSchemaFilesOptions): Promise<SchemaFile[]>;
@@ -38,6 +38,7 @@ exports.readSchemaFiles = readSchemaFiles;
38
38
  const fs_1 = require("fs");
39
39
  const path = __importStar(require("path"));
40
40
  const scan_exclusions_1 = require("../patterns/scan-exclusions");
41
+ const file_system_1 = require("./file-system");
41
42
  const gitignore_1 = require("./gitignore");
42
43
  const MAX_SCHEMA_FILE_BYTES = 2 * 1024 * 1024;
43
44
  const MAX_SCHEMA_FILES = 5_000;
@@ -61,15 +62,22 @@ function schemaFileKind(filePath) {
61
62
  return "laravel";
62
63
  return undefined;
63
64
  }
64
- /** Every `*.prisma` and `*.sql` file under the root, outside excluded, test and fixture directories. */
65
- async function readSchemaFiles(rootPath) {
65
+ /**
66
+ * Every `*.prisma` and `*.sql` file under the root, outside excluded, test and fixture
67
+ * directories. Uses the same pruning as ingest: default excluded directories, the exclude
68
+ * patterns and `.gitignore` are applied to each directory before it is entered.
69
+ */
70
+ async function readSchemaFiles(rootPath, options = {}) {
66
71
  const root = path.resolve(rootPath);
72
+ const excludePaths = [...scan_exclusions_1.DEFAULT_EXCLUDED_FILE_GLOBS, ...(options.excludePaths ?? [])];
67
73
  const out = [];
68
- const walk = async (dir) => {
74
+ const walk = async (dir, parentRules) => {
69
75
  if (out.length >= MAX_SCHEMA_FILES)
70
76
  return;
71
77
  let entries;
78
+ let rules;
72
79
  try {
80
+ rules = await (0, gitignore_1.gitignoreRulesForDir)(dir, parentRules);
73
81
  entries = await fs_1.promises.readdir(dir, { withFileTypes: true });
74
82
  }
75
83
  catch {
@@ -78,20 +86,29 @@ async function readSchemaFiles(rootPath) {
78
86
  entries.sort((a, b) => a.name.localeCompare(b.name));
79
87
  for (const entry of entries) {
80
88
  const full = path.join(dir, entry.name);
89
+ const rel = (0, gitignore_1.toPosixPath)(path.relative(root, full));
81
90
  if (entry.isDirectory()) {
82
91
  if ((0, scan_exclusions_1.shouldSkipDirectoryName)(entry.name) || NON_APP_DIR.test(entry.name))
83
92
  continue;
84
- await walk(full);
93
+ if ((0, file_system_1.isExcludedByUserPatterns)(rel, true, excludePaths))
94
+ continue;
95
+ if ((0, gitignore_1.isPathIgnored)(full, true, rules))
96
+ continue;
97
+ await walk(full, rules);
85
98
  }
86
99
  else if (entry.isFile()) {
87
- const kind = schemaFileKind(path.relative(root, full));
100
+ const kind = schemaFileKind(rel);
88
101
  if (!kind)
89
102
  continue;
103
+ if ((0, file_system_1.isExcludedByUserPatterns)(rel, false, excludePaths))
104
+ continue;
105
+ if ((0, gitignore_1.isPathIgnored)(full, false, rules))
106
+ continue;
90
107
  try {
91
108
  const stat = await fs_1.promises.stat(full);
92
109
  if (stat.size > MAX_SCHEMA_FILE_BYTES)
93
110
  continue;
94
- out.push({ path: (0, gitignore_1.toPosixPath)(path.relative(root, full)), content: await fs_1.promises.readFile(full, "utf8"), kind });
111
+ out.push({ path: rel, content: await fs_1.promises.readFile(full, "utf8"), kind });
95
112
  }
96
113
  catch {
97
114
  /* unreadable files are skipped */
@@ -101,6 +118,6 @@ async function readSchemaFiles(rootPath) {
101
118
  }
102
119
  }
103
120
  };
104
- await walk(root);
121
+ await walk(root, []);
105
122
  return out;
106
123
  }
@@ -2,3 +2,6 @@ export declare const FRONTEND_FRAMEWORK_HINTS: readonly ["next_or_react_route",
2
2
  export declare const FRONTEND_FRAMEWORK_HINTS_SET: Set<string>;
3
3
  export declare const PREFERRED_WEB_APP_FRAMEWORKS: Set<string>;
4
4
  export declare const SERVER_FRAMEWORK_HINTS: Set<string>;
5
+ export declare function canonicalFrameworkId(framework: string): string;
6
+ /** Human-readable framework label, identical for every alias of one framework. */
7
+ export declare function frameworkDisplayName(framework: string): string;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SERVER_FRAMEWORK_HINTS = exports.PREFERRED_WEB_APP_FRAMEWORKS = exports.FRONTEND_FRAMEWORK_HINTS_SET = exports.FRONTEND_FRAMEWORK_HINTS = void 0;
4
+ exports.canonicalFrameworkId = canonicalFrameworkId;
5
+ exports.frameworkDisplayName = frameworkDisplayName;
4
6
  exports.FRONTEND_FRAMEWORK_HINTS = [
5
7
  "next_or_react_route",
6
8
  "nextjs",
@@ -23,3 +25,46 @@ exports.SERVER_FRAMEWORK_HINTS = new Set([
23
25
  "express",
24
26
  "serverless",
25
27
  ]);
28
+ /**
29
+ * Canonical framework ids. Detectors emit different spellings for the same
30
+ * framework (`next_or_react_route` from route-handler files, `nextjs` from the
31
+ * `next` dependency); both resolve to one id here.
32
+ */
33
+ const FRAMEWORK_ALIASES = {
34
+ next_or_react_route: "nextjs",
35
+ next: "nextjs",
36
+ "next.js": "nextjs",
37
+ nextjs: "nextjs",
38
+ };
39
+ const FRAMEWORK_DISPLAY_NAMES = {
40
+ nextjs: "Next.js",
41
+ react: "React",
42
+ vue: "Vue",
43
+ angular: "Angular",
44
+ ionic: "Ionic",
45
+ electron: "Electron",
46
+ svelte: "Svelte",
47
+ solid: "Solid",
48
+ qwik: "Qwik",
49
+ express: "Express",
50
+ nest: "Nest",
51
+ fastapi: "FastAPI",
52
+ flask: "Flask",
53
+ django: "Django",
54
+ };
55
+ function canonicalFrameworkId(framework) {
56
+ const key = framework.trim().toLowerCase();
57
+ return FRAMEWORK_ALIASES[key] ?? key;
58
+ }
59
+ /** Human-readable framework label, identical for every alias of one framework. */
60
+ function frameworkDisplayName(framework) {
61
+ const id = canonicalFrameworkId(framework);
62
+ const known = FRAMEWORK_DISPLAY_NAMES[id];
63
+ if (known)
64
+ return known;
65
+ return id
66
+ .split(/[\s_-]+/)
67
+ .filter(Boolean)
68
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
69
+ .join(" ");
70
+ }
@@ -17,7 +17,14 @@ exports.DEFAULT_EXCLUDED_DIRS = new Set([
17
17
  ".git",
18
18
  "dist",
19
19
  "build",
20
+ // Framework build output and tool caches. Hidden directories are skipped anyway (see
21
+ // shouldSkipDirectoryName); they are listed so the default stays explicit.
20
22
  ".next",
23
+ ".nuxt",
24
+ ".svelte-kit",
25
+ ".turbo",
26
+ ".vercel",
27
+ ".cache",
21
28
  "out",
22
29
  "coverage",
23
30
  ".vscode",
@@ -53,6 +53,14 @@ third_parties:
53
53
  type: third_party
54
54
  subType: saas_service
55
55
 
56
+ - serviceName: notion
57
+ matchKeys:
58
+ - "@notionhq/client"
59
+ - "notion.so"
60
+ - "notion.com"
61
+ type: third_party
62
+ subType: saas_service
63
+
56
64
  - serviceName: google_identity
57
65
  matchKeys:
58
66
  - google_identity
@@ -57,6 +57,15 @@ services:
57
57
  - api.twitter.com
58
58
  - x.com
59
59
  - api.x.com
60
+ - serviceName: notion
61
+ patternId: external_api_call
62
+ importFragments:
63
+ - "@notionhq/client"
64
+ confidence: 0.85
65
+ url_host_patterns:
66
+ - notion.so
67
+ - notion.com
68
+ - api.notion.com
60
69
  - serviceName: google_identity
61
70
  patternId: external_api_call
62
71
  importFragments: