@dataparade/cli 0.0.26 → 0.0.29

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 (120) hide show
  1. package/README.md +56 -13
  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.d.ts +3 -0
  5. package/dist/src/cli.js +102 -68
  6. package/dist/src/discoveries/contract/ocsf-discovery-record.d.ts +1 -1
  7. package/dist/src/discoveries/load-ocsf-discoveries.d.ts +0 -8
  8. package/dist/src/discoveries/load-ocsf-discoveries.js +0 -31
  9. package/dist/src/discoveries/write-ocsf-discoveries.d.ts +0 -8
  10. package/dist/src/discoveries/write-ocsf-discoveries.js +0 -38
  11. package/dist/src/evals/run-model-matrix.js +0 -1
  12. package/dist/src/export/export-ocsf.d.ts +18 -0
  13. package/dist/src/export/export-ocsf.js +104 -0
  14. package/dist/src/export/register-export-commands.d.ts +2 -0
  15. package/dist/src/export/register-export-commands.js +30 -0
  16. package/dist/src/facts/apply-answers.d.ts +29 -0
  17. package/dist/src/facts/apply-answers.js +202 -0
  18. package/dist/src/facts/build-facts.d.ts +24 -0
  19. package/dist/src/facts/build-facts.js +198 -0
  20. package/dist/src/facts/io.d.ts +17 -0
  21. package/dist/src/facts/io.js +67 -0
  22. package/dist/src/facts/layout.d.ts +29 -0
  23. package/dist/src/facts/layout.js +38 -0
  24. package/dist/src/facts/schema.d.ts +265 -0
  25. package/dist/src/facts/schema.js +122 -0
  26. package/dist/src/facts/slug.d.ts +7 -0
  27. package/dist/src/facts/slug.js +47 -0
  28. package/dist/src/kb/brief.d.ts +1 -2
  29. package/dist/src/kb/brief.js +2 -4
  30. package/dist/src/kb/interview-record.d.ts +18 -0
  31. package/dist/src/kb/interview-record.js +70 -0
  32. package/dist/src/kb/kb-store.d.ts +24 -18
  33. package/dist/src/kb/kb-store.js +89 -28
  34. package/dist/src/kb/land.d.ts +32 -12
  35. package/dist/src/kb/land.js +97 -90
  36. package/dist/src/kb/migrate.d.ts +23 -0
  37. package/dist/src/kb/migrate.js +91 -0
  38. package/dist/src/kb/project-diagram.js +4 -4
  39. package/dist/src/kb/register-kb-commands.js +71 -20
  40. package/dist/src/observability/scan-sentry.js +0 -1
  41. package/dist/src/output/scan-output-excludes.d.ts +1 -1
  42. package/dist/src/output/scan-output-excludes.js +14 -5
  43. package/dist/src/output/write-scan-knowledge.d.ts +33 -0
  44. package/dist/src/output/write-scan-knowledge.js +115 -0
  45. package/dist/src/platform-api/estimate-scan-footprint.d.ts +31 -0
  46. package/dist/src/platform-api/estimate-scan-footprint.js +75 -2
  47. package/dist/src/platform-api/fetch-failure.d.ts +5 -0
  48. package/dist/src/platform-api/fetch-failure.js +13 -0
  49. package/dist/src/platform-api/upload-client.d.ts +5 -0
  50. package/dist/src/platform-api/upload-client.js +11 -1
  51. package/dist/src/ui/scan-progress-renderer.d.ts +16 -0
  52. package/dist/src/ui/scan-progress-renderer.js +29 -3
  53. package/dist/src/ui/teaching-lines.js +18 -6
  54. package/dist/src/upload/collect-scan-sidecars.d.ts +2 -27
  55. package/dist/src/upload/collect-scan-sidecars.js +25 -121
  56. package/dist/src/upload/run-upload.js +0 -3
  57. package/dist/tests/cli/cli.spec.js +30 -13
  58. package/dist/tests/helpers/facts-fixture.d.ts +9 -0
  59. package/dist/tests/helpers/facts-fixture.js +72 -0
  60. package/dist/tests/unit/cli/scan-ai-session-fallback.spec.js +156 -0
  61. package/dist/tests/unit/export/export-ocsf.spec.js +72 -0
  62. package/dist/tests/unit/facts/apply-answers.spec.d.ts +1 -0
  63. package/dist/tests/unit/facts/apply-answers.spec.js +128 -0
  64. package/dist/tests/unit/facts/build-facts.spec.d.ts +1 -0
  65. package/dist/tests/unit/facts/build-facts.spec.js +161 -0
  66. package/dist/tests/unit/facts/slug.spec.d.ts +1 -0
  67. package/dist/tests/unit/facts/slug.spec.js +30 -0
  68. package/dist/tests/unit/kb/kb-interview-loop.spec.js +83 -35
  69. package/dist/tests/unit/kb/migrate.spec.d.ts +1 -0
  70. package/dist/tests/unit/kb/migrate.spec.js +108 -0
  71. package/dist/tests/unit/output/graphify-cache-dir.spec.d.ts +1 -0
  72. package/dist/tests/unit/output/graphify-cache-dir.spec.js +20 -0
  73. package/dist/tests/unit/output/scan-output-excludes.spec.js +4 -2
  74. package/dist/tests/unit/platform-api/estimate-scan-footprint.spec.js +77 -0
  75. package/dist/tests/unit/platform-api/upload-client.spec.js +2 -2
  76. package/dist/tests/unit/ui/scan-progress-renderer.spec.js +21 -0
  77. package/dist/tests/unit/ui/teaching-lines.spec.js +16 -0
  78. package/dist/tests/unit/upload/collect-scan-sidecars.spec.js +46 -46
  79. package/dist/tests/unit/upload/pack-scan-upload.spec.js +6 -6
  80. package/dist/vendor/scanner/dist/src/classifier/component-factory.js +6 -14
  81. package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.d.ts +1 -0
  82. package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.js +32 -1
  83. package/dist/vendor/scanner/dist/src/classifier/naming.d.ts +5 -0
  84. package/dist/vendor/scanner/dist/src/classifier/naming.js +8 -4
  85. package/dist/vendor/scanner/dist/src/core/pipeline/build-scan-personal-data-layers.js +26 -14
  86. package/dist/vendor/scanner/dist/src/core/pipeline/enrich-personal-data-layers.js +3 -1
  87. package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.d.ts +18 -0
  88. package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.js +125 -66
  89. package/dist/vendor/scanner/dist/src/index.d.ts +2 -0
  90. package/dist/vendor/scanner/dist/src/index.js +7 -2
  91. package/dist/vendor/scanner/dist/src/ingest/file-system.d.ts +5 -0
  92. package/dist/vendor/scanner/dist/src/ingest/file-system.js +5 -0
  93. package/dist/vendor/scanner/dist/src/ingest/gitignore.d.ts +17 -0
  94. package/dist/vendor/scanner/dist/src/ingest/gitignore.js +47 -9
  95. package/dist/vendor/scanner/dist/src/ingest/schema-files.d.ts +10 -2
  96. package/dist/vendor/scanner/dist/src/ingest/schema-files.js +24 -7
  97. package/dist/vendor/scanner/dist/src/patterns/frontend-frameworks.d.ts +3 -0
  98. package/dist/vendor/scanner/dist/src/patterns/frontend-frameworks.js +45 -0
  99. package/dist/vendor/scanner/dist/src/patterns/scan-exclusions.js +7 -0
  100. package/dist/vendor/scanner/dist/src/pii-signals/match-pii-signals.d.ts +24 -0
  101. package/dist/vendor/scanner/dist/src/pii-signals/match-pii-signals.js +19 -6
  102. package/dist/vendor/scanner/dist/src/pii-signals/occurrence-group.js +5 -2
  103. package/dist/vendor/scanner/dist/src/pii-signals/pii-signal-aliases.js +5 -2
  104. package/dist/vendor/scanner/patterns/classifier/third-party.classifier.yaml +8 -0
  105. package/dist/vendor/scanner/patterns/third-party.patterns.yaml +9 -0
  106. package/package.json +7 -7
  107. package/dist/src/discoveries/project-collected-diagram.d.ts +0 -7
  108. package/dist/src/discoveries/project-collected-diagram.js +0 -182
  109. package/dist/src/discoveries/project-ocsf-to-discoveries-document.d.ts +0 -16
  110. package/dist/src/discoveries/project-ocsf-to-discoveries-document.js +0 -269
  111. package/dist/src/discoveries/scan-result-to-discovery-input.d.ts +0 -13
  112. package/dist/src/discoveries/scan-result-to-discovery-input.js +0 -60
  113. package/dist/src/output/write-knowledge-graph.d.ts +0 -20
  114. package/dist/src/output/write-knowledge-graph.js +0 -53
  115. package/dist/src/output/write-scan-discoveries.d.ts +0 -17
  116. package/dist/src/output/write-scan-discoveries.js +0 -61
  117. package/dist/tests/unit/discoveries/project-collected-diagram.spec.js +0 -97
  118. package/dist/tests/unit/discoveries/rescan-replaces-scan-records.spec.js +0 -89
  119. /package/dist/tests/unit/{discoveries/project-collected-diagram.spec.d.ts → cli/scan-ai-session-fallback.spec.d.ts} +0 -0
  120. /package/dist/tests/unit/{discoveries/rescan-replaces-scan-records.spec.d.ts → export/export-ocsf.spec.d.ts} +0 -0
@@ -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",
@@ -102,5 +102,29 @@ export { piiSignalIdentity, rawHitIdentity, occurrenceIdentity, dataItemIdentity
102
102
  * field declaration a few lines below; span evidence through the annotation block.
103
103
  */
104
104
  export declare function javaAnnotationBlockStartLine(lines: readonly string[], fieldLineIndex: number): number;
105
+ /**
106
+ * A module path or URL path (`'../../services/email-service'`) or a prose message
107
+ * (`'Email not found.'`): it names a file or tells a person something, not a value.
108
+ * SQL, other strings and messages that interpolate a value (`"Logout failed for
109
+ * #{channel.email}."`) keep matching.
110
+ *
111
+ * A prose message starts with a capital, holds at least two whitespace characters and
112
+ * ends in `.`, `!` or `?`. The first two runs exclude whitespace, so the two `\s` are
113
+ * always the first two whitespace characters and each run has one way to match. Runs
114
+ * that also matched whitespace backtracked O(n^3) on a long capitalised string that is
115
+ * not prose (an inline SVG path `d="M1.5 2.5 ..."`). Matches on a single line are the
116
+ * same as before.
117
+ */
118
+ export declare const PATH_OR_PROSE_STRING: RegExp;
119
+ /**
120
+ * A whole import statement (`const mail = require('../mail');`, `import { isEmail } from
121
+ * 'validator';`, `from email.mime.text import MIMEText`, `require 'mail'`): its names are
122
+ * modules and bindings, not values.
123
+ *
124
+ * Whitespace runs never sit next to another run that also takes whitespace (`\s[^=]+`,
125
+ * `(?:\s*;)?`, `import\s(?:...)`): `from a import` followed by a long run of spaces
126
+ * backtracked O(n^3). Same matches as before.
127
+ */
128
+ export declare const IMPORT_LINE: RegExp;
105
129
  export declare function matchPiiSignalsInFile(input: MatchPiiSignalsFileInput, rules?: PiiSignalRule[]): PiiSignalHit[];
106
130
  export declare function matchPiiSignalsInFiles(files: MatchPiiSignalsFileInput[], rules?: PiiSignalRule[]): PiiSignalHit[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dataItemIdentity = exports.occurrenceIdentity = exports.rawHitIdentity = exports.piiSignalIdentity = void 0;
3
+ exports.IMPORT_LINE = exports.PATH_OR_PROSE_STRING = exports.dataItemIdentity = exports.occurrenceIdentity = exports.rawHitIdentity = exports.piiSignalIdentity = void 0;
4
4
  exports.javaAnnotationBlockStartLine = javaAnnotationBlockStartLine;
5
5
  exports.matchPiiSignalsInFile = matchPiiSignalsInFile;
6
6
  exports.matchPiiSignalsInFiles = matchPiiSignalsInFiles;
@@ -15,7 +15,9 @@ function ruleById(rules) {
15
15
  return new Map(rules.map((rule) => [rule.id, rule]));
16
16
  }
17
17
  function isJavaFieldDeclarationLine(line) {
18
- return /\b(?:private|protected)\s+[\w<>,\s\[\]]+\s+\w+\s*;/.test(line);
18
+ // Single `\s` around the type: the type class takes whitespace too, and `\s+` there
19
+ // backtracked O(n^3) on `private` followed by a long run of spaces. Same matches.
20
+ return /\b(?:private|protected)\s[\w<>,\s\[\]]+\s\w+\s*;/.test(line);
19
21
  }
20
22
  /**
21
23
  * Gold often anchors on the leading @Column line while token matching fires on the
@@ -98,8 +100,15 @@ const TRANSLATION_KEY = /(\b(?:I18n\.t|i18n\.t|translate|t|__|\$t)\(\s*)(['"`])[
98
100
  * (`'Email not found.'`): it names a file or tells a person something, not a value.
99
101
  * SQL, other strings and messages that interpolate a value (`"Logout failed for
100
102
  * #{channel.email}."`) keep matching.
103
+ *
104
+ * A prose message starts with a capital, holds at least two whitespace characters and
105
+ * ends in `.`, `!` or `?`. The first two runs exclude whitespace, so the two `\s` are
106
+ * always the first two whitespace characters and each run has one way to match. Runs
107
+ * that also matched whitespace backtracked O(n^3) on a long capitalised string that is
108
+ * not prose (an inline SVG path `d="M1.5 2.5 ..."`). Matches on a single line are the
109
+ * same as before.
101
110
  */
102
- const PATH_OR_PROSE_STRING = /(['"`])(?:[\w.@-]*\/[\w./@-]*|[A-Z](?:(?![$#]\{)[^'"`\n])*\s(?:(?![$#]\{)[^'"`\n])*\s(?:(?![$#]\{)[^'"`\n])*[.!?])\1/g;
111
+ exports.PATH_OR_PROSE_STRING = /(['"`])(?:[\w.@-]*\/[\w./@-]*|[A-Z](?:(?![$#]\{)[^'"`\s])*\s(?:(?![$#]\{)[^'"`\s])*\s(?:(?![$#]\{)[^'"`\n])*[.!?])\1/g;
103
112
  /**
104
113
  * A capitalized Email or Mail class reference (`Channel::Email`, `models.Email.findOne`,
105
114
  * `Email::Cleaner`): a model or module, not an address. Lowercase members (`user.email`)
@@ -111,8 +120,12 @@ const EMAIL_NAMESPACE = /\b(?:Email|Mail)(?=::)/g;
111
120
  * A whole import statement (`const mail = require('../mail');`, `import { isEmail } from
112
121
  * 'validator';`, `from email.mime.text import MIMEText`, `require 'mail'`): its names are
113
122
  * modules and bindings, not values.
123
+ *
124
+ * Whitespace runs never sit next to another run that also takes whitespace (`\s[^=]+`,
125
+ * `(?:\s*;)?`, `import\s(?:...)`): `from a import` followed by a long run of spaces
126
+ * backtracked O(n^3). Same matches as before.
114
127
  */
115
- const IMPORT_LINE = /^\s*(?:(?:const|let|var)\s+[^=]+=\s*require\(\s*(['"`])[^'"`]*\1\s*\)(?:\(\s*(['"`])[^'"`]*\2\s*\))?(?:\.\w+)*\s*;?|import\b[^'"`]*\bfrom\s*(['"`])[^'"`]*\3\s*;?|import\s*(['"`])[^'"`]*\4\s*;?|from\s+[\w.]+\s+import\s+[\w\s,()*]+|import\s+[\w.]+(?:\s+as\s+\w+)?|require(?:_relative)?\s+(['"])[^'"]*\5)\s*$/;
128
+ exports.IMPORT_LINE = /^\s*(?:(?:const|let|var)\s[^=]+=\s*require\(\s*(['"`])[^'"`]*\1\s*\)(?:\(\s*(['"`])[^'"`]*\2\s*\))?(?:\.\w+)*(?:\s*;)?|import\b[^'"`]*\bfrom\s*(['"`])[^'"`]*\3(?:\s*;)?|import\s*(['"`])[^'"`]*\4(?:\s*;)?|from\s+[\w.]+\s+import\s(?:[\w\s,()*]*[\w,()*]|\s)|import\s+[\w.]+(?:\s+as\s+\w+)?|require(?:_relative)?\s+(['"])[^'"]*\5)\s*$/;
116
129
  const NEVER = /(?!)/g;
117
130
  /** A Ruby predicate (`inbox.email?`, `mail?`) asks a yes/no question; it is not an address. */
118
131
  const EMAIL_PREDICATE = /(\.|\b)e?mails?\?(?!\?)/g;
@@ -125,9 +138,9 @@ function matchPiiSignalsInFile(input, rules = (0, pii_signal_rules_1.loadPiiSign
125
138
  for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
126
139
  // A translation key names a message, not a value: it is blanked before matching.
127
140
  const raw = lines[lineIndex] ?? "";
128
- const line = (IMPORT_LINE.test(raw) ? "" : raw)
141
+ const line = (exports.IMPORT_LINE.test(raw) ? "" : raw)
129
142
  .replace(TRANSLATION_KEY, '$1""')
130
- .replace(PATH_OR_PROSE_STRING, '""')
143
+ .replace(exports.PATH_OR_PROSE_STRING, '""')
131
144
  .replace(EMAIL_CLASS_REFERENCE, "$1Klass")
132
145
  .replace(EMAIL_NAMESPACE, "Klass")
133
146
  .replace(rubyFile ? EMAIL_PREDICATE : NEVER, "$1kind?");
@@ -89,7 +89,8 @@ function qualify(line, signalId) {
89
89
  // Also a function defined by assignment: `findOneByEmail = async (email) => ...`,
90
90
  // `sendEmail: async (to) => ...`, `x = function (...)`.
91
91
  const isFunctionName = (/^\s*(\(|:\s*(async\s+)?function\b)/.test(after) ||
92
- /^\s*[:=]\s*(async\s+)?(function\b|\([^)]*\)\s*(:\s*[^=]+)?=>|[A-Za-z_$][\w$]*\s*=>)/.test(after)) &&
92
+ // `:[^=]+` matches what `:\s*[^=]+` did (`[^=]` takes whitespace) in linear time.
93
+ /^\s*[:=]\s*(async\s+)?(function\b|\([^)]*\)\s*(:[^=]+)?=>|[A-Za-z_$][\w$]*\s*=>)/.test(after)) &&
93
94
  !assignsConcept;
94
95
  const words = identifierWords(identifier);
95
96
  // A getter named for whose value it returns keeps its qualifier:
@@ -130,7 +131,9 @@ function qualify(line, signalId) {
130
131
  // `const verificationEmail = user?.email ?? input.email` -> user. Only true locals;
131
132
  // `gift_card.used_by_email = user.email` stores a copy in another entity and keeps
132
133
  // its own name.
133
- const localCopy = new RegExp(`^\\s*(?:(?:const|let|var)\\s+)?([A-Za-z_]\\w*)\\s*(?::\\s*[\\w<>\\[\\]| ]+)?\\s*=\\s*(?:await\\s+)?(?:[\\w.]+\\s*\\?\\?\\s*)?([A-Za-z_]\\w*)\\s*(?:\\?\\.|\\.|\\[\\s*['"]|\\.get\\(\\s*['"])${conceptWords.map(escapeRegExp).join("_?")}\\b`, "i").exec(line);
134
+ // The type annotation's runs never meet another run that takes the same whitespace
135
+ // (`: ` followed by a long run of spaces backtracked O(n^3)); same matches and groups.
136
+ const localCopy = new RegExp(`^\\s*(?:(?:const|let|var)\\s+)?([A-Za-z_]\\w*)\\s*(?::(?:\\s*[\\w<>\\[\\]|](?:[\\w<>\\[\\]| ]*[\\w<>\\[\\]|])?|[^\\S ]* )\\s*)?=\\s*(?:await\\s+)?(?:[\\w.]+\\s*\\?\\?\\s*)?([A-Za-z_]\\w*)\\s*(?:\\?\\.|\\.|\\[\\s*['"]|\\.get\\(\\s*['"])${conceptWords.map(escapeRegExp).join("_?")}\\b`, "i").exec(line);
134
137
  if (localCopy && conceptWords.every((word) => identifierWords(localCopy[1]).includes(word))) {
135
138
  const source = /^users?$/i.test(localCopy[2])
136
139
  ? "user"
@@ -117,7 +117,9 @@ function isBareAddressFieldDeclaration(line, tokenStartIndex) {
117
117
  /\b(?:String|CharField|TextField|varchar|text)\s+address\b/i.test(line) ||
118
118
  /\baddress\s*=\s*models\./i.test(line) ||
119
119
  /\bprivate\s+\w+\s+address\s*;/.test(line) ||
120
- /\bvalidates(?:_\w+)*\s+:\w*address\b/i.test(line));
120
+ // `(?:_\w+)?` matches what `(?:_\w+)*` did (`_` is a word character) without
121
+ // exponential backtracking on `validates_a_a_a...`.
122
+ /\bvalidates(?:_\w+)?\s+:\w*address\b/i.test(line));
121
123
  }
122
124
  /** Extract identifier tokens from a source line (supports optional `$` prefix). */
123
125
  function extractLineIdentifierTokens(line) {
@@ -230,7 +232,8 @@ function resolveAliasRuleIdsForToken(token, line, tokenStartIndex, filePath) {
230
232
  // class, never a phone value; ALL_CAPS constants (`ATTENDEE_PHONE_NUMBER_FIELD`) still count.
231
233
  if (ruleId === "phone_number" &&
232
234
  (NOT_PHONE_LAST_WORD.has(splitCamelCaseParts(token).slice(-1)[0] ?? "") ||
233
- (/^[A-Z][A-Za-z0-9]*[a-z][A-Za-z0-9]*$/.test(token) && splitCamelCaseParts(token).length > 1))) {
235
+ // `[A-Z0-9]*` stops at the first lowercase letter: same matches, linear time.
236
+ (/^[A-Z][A-Z0-9]*[a-z][A-Za-z0-9]*$/.test(token) && splitCamelCaseParts(token).length > 1))) {
234
237
  continue;
235
238
  }
236
239
  // A multi-word name that starts with a flag or action word names a flag or a function
@@ -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:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataparade/cli",
3
- "version": "0.0.26",
3
+ "version": "0.0.29",
4
4
  "description": "dataPARADE CLI — scan codebases for privacy and security data flows",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -56,9 +56,9 @@
56
56
  "dependencies": {
57
57
  "@clack/prompts": "^1.8.1",
58
58
  "@sentry/node": "^10.38.0",
59
- "commander": "^12.1.0",
59
+ "commander": "^14.0.3",
60
60
  "dotenv": "^16.4.7",
61
- "langsmith": "^0.3.14",
61
+ "langsmith": "^0.10.13",
62
62
  "tree-sitter-wasms": "^0.1.13",
63
63
  "typescript": "^5.7.3",
64
64
  "web-tree-sitter": "0.25.10",
@@ -66,14 +66,14 @@
66
66
  "zod": "^4.3.5"
67
67
  },
68
68
  "devDependencies": {
69
- "@dataparade/scanner": "github:DataParade-io/scanner#0b1a31e7444acbf1e43d800e26a37746f11e7232",
69
+ "@dataparade/scanner": "github:DataParade-io/scanner#6a5a95897fe9ccd60230b0636f3a91b2e21a1ab1",
70
70
  "@eslint/js": "^9.18.0",
71
- "@types/jest": "^29.5.14",
71
+ "@types/jest": "^30.0.0",
72
72
  "@types/node": "^22.0.0",
73
73
  "eslint": "^9.18.0",
74
74
  "globals": "^15.14.0",
75
- "jest": "^29.7.0",
76
- "ts-jest": "^29.2.5",
75
+ "jest": "^30.5.2",
76
+ "ts-jest": "^29.4.6",
77
77
  "typescript-eslint": "^8.20.0"
78
78
  },
79
79
  "files": [
@@ -1,7 +0,0 @@
1
- import type { DiagramGraphJsonSchema } from "../core/schema/diagram-graph.schema";
2
- import type { A0DiscoveriesDocument } from "./contract/discoveries-document.schema";
3
- export interface CollectedDiagram {
4
- graph: DiagramGraphJsonSchema;
5
- d2: string;
6
- }
7
- export declare function projectCollectedDiscoveriesDiagram(document: A0DiscoveriesDocument): CollectedDiagram;