@dataparade/cli 0.0.31 → 0.0.33

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 (141) hide show
  1. package/README.md +56 -1
  2. package/dist/package.json +4 -3
  3. package/dist/src/ai-enrichment/fallbacks.js +12 -1
  4. package/dist/src/cli.js +50 -4
  5. package/dist/src/core/pipeline/omit-internal-implementation.js +13 -6
  6. package/dist/src/diff/register-diff-command.d.ts +4 -0
  7. package/dist/src/diff/register-diff-command.js +79 -0
  8. package/dist/src/diff/run-diff.d.ts +80 -0
  9. package/dist/src/diff/run-diff.js +206 -0
  10. package/dist/src/diff/upload-diff.d.ts +26 -0
  11. package/dist/src/diff/upload-diff.js +69 -0
  12. package/dist/src/facts/apply-answers.js +1 -1
  13. package/dist/src/facts/build-facts.d.ts +3 -1
  14. package/dist/src/facts/build-facts.js +10 -1
  15. package/dist/src/facts/identity.d.ts +27 -0
  16. package/dist/src/facts/identity.js +203 -0
  17. package/dist/src/facts/io.d.ts +2 -0
  18. package/dist/src/facts/io.js +7 -0
  19. package/dist/src/facts/scan-stamps.d.ts +55 -0
  20. package/dist/src/facts/scan-stamps.js +165 -0
  21. package/dist/src/facts/schema.d.ts +243 -7
  22. package/dist/src/facts/schema.js +71 -1
  23. package/dist/src/kb/answer-fingerprint.d.ts +44 -0
  24. package/dist/src/kb/answer-fingerprint.js +173 -0
  25. package/dist/src/kb/brief.d.ts +8 -1
  26. package/dist/src/kb/brief.js +18 -2
  27. package/dist/src/kb/land.js +3 -0
  28. package/dist/src/kb/register-kb-commands.js +7 -1
  29. package/dist/src/output/git-context.d.ts +25 -0
  30. package/dist/src/output/git-context.js +122 -0
  31. package/dist/src/output/scan-output-excludes.js +5 -1
  32. package/dist/src/output/write-scan-knowledge.d.ts +2 -0
  33. package/dist/src/output/write-scan-knowledge.js +1 -0
  34. package/dist/src/platform-api/dataparade-app-base-url.d.ts +8 -4
  35. package/dist/src/platform-api/dataparade-app-base-url.js +10 -5
  36. package/dist/src/platform-api/upload-client.d.ts +1 -1
  37. package/dist/src/platform-api/upload-client.js +32 -1
  38. package/dist/src/platform-api/upload.types.d.ts +55 -0
  39. package/dist/src/sensitive-scan/process.d.ts +5 -0
  40. package/dist/src/sensitive-scan/process.js +48 -0
  41. package/dist/src/sensitive-scan/project.d.ts +12 -0
  42. package/dist/src/sensitive-scan/project.js +177 -0
  43. package/dist/src/sensitive-scan/report.d.ts +50 -0
  44. package/dist/src/sensitive-scan/report.js +32 -0
  45. package/dist/src/sensitive-scan/sessions.d.ts +2 -0
  46. package/dist/src/sensitive-scan/sessions.js +120 -0
  47. package/dist/src/ui/scan-progress-renderer.d.ts +1 -0
  48. package/dist/src/ui/scan-progress-renderer.js +8 -0
  49. package/dist/src/upload/build-preview-url.d.ts +2 -2
  50. package/dist/src/upload/build-preview-url.js +4 -4
  51. package/dist/src/upload/run-upload.js +6 -2
  52. package/dist/src/upload/types.d.ts +2 -0
  53. package/dist/tests/unit/ai-enrichment/fallbacks.spec.js +30 -0
  54. package/dist/tests/unit/core/omit-internal-implementation.spec.js +21 -0
  55. package/dist/tests/unit/diff/run-diff.spec.d.ts +1 -0
  56. package/dist/tests/unit/diff/run-diff.spec.js +189 -0
  57. package/dist/tests/unit/diff/upload-diff.spec.d.ts +1 -0
  58. package/dist/tests/unit/diff/upload-diff.spec.js +81 -0
  59. package/dist/tests/unit/facts/apply-answers.spec.js +1 -1
  60. package/dist/tests/unit/facts/build-facts.spec.js +67 -1
  61. package/dist/tests/unit/facts/identity.spec.d.ts +1 -0
  62. package/dist/tests/unit/facts/identity.spec.js +148 -0
  63. package/dist/tests/unit/facts/scan-stamps.spec.d.ts +1 -0
  64. package/dist/tests/unit/facts/scan-stamps.spec.js +95 -0
  65. package/dist/tests/unit/kb/answer-fingerprint.spec.d.ts +1 -0
  66. package/dist/tests/unit/kb/answer-fingerprint.spec.js +157 -0
  67. package/dist/tests/unit/kb/kb-interview-loop.spec.js +16 -0
  68. package/dist/tests/unit/output/git-context.spec.d.ts +1 -0
  69. package/dist/tests/unit/output/git-context.spec.js +98 -0
  70. package/dist/tests/unit/platform-api/dataparade-app-base-url.spec.js +9 -0
  71. package/dist/tests/unit/platform-api/upload-client.spec.js +101 -1
  72. package/dist/tests/unit/sensitive-scan/project.spec.d.ts +1 -0
  73. package/dist/tests/unit/sensitive-scan/project.spec.js +98 -0
  74. package/dist/tests/unit/upload/build-preview-url.spec.js +4 -0
  75. package/dist/tests/unit/upload/collect-scan-sidecars.spec.js +1 -0
  76. package/dist/tests/unit/upload/run-upload.spec.js +32 -0
  77. package/dist/vendor/kb-compare/dist/src/canonical.d.ts +80 -0
  78. package/dist/vendor/kb-compare/dist/src/canonical.js +119 -0
  79. package/dist/vendor/kb-compare/dist/src/change-set.d.ts +144 -0
  80. package/dist/vendor/kb-compare/dist/src/change-set.js +80 -0
  81. package/dist/vendor/kb-compare/dist/src/comparable.d.ts +23 -0
  82. package/dist/vendor/kb-compare/dist/src/comparable.js +48 -0
  83. package/dist/vendor/kb-compare/dist/src/compare.d.ts +52 -0
  84. package/dist/vendor/kb-compare/dist/src/compare.js +370 -0
  85. package/dist/vendor/kb-compare/dist/src/fingerprint.d.ts +40 -0
  86. package/dist/vendor/kb-compare/dist/src/fingerprint.js +88 -0
  87. package/dist/vendor/kb-compare/dist/src/index.d.ts +15 -0
  88. package/dist/vendor/kb-compare/dist/src/index.js +34 -0
  89. package/dist/vendor/kb-compare/dist/src/input.d.ts +128 -0
  90. package/dist/vendor/kb-compare/dist/src/input.js +75 -0
  91. package/dist/vendor/kb-compare/dist/src/slot-rules.d.ts +69 -0
  92. package/dist/vendor/kb-compare/dist/src/slot-rules.js +203 -0
  93. package/dist/vendor/kb-compare/dist/src/summary.d.ts +3 -0
  94. package/dist/vendor/kb-compare/dist/src/summary.js +47 -0
  95. package/dist/vendor/kb-compare/package.json +6 -0
  96. package/dist/vendor/scanner/dist/src/analyzers/python/python-detection-config.d.ts +11 -0
  97. package/dist/vendor/scanner/dist/src/analyzers/python/python-detection-config.js +2 -0
  98. package/dist/vendor/scanner/dist/src/analyzers/registry.d.ts +2 -0
  99. package/dist/vendor/scanner/dist/src/analyzers/registry.js +3 -2
  100. package/dist/vendor/scanner/dist/src/analyzers/typescript/typescript-detection-config.d.ts +17 -0
  101. package/dist/vendor/scanner/dist/src/analyzers/typescript/typescript-detection-config.js +11 -0
  102. package/dist/vendor/scanner/dist/src/classifier/application-injection.js +5 -0
  103. package/dist/vendor/scanner/dist/src/classifier/component-factory.js +33 -3
  104. package/dist/vendor/scanner/dist/src/classifier/enhance.js +14 -0
  105. package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.d.ts +8 -0
  106. package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.js +43 -2
  107. package/dist/vendor/scanner/dist/src/classifier/postprocessing.js +4 -1
  108. package/dist/vendor/scanner/dist/src/config/third-party-detection-config.d.ts +41 -0
  109. package/dist/vendor/scanner/dist/src/config/third-party-detection-config.js +65 -1
  110. package/dist/vendor/scanner/dist/src/core/pipeline/stable-component-ids.d.ts +8 -0
  111. package/dist/vendor/scanner/dist/src/core/pipeline/stable-component-ids.js +11 -1
  112. package/dist/vendor/scanner/dist/src/core/pipeline/structural-scan.js +2 -0
  113. package/dist/vendor/scanner/dist/src/eval/canonical/scanner/components.d.ts +5 -0
  114. package/dist/vendor/scanner/dist/src/eval/canonical/scanner/components.js +10 -2
  115. package/dist/vendor/scanner/dist/src/eval/canonical/scanner/data-flows.js +4 -4
  116. package/dist/vendor/scanner/dist/src/index.d.ts +1 -1
  117. package/dist/vendor/scanner/dist/src/index.js +4 -2
  118. package/dist/vendor/scanner/dist/src/patterns/config.js +7 -1
  119. package/dist/vendor/scanner/dist/src/patterns/detectors/git-remote-owner.d.ts +14 -0
  120. package/dist/vendor/scanner/dist/src/patterns/detectors/git-remote-owner.js +108 -0
  121. package/dist/vendor/scanner/dist/src/patterns/detectors/python-outbound-http.d.ts +93 -0
  122. package/dist/vendor/scanner/dist/src/patterns/detectors/python-outbound-http.js +1206 -0
  123. package/dist/vendor/scanner/dist/src/patterns/detectors/python-source.d.ts +180 -0
  124. package/dist/vendor/scanner/dist/src/patterns/detectors/python-source.js +1022 -0
  125. package/dist/vendor/scanner/dist/src/patterns/detectors/python.d.ts +6 -0
  126. package/dist/vendor/scanner/dist/src/patterns/detectors/python.js +49 -1
  127. package/dist/vendor/scanner/dist/src/patterns/detectors/repo-declared-domains.d.ts +2 -0
  128. package/dist/vendor/scanner/dist/src/patterns/detectors/repo-declared-domains.js +80 -0
  129. package/dist/vendor/scanner/dist/src/patterns/detectors/source-module-index.d.ts +23 -0
  130. package/dist/vendor/scanner/dist/src/patterns/detectors/source-module-index.js +145 -0
  131. package/dist/vendor/scanner/dist/src/patterns/detectors/typescript-outbound-http.d.ts +30 -0
  132. package/dist/vendor/scanner/dist/src/patterns/detectors/typescript-outbound-http.js +575 -0
  133. package/dist/vendor/scanner/dist/src/patterns/detectors/typescript.js +12 -0
  134. package/dist/vendor/scanner/dist/src/patterns/engine.js +6 -1
  135. package/dist/vendor/scanner/package.json +3 -1
  136. package/dist/vendor/scanner/patterns/classifier/third-party.classifier.yaml +198 -0
  137. package/dist/vendor/scanner/patterns/component-taxonomy.yaml +1 -1
  138. package/dist/vendor/scanner/patterns/python.patterns.yaml +10 -0
  139. package/dist/vendor/scanner/patterns/third-party.patterns.yaml +271 -0
  140. package/dist/vendor/scanner/patterns/typescript.patterns.yaml +21 -0
  141. package/package.json +4 -3
package/README.md CHANGED
@@ -42,6 +42,61 @@ dataparade scan path/to/your/project --output scan-my-project-dataflow.json
42
42
 
43
43
  List commands and options: `dataparade --help` and `dataparade scan --help`.
44
44
 
45
+ ## Sensitive information scans
46
+
47
+ `dataparade scan <path>` runs LeftBlock alongside the data-flow scan. Install
48
+ [Gitleaks](https://github.com/gitleaks/gitleaks#installing) and a
49
+ [LeftBlock](https://github.com/DataParade-io/LeftBlock) version with
50
+ `leftblock scan --format report` on your `PATH`. To use a separate Python
51
+ environment, set `DATAPARADE_LEFTBLOCK` to its LeftBlock executable.
52
+
53
+ The integration was tested with Gitleaks 8.30.1. For a development build,
54
+ install the tested LeftBlock revision in a separate environment so it does
55
+ not replace the LeftBlock executable used by Git hooks:
56
+
57
+ ```sh
58
+ python3 -m venv ~/.local/share/dataparade/leftblock
59
+ ~/.local/share/dataparade/leftblock/bin/pip install \
60
+ 'leftblock @ git+https://github.com/DataParade-io/LeftBlock.git@1b87eeb0f3a2cc142cac25046a3fb0ddd57808cc'
61
+ export DATAPARADE_LEFTBLOCK="$HOME/.local/share/dataparade/leftblock/bin/leftblock"
62
+ ```
63
+
64
+ The local `sensitive-findings.json` file reports findings and the status of
65
+ each pass. DataParade does not upload this file. The scan does not sanitize the
66
+ existing data-flow artifacts. Findings do not change the project scan's exit
67
+ code. If the rule scan cannot run, DataParade warns and continues.
68
+
69
+ LeftBlock scans UTF-8 project files within the scan path, including supported
70
+ source, configuration, and documentation files. The project scan honors
71
+ `--exclude`, the scan configuration, and repository ignore rules. It skips
72
+ symbolic links, hidden directories, generated files, dependencies, output files,
73
+ and the scanner's default exclusions, including `.env` files. The report records
74
+ the 1 MiB file and 64 MiB scan limits if they affect coverage.
75
+
76
+ Both sensitive information scans try Privacy Filter only when its files and
77
+ dependencies are available locally. Follow LeftBlock's model setup instructions
78
+ to prepare it. If the model cannot run, DataParade warns and keeps the rule
79
+ findings. Use `--privacy-filter off` for a rules-only scan. Use
80
+ `--no-sensitive-scan` on the project command to skip both passes.
81
+
82
+ Install a [BotSpy](https://github.com/DataParade-io/BotSpy) version with
83
+ `botspy privacy-audit` to scan coding sessions. DataParade uses `botspy` from
84
+ `PATH`, or the executable set in `DATAPARADE_BOTSPY`.
85
+
86
+ ```sh
87
+ dataparade sessions scan # this project, last 7 days
88
+ dataparade sessions scan ./service --source claude_code --since 24h
89
+ dataparade sessions scan --source codex --session SESSION_ID
90
+ dataparade sessions scan --all --since 24h --format json --fail-on-findings
91
+ ```
92
+
93
+ The session scan reads local agent histories. It does not create a transcript
94
+ index or send session data to a remote service. It reports source coverage and
95
+ finding locations without matched values. Output goes to stdout and warnings go
96
+ to stderr. A completed audit exits 0, or 1 with `--fail-on-findings` when it finds
97
+ sensitive information. An incomplete audit exits 2. An unavailable model alone
98
+ does not change the exit code.
99
+
45
100
  ---
46
101
 
47
102
  ## Upload to dashboard
@@ -75,7 +130,7 @@ By default, a scan writes these files to `./.dataparade/`:
75
130
  | `graphify.json` | The code-structure graph from [Graphify](https://github.com/Graphify-Labs/graphify), when it is installed. |
76
131
  | `answers.json` | People's decisions (interview answers, reviews). A scan never writes or changes it. |
77
132
 
78
- `-o` / `--output` is the path of `dataflow.json`; the other files go in the same folder. Scans skip this folder, so rescanning does not read old output. Commit `answers.json` with your code; the rest can be regenerated.
133
+ `-o` / `--output` is the path of `dataflow.json`; the other files go in the same folder. Scans skip this folder, so rescanning does not read old output. Committing `.dataparade/` is optional: DataParade keeps uploaded scans and answers by commit. The scan files can be regenerated; `answers.json` holds people's decisions, so keep it if you do not upload.
79
134
 
80
135
  Graphify's cache lives outside the output, in `~/.cache/dataparade/graphify/` (set `DATAPARADE_CACHE_DIR` to move it).
81
136
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataparade/cli",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "dataPARADE CLI — scan codebases for privacy and security data flows",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -45,11 +45,12 @@
45
45
  },
46
46
  "scripts": {
47
47
  "ensure-scanner": "node scripts/ensure-scanner-built.mjs",
48
- "build": "node scripts/ensure-scanner-built.mjs && pnpm exec tsc -p tsconfig.json && node scripts/vendor-scanner.mjs",
48
+ "build": "node scripts/ensure-scanner-built.mjs && pnpm --dir ../packages/kb-compare build && pnpm exec tsc -p tsconfig.json && node scripts/vendor-scanner.mjs && node scripts/vendor-kb-compare.mjs",
49
49
  "prepublishOnly": "pnpm run build && pnpm run test",
50
50
  "lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
51
51
  "pretest": "pnpm run build",
52
52
  "test": "jest",
53
+ "check:determinism": "node scripts/check-determinism.mjs",
53
54
  "scan": "node dist/bin/cli.js scan",
54
55
  "eval:models": "pnpm exec node dist/src/evals/run-model-matrix.js"
55
56
  },
@@ -66,7 +67,7 @@
66
67
  "zod": "^4.3.5"
67
68
  },
68
69
  "devDependencies": {
69
- "@dataparade/scanner": "github:DataParade-io/scanner#dc6104f9108cbb3647eb595861e73090f3cc257a",
70
+ "@dataparade/scanner": "github:DataParade-io/scanner#175f7366ab54b8bf8c56998a21198d9aaa6858e0",
70
71
  "@eslint/js": "^9.18.0",
71
72
  "@types/jest": "^30.0.0",
72
73
  "@types/node": "^22.0.0",
@@ -213,6 +213,16 @@ function componentMatchesProvider(component, keys) {
213
213
  const corpus = new Set([name, ...serviceNameValues]);
214
214
  return keys.some((k) => corpus.has(k) || name.includes(k));
215
215
  }
216
+ /**
217
+ * A product of the provider (Google Docs, Google Analytics) has its own
218
+ * serviceName that is not a provider key. It keeps its name and stays out of
219
+ * the provider topology, although its name contains the provider key.
220
+ */
221
+ function isProviderProduct(component, keys) {
222
+ const serviceNameValues = getStringValues(component.properties?.serviceName);
223
+ return (serviceNameValues.length > 0 &&
224
+ !serviceNameValues.some((value) => keys.includes(value)));
225
+ }
216
226
  function isManagedResourceComponent(component, managedResource, fallbackPolicy) {
217
227
  if (!(component.type === 'asset' && component.subType === 'database'))
218
228
  return false;
@@ -633,7 +643,8 @@ function applyDeterministicInferenceFallbacks(components, flows) {
633
643
  const providerRules = (0, provider_topology_rules_1.loadProviderTopologyRules)();
634
644
  for (const rule of providerRules) {
635
645
  const providers = nextComponents.filter((component) => component.type === 'third_party' &&
636
- componentMatchesProvider(component, rule.providerMatchKeys));
646
+ componentMatchesProvider(component, rule.providerMatchKeys) &&
647
+ !isProviderProduct(component, rule.providerMatchKeys));
637
648
  if (providers.length === 0)
638
649
  continue;
639
650
  for (const provider of providers) {
package/dist/src/cli.js CHANGED
@@ -44,9 +44,12 @@ const commander_1 = require("commander");
44
44
  const crypto_1 = require("crypto");
45
45
  const package_json_1 = __importDefault(require("../package.json"));
46
46
  const json_1 = require("./output/json");
47
+ const git_context_1 = require("./output/git-context");
47
48
  const write_scan_knowledge_1 = require("./output/write-scan-knowledge");
48
49
  const layout_1 = require("./facts/layout");
49
50
  const register_kb_commands_1 = require("./kb/register-kb-commands");
51
+ const register_diff_command_1 = require("./diff/register-diff-command");
52
+ const scan_stamps_1 = require("./facts/scan-stamps");
50
53
  const register_export_commands_1 = require("./export/register-export-commands");
51
54
  const scan_output_excludes_1 = require("./output/scan-output-excludes");
52
55
  const dataflow_wrapper_schema_1 = require("./core/schema/dataflow-wrapper.schema");
@@ -66,6 +69,14 @@ const scan_config_schema_1 = require("./core/schema/scan-config.schema");
66
69
  const scanner_1 = require("../vendor/scanner/dist/src/index.js");
67
70
  const scan_interrupt_handlers_1 = require("./cli/scan-interrupt-handlers");
68
71
  const scan_progress_renderer_1 = require("./ui/scan-progress-renderer");
72
+ const project_1 = require("./sensitive-scan/project");
73
+ const sessions_1 = require("./sensitive-scan/sessions");
74
+ /** The full scanner commit the CLI pins (devDependency `github:...#<sha>`). */
75
+ function scannerCommitFromPackage() {
76
+ const scannerPackage = ['@dataparade', 'scanner'].join('/');
77
+ const spec = package_json_1.default.devDependencies?.[scannerPackage];
78
+ return spec?.split('#')[1] ?? 'unknown';
79
+ }
69
80
  /** The scanner is vendored into the CLI; its version is the commit the CLI depends on. */
70
81
  function scannerVersionFromPackage() {
71
82
  // Built from parts: the vendor step rewrites the scanner's package name in string literals.
@@ -160,6 +171,9 @@ function createProgram() {
160
171
  .description('Scan a directory (or a single supported source file) for data flow components')
161
172
  .option('-o, --output <file>', `Write dataflow.json to the given file; facts.json, data-items/ and graphify.json go next to it (default: ./${layout_1.DEFAULT_DATAFLOW_OUTPUT})`)
162
173
  .option('--exclude <pattern...>', 'One or more glob patterns to exclude from scanning')
174
+ .option('--no-sensitive-scan', 'Skip the local LeftBlock rules and Privacy Filter')
175
+ .addOption(new commander_1.Option('--privacy-filter <mode>', 'Use the local Privacy Filter when available')
176
+ .choices(['auto', 'off']).default('auto'))
163
177
  .option('--minimum-confidence <number>', 'Minimum confidence (0-1) for including detections')
164
178
  .option('--language <language...>', 'Limit scanning to specific languages (e.g. typescript, javascript, python, go, java, kotlin, cpp, csharp, terraform)')
165
179
  .option('--project-name <name>', 'Override the inferred project name used for the application asset')
@@ -304,6 +318,10 @@ function createProgram() {
304
318
  process.exitCode = 2;
305
319
  return;
306
320
  }
321
+ parsedGitContext ??=
322
+ (0, git_context_1.detectGitContext)(scanEntry.scanRootDir) ?? undefined;
323
+ // Read before the scan writes anything, so its own output never counts as a change (DATAP-876).
324
+ const gitStamps = (0, scan_stamps_1.readGitStamps)(scanEntry.scanRootDir, path_1.default.dirname(path_1.default.resolve(process.cwd(), options.output ?? layout_1.DEFAULT_DATAFLOW_OUTPUT)), parsedGitContext?.commitSha);
307
325
  const [{ createDefaultScanConfiguration }, { runScanPipeline }, { buildDiagramGraphFromScanResult },] = await Promise.all([
308
326
  Promise.resolve().then(() => __importStar(require('./core/pipeline/orchestrator'))),
309
327
  Promise.resolve().then(() => __importStar(require('./core/pipeline/scan-pipeline'))),
@@ -323,11 +341,9 @@ function createProgram() {
323
341
  // Technical meters, shown as one block after the scan (TTY) or
324
342
  // printed as before (non-TTY).
325
343
  const technicalLines = [];
344
+ const outputExcludes = (0, scan_output_excludes_1.scanOutputExcludes)(resolvedScanRoot, path_1.default.resolve(process.cwd(), options.output ?? layout_1.DEFAULT_DATAFLOW_OUTPUT));
326
345
  const flags = {
327
- exclude: [
328
- ...(options.exclude ?? []),
329
- ...(0, scan_output_excludes_1.scanOutputExcludes)(resolvedScanRoot, path_1.default.resolve(process.cwd(), options.output ?? layout_1.DEFAULT_DATAFLOW_OUTPUT)),
330
- ],
346
+ exclude: [...(options.exclude ?? []), ...outputExcludes],
331
347
  minimumConfidence: typeof options.minimumConfidence === 'string'
332
348
  ? Number(options.minimumConfidence)
333
349
  : undefined,
@@ -636,7 +652,29 @@ function createProgram() {
636
652
  projectName: resolvedProjectName,
637
653
  cliVersion: package_json_1.default.version,
638
654
  scannerVersion: scannerVersionFromPackage(),
655
+ stamps: (0, scan_stamps_1.buildScanStamps)({
656
+ cliVersion: package_json_1.default.version,
657
+ scanner: (0, scan_stamps_1.scannerBuildInfo)((0, scan_stamps_1.findCliPackageRoot)(__dirname), scannerCommitFromPackage()),
658
+ // Where the output goes is not a setting of the scan (DATAP-876).
659
+ config: { ...config, excludePaths: config.excludePaths?.filter((p) => !outputExcludes.includes(p)) },
660
+ aiInference: config.enableAiInference === true,
661
+ structureGraph: Boolean(knowledge.result.structureGraph),
662
+ git: gitStamps,
663
+ }),
639
664
  });
665
+ if (options.sensitiveScan !== false) {
666
+ ui.sensitiveScanMessage('Scanning for sensitive information with LeftBlock');
667
+ }
668
+ const sensitiveFindings = await (0, project_1.writeProjectSensitiveScan)(dataflowOutputPath, {
669
+ root: scanEntry.scanRootDir,
670
+ target: scanEntry.ingestTarget,
671
+ excludes: config.excludePaths ?? [],
672
+ modelMode: options.privacyFilter,
673
+ enabled: options.sensitiveScan !== false,
674
+ }, message => ui.warn(message));
675
+ if (sensitiveFindings !== undefined) {
676
+ ui.sensitiveScanMessage(`LeftBlock reported ${sensitiveFindings} sensitive information finding(s).`);
677
+ }
640
678
  // Friendly TTY/plain progress line (additive).
641
679
  ui.onWroteDataflow(dataflowOutputPath);
642
680
  // Machine line for scripts / CI (non-TTY). The friendly TTY UI
@@ -666,6 +704,7 @@ function createProgram() {
666
704
  cliUsageSessionId: usageSessionId,
667
705
  command: 'scan',
668
706
  files,
707
+ repositoryDir: scanEntry.scanRootDir,
669
708
  quiet: friendlyTty,
670
709
  });
671
710
  if (uploadResult.previewUrl) {
@@ -878,6 +917,7 @@ function createProgram() {
878
917
  cliUsageSessionId: usageSessionId,
879
918
  command: 'upload',
880
919
  files,
920
+ repositoryDir: path_1.default.dirname(filePath),
881
921
  });
882
922
  }
883
923
  catch (err) {
@@ -922,7 +962,13 @@ function createProgram() {
922
962
  }
923
963
  });
924
964
  (0, register_kb_commands_1.registerKbCommands)(program);
965
+ // The scan cache of `diff` is keyed by these stamps (DATAP-878).
966
+ (0, register_diff_command_1.registerDiffCommand)(program, () => ({
967
+ cliVersion: package_json_1.default.version,
968
+ ...(0, scan_stamps_1.scannerBuildInfo)((0, scan_stamps_1.findCliPackageRoot)(__dirname), scannerCommitFromPackage()),
969
+ }));
925
970
  (0, register_export_commands_1.registerExportCommands)(program);
971
+ (0, sessions_1.registerSessionScan)(program);
926
972
  return program;
927
973
  }
928
974
  async function run(argv) {
@@ -85,14 +85,21 @@ function stringProp(component, key) {
85
85
  const value = component.properties?.[key];
86
86
  return typeof value === 'string' ? value : '';
87
87
  }
88
- function hasPublicUrl(component) {
89
- const url = stringProp(component, 'url') ||
90
- (/^https?:\/\//i.test(component.name) ? component.name : '');
88
+ function isPublicUrl(url) {
91
89
  if (!/^https?:\/\//i.test(url))
92
90
  return false;
93
- if (/\$\{|process\.env|localhost|127\.0\.0\.1/i.test(url))
94
- return false;
95
- return true;
91
+ return !/\$\{|process\.env|localhost|127\.0\.0\.1/i.test(url);
92
+ }
93
+ /** A literal URL or a resolved `host` (e.g. a Cloud Run service) names a real destination. */
94
+ function hasPublicUrl(component) {
95
+ const raw = component.properties?.url;
96
+ const urls = (Array.isArray(raw) ? raw : [raw]).filter((value) => typeof value === 'string');
97
+ if (/^https?:\/\//i.test(component.name))
98
+ urls.push(component.name);
99
+ const host = stringProp(component, 'host');
100
+ if (host)
101
+ urls.push(`https://${host}`);
102
+ return urls.some(isPublicUrl);
96
103
  }
97
104
  function isBareHttpTransportNode(component) {
98
105
  if (component.properties?.sourceContext === 'dependency_manifest')
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import { type ToolStamps } from "./run-diff";
3
+ /** Hidden for now (DATAP-852): compares two Git revisions of one repository. */
4
+ export declare function registerDiffCommand(program: Command, tools: () => ToolStamps): void;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.registerDiffCommand = registerDiffCommand;
7
+ const child_process_1 = require("child_process");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const kb_compare_1 = require("../../vendor/kb-compare/dist/src/index.js");
11
+ const scan_env_1 = require("../config/scan-env");
12
+ const run_diff_1 = require("./run-diff");
13
+ const upload_diff_1 = require("./upload-diff");
14
+ /** Scans a folder by running this CLI's own `scan` command, with AI off and no upload. */
15
+ function scanWithThisCli() {
16
+ const entry = process.argv[1];
17
+ return (dir, outDir) => {
18
+ try {
19
+ (0, child_process_1.execFileSync)(process.execPath, [entry, "scan", dir, "--no-ai-inference", "-o", path_1.default.join(outDir, "dataflow.json")], {
20
+ env: { ...process.env, DATAPARADE_SKIP_AUTO_UPLOAD: "1", SCAN_AI_INFERENCE: "false" },
21
+ stdio: ["ignore", "ignore", "pipe"],
22
+ maxBuffer: 64 * 1024 * 1024,
23
+ });
24
+ return JSON.parse(fs_1.default.readFileSync(path_1.default.join(outDir, "facts.json"), "utf8"));
25
+ }
26
+ catch (error) {
27
+ const stderr = error.stderr?.toString().trim();
28
+ throw new run_diff_1.DiffError("SCAN_FAILED", `The scan of ${dir} failed${stderr ? `:\n${stderr.split("\n").slice(-5).join("\n")}` : "."}`);
29
+ }
30
+ };
31
+ }
32
+ /** Hidden for now (DATAP-852): compares two Git revisions of one repository. */
33
+ function registerDiffCommand(program, tools) {
34
+ program
35
+ .command("diff <repo> <base> <head>", { hidden: true })
36
+ .description("Compare two Git revisions of a repository and write the change set (AI off)")
37
+ .option("-o, --output <dir>", "Folder for change-set.json, summary.txt and renames.json", "dataparade-diff")
38
+ .option("--no-cache", "Scan both revisions again instead of reusing cached scans")
39
+ .option("--upload", "Upload both scans, the rename map and the root commit, so the backend compares them (needs a workspace API key)")
40
+ .option("--workspace-api-key <key>", "DataParade workspace API key for --upload (env: DATAPARADE_WORKSPACE_API_KEY)")
41
+ .action(async (repo, base, head, options) => {
42
+ const apiKey = options.workspaceApiKey?.trim() || (0, scan_env_1.resolveWorkspaceApiKey)(process.env);
43
+ if (options.upload && !apiKey) {
44
+ console.error("--upload needs a workspace API key: pass --workspace-api-key or set DATAPARADE_WORKSPACE_API_KEY.");
45
+ process.exitCode = 1;
46
+ return;
47
+ }
48
+ try {
49
+ const result = (0, run_diff_1.runDiff)({
50
+ repo,
51
+ base,
52
+ head,
53
+ outputDir: path_1.default.resolve(options.output),
54
+ scan: scanWithThisCli(),
55
+ tools: tools(),
56
+ cacheDir: options.cache ? (0, run_diff_1.defaultCacheDir)() : null,
57
+ keepScans: Boolean(options.upload),
58
+ log: (line) => console.error(line),
59
+ });
60
+ console.log(`${result.baseSha.slice(0, 8)}..${result.headSha.slice(0, 8)}`);
61
+ console.log(result.summary);
62
+ console.log(`\nWrote ${result.files.changeSet}`);
63
+ if (options.upload) {
64
+ const uploaded = await (0, upload_diff_1.uploadDiffScans)({ apiKey: apiKey, repo, result, log: (line) => console.error(line) });
65
+ console.log((0, upload_diff_1.describeUploadedComparison)(uploaded));
66
+ }
67
+ }
68
+ catch (error) {
69
+ if (error instanceof kb_compare_1.ComparisonRefused) {
70
+ // DATAP-877: the two scans cannot be compared; say why, with the reason code.
71
+ console.error(`Cannot compare these scans (${error.reason}): ${error.message}`);
72
+ process.exitCode = 3;
73
+ return;
74
+ }
75
+ console.error(error instanceof Error ? error.message : String(error));
76
+ process.exitCode = error instanceof run_diff_1.DiffError && error.code === "DIRTY_TREE" ? 2 : 1;
77
+ }
78
+ });
79
+ }
@@ -0,0 +1,80 @@
1
+ import { type ChangeSet } from "../../vendor/kb-compare/dist/src/index.js";
2
+ /**
3
+ * `dataparade diff <repo> <base> <head>` (DATAP-852): scans two Git revisions of one repository
4
+ * and writes the change set between them. AI is off and nothing is uploaded.
5
+ *
6
+ * - Refuses a working tree with changes that are not committed.
7
+ * - Exports each revision with `git archive` into a temporary folder named after the repository,
8
+ * so the user's checkout is never touched.
9
+ * - Scans both revisions with the head's `dataparade.config.json`.
10
+ * - Reuses a cached scan only when it was made from the same commit and configuration by the same
11
+ * CLI, scanner and pattern catalog (DATAP-878); the cached scan's own stamps are checked too.
12
+ * - Writes `change-set.json`, `summary.txt` and `renames.json` (rename map and root commit).
13
+ * - With `keepScans` (`--upload`, DATAP-886), keeps each revision's whole scan output in
14
+ * `base/` and `head/`, with the commit, root commit and a clean tree in its facts.json stamps:
15
+ * the scan ran on a `git archive` export, which has no .git to read them from.
16
+ */
17
+ export declare class DiffError extends Error {
18
+ readonly code: "NOT_A_REPO" | "DIRTY_TREE" | "UNKNOWN_REVISION" | "SCAN_FAILED";
19
+ constructor(code: "NOT_A_REPO" | "DIRTY_TREE" | "UNKNOWN_REVISION" | "SCAN_FAILED", message: string);
20
+ }
21
+ export declare const CONFIG_FILE = "dataparade.config.json";
22
+ export interface Rename {
23
+ from: string;
24
+ to: string;
25
+ similarity: number;
26
+ }
27
+ /** Scans `dir`, writes the scan output (dataflow.json, facts.json, ...) into `outDir`, and returns its facts.json, parsed. */
28
+ export type ScanFn = (dir: string, outDir: string) => unknown;
29
+ /** The scan stamps that describe the tools (DATAP-876). */
30
+ export interface ToolStamps {
31
+ cliVersion: string;
32
+ scannerCommit: string;
33
+ catalogHash: string;
34
+ }
35
+ /** True when a scan's stamps say it was made by these tools. Scans without stamps never match. */
36
+ export declare function madeBy(facts: unknown, tools: ToolStamps): boolean;
37
+ export interface RunDiffOptions {
38
+ repo: string;
39
+ base: string;
40
+ head: string;
41
+ /** Folder for change-set.json, summary.txt and renames.json. Created if missing. */
42
+ outputDir: string;
43
+ scan: ScanFn;
44
+ /** The tools that make the scans: part of the cache key, and checked against a cached scan's stamps. */
45
+ tools: ToolStamps;
46
+ /** Scan cache folder; scans are not cached when null. */
47
+ cacheDir: string | null;
48
+ /** Keep each revision's whole scan output in `<outputDir>/base` and `<outputDir>/head`, for upload. */
49
+ keepScans?: boolean;
50
+ log?: (line: string) => void;
51
+ }
52
+ export interface RunDiffResult {
53
+ changeSet: ChangeSet;
54
+ summary: string;
55
+ baseSha: string;
56
+ headSha: string;
57
+ rootCommit: string;
58
+ renames: Rename[];
59
+ files: {
60
+ changeSet: string;
61
+ summary: string;
62
+ renames: string;
63
+ };
64
+ /** The kept scan output folders, with `keepScans`. */
65
+ scanDirs?: {
66
+ base: string;
67
+ head: string;
68
+ };
69
+ }
70
+ /** The repository's root commit (the oldest one when there are several). */
71
+ export declare function rootCommit(repo: string, sha: string): string;
72
+ /** Renamed files between two commits, from `git diff -M`. */
73
+ export declare function renameMap(repo: string, base: string, head: string): Rename[];
74
+ /**
75
+ * Writes the Git stamps of an exported revision into a kept scan's facts.json: the export has no
76
+ * .git, so the scan recorded no commit. The export is exactly that commit, so the tree is clean.
77
+ */
78
+ export declare function stampCommit(factsPath: string, commitSha: string, rootCommitSha: string): void;
79
+ export declare function defaultCacheDir(): string;
80
+ export declare function runDiff(options: RunDiffOptions): RunDiffResult;
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CONFIG_FILE = exports.DiffError = void 0;
7
+ exports.madeBy = madeBy;
8
+ exports.rootCommit = rootCommit;
9
+ exports.renameMap = renameMap;
10
+ exports.stampCommit = stampCommit;
11
+ exports.defaultCacheDir = defaultCacheDir;
12
+ exports.runDiff = runDiff;
13
+ const child_process_1 = require("child_process");
14
+ const crypto_1 = require("crypto");
15
+ const fs_1 = __importDefault(require("fs"));
16
+ const os_1 = __importDefault(require("os"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const kb_compare_1 = require("../../vendor/kb-compare/dist/src/index.js");
19
+ /**
20
+ * `dataparade diff <repo> <base> <head>` (DATAP-852): scans two Git revisions of one repository
21
+ * and writes the change set between them. AI is off and nothing is uploaded.
22
+ *
23
+ * - Refuses a working tree with changes that are not committed.
24
+ * - Exports each revision with `git archive` into a temporary folder named after the repository,
25
+ * so the user's checkout is never touched.
26
+ * - Scans both revisions with the head's `dataparade.config.json`.
27
+ * - Reuses a cached scan only when it was made from the same commit and configuration by the same
28
+ * CLI, scanner and pattern catalog (DATAP-878); the cached scan's own stamps are checked too.
29
+ * - Writes `change-set.json`, `summary.txt` and `renames.json` (rename map and root commit).
30
+ * - With `keepScans` (`--upload`, DATAP-886), keeps each revision's whole scan output in
31
+ * `base/` and `head/`, with the commit, root commit and a clean tree in its facts.json stamps:
32
+ * the scan ran on a `git archive` export, which has no .git to read them from.
33
+ */
34
+ class DiffError extends Error {
35
+ constructor(code, message) {
36
+ super(message);
37
+ this.code = code;
38
+ }
39
+ }
40
+ exports.DiffError = DiffError;
41
+ exports.CONFIG_FILE = "dataparade.config.json";
42
+ /** True when a scan's stamps say it was made by these tools. Scans without stamps never match. */
43
+ function madeBy(facts, tools) {
44
+ const stamps = facts?.scan?.stamps;
45
+ return Boolean(stamps) && stamps.cliVersion === tools.cliVersion && stamps.scannerCommit === tools.scannerCommit && stamps.catalogHash === tools.catalogHash;
46
+ }
47
+ function git(repo, args) {
48
+ return (0, child_process_1.execFileSync)("git", ["-C", repo, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], maxBuffer: 64 * 1024 * 1024 });
49
+ }
50
+ function repoRoot(repo) {
51
+ try {
52
+ return git(repo, ["rev-parse", "--show-toplevel"]).trim();
53
+ }
54
+ catch {
55
+ throw new DiffError("NOT_A_REPO", `${repo} is not inside a Git repository.`);
56
+ }
57
+ }
58
+ function resolveCommit(repo, revision) {
59
+ try {
60
+ return git(repo, ["rev-parse", "--verify", "--quiet", `${revision}^{commit}`]).trim();
61
+ }
62
+ catch {
63
+ throw new DiffError("UNKNOWN_REVISION", `'${revision}' is not a commit in ${repo}.`);
64
+ }
65
+ }
66
+ /** The repository's root commit (the oldest one when there are several). */
67
+ function rootCommit(repo, sha) {
68
+ const roots = git(repo, ["rev-list", "--max-parents=0", sha]).trim().split("\n").filter(Boolean);
69
+ return roots[roots.length - 1];
70
+ }
71
+ /** Renamed files between two commits, from `git diff -M`. */
72
+ function renameMap(repo, base, head) {
73
+ const out = git(repo, ["diff", "-M", "--name-status", "-z", base, head]);
74
+ const fields = out.split("\0");
75
+ const renames = [];
76
+ for (let i = 0; i < fields.length;) {
77
+ const status = fields[i];
78
+ if (!status)
79
+ break;
80
+ if (status.startsWith("R")) {
81
+ renames.push({ from: fields[i + 1], to: fields[i + 2], similarity: Number(status.slice(1)) || 0 });
82
+ i += 3;
83
+ }
84
+ else if (status.startsWith("C")) {
85
+ i += 3;
86
+ }
87
+ else {
88
+ i += 2;
89
+ }
90
+ }
91
+ return renames.sort((a, b) => (a.from < b.from ? -1 : a.from > b.from ? 1 : 0));
92
+ }
93
+ function configAt(repo, sha) {
94
+ try {
95
+ return git(repo, ["show", `${sha}:${exports.CONFIG_FILE}`]);
96
+ }
97
+ catch {
98
+ return null;
99
+ }
100
+ }
101
+ /** Writes the tree of `sha` into `dir`, with the head's configuration in place of its own. */
102
+ function exportRevision(repo, sha, dir, headConfig) {
103
+ fs_1.default.mkdirSync(dir, { recursive: true });
104
+ (0, child_process_1.execFileSync)("sh", ["-c", 'git -C "$1" archive --format=tar "$2" | tar -x -C "$3"', "sh", repo, sha, dir], { stdio: ["ignore", "ignore", "pipe"] });
105
+ const configPath = path_1.default.join(dir, exports.CONFIG_FILE);
106
+ if (headConfig === null)
107
+ fs_1.default.rmSync(configPath, { force: true });
108
+ else
109
+ fs_1.default.writeFileSync(configPath, headConfig);
110
+ }
111
+ const sha256 = (text) => (0, crypto_1.createHash)("sha256").update(text, "utf8").digest("hex");
112
+ /**
113
+ * Writes the Git stamps of an exported revision into a kept scan's facts.json: the export has no
114
+ * .git, so the scan recorded no commit. The export is exactly that commit, so the tree is clean.
115
+ */
116
+ function stampCommit(factsPath, commitSha, rootCommitSha) {
117
+ const facts = JSON.parse(fs_1.default.readFileSync(factsPath, "utf8"));
118
+ const stamps = facts.scan?.stamps;
119
+ if (!stamps)
120
+ return;
121
+ facts.scan.stamps = { ...stamps, commitSha, dirty: false, rootCommitSha };
122
+ fs_1.default.writeFileSync(factsPath, `${JSON.stringify(facts, null, 2)}\n`);
123
+ }
124
+ function defaultCacheDir() {
125
+ return process.env.DATAPARADE_CACHE_DIR?.trim() || path_1.default.join(os_1.default.homedir(), ".cache", "dataparade", "diff-scans");
126
+ }
127
+ function runDiff(options) {
128
+ const log = options.log ?? (() => { });
129
+ const repo = repoRoot(path_1.default.resolve(options.repo));
130
+ if (git(repo, ["status", "--porcelain"]).trim() !== "") {
131
+ throw new DiffError("DIRTY_TREE", `${repo} has changes that are not committed. Commit or stash them, then run diff again.`);
132
+ }
133
+ const baseSha = resolveCommit(repo, options.base);
134
+ const headSha = resolveCommit(repo, options.head);
135
+ const root = rootCommit(repo, headSha);
136
+ const headConfig = configAt(repo, headSha);
137
+ const configChanged = configAt(repo, baseSha) !== headConfig;
138
+ const toolsKey = sha256(JSON.stringify([options.tools.cliVersion, options.tools.scannerCommit, options.tools.catalogHash, headConfig ?? ""])).slice(0, 16);
139
+ const cacheKey = (sha) => `${sha}-${toolsKey}`;
140
+ const folderName = path_1.default.basename(repo);
141
+ const keepDir = (side) => path_1.default.join(options.outputDir, side);
142
+ /** The scan of `sha`; with `keepScans`, its whole output is also left in `keep`. */
143
+ const scanRevision = (sha, keep) => {
144
+ const cacheFolder = options.cacheDir ? path_1.default.join(options.cacheDir, root, cacheKey(sha)) : null;
145
+ const cached = cacheFolder ? path_1.default.join(cacheFolder, "facts.json") : null;
146
+ // A cache entry from before --upload holds facts.json only; an upload needs the whole output.
147
+ const usable = cached && fs_1.default.existsSync(cached) && (!keep || fs_1.default.existsSync(path_1.default.join(cacheFolder, "dataflow.json")));
148
+ if (usable) {
149
+ const facts = JSON.parse(fs_1.default.readFileSync(cached, "utf8"));
150
+ if (madeBy(facts, options.tools)) {
151
+ log(`Reusing the scan of ${sha.slice(0, 8)}.`);
152
+ if (keep)
153
+ fs_1.default.cpSync(cacheFolder, keep, { recursive: true });
154
+ return facts;
155
+ }
156
+ log(`The cached scan of ${sha.slice(0, 8)} was made by other tools; scanning again.`);
157
+ }
158
+ const work = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "dataparade-diff-"));
159
+ try {
160
+ const dir = path_1.default.join(work, folderName);
161
+ const out = keep ?? path_1.default.join(work, "out");
162
+ exportRevision(repo, sha, dir, headConfig);
163
+ fs_1.default.mkdirSync(out, { recursive: true });
164
+ log(`Scanning ${sha.slice(0, 8)}...`);
165
+ const facts = options.scan(dir, out);
166
+ if (cacheFolder) {
167
+ fs_1.default.rmSync(cacheFolder, { recursive: true, force: true });
168
+ fs_1.default.mkdirSync(cacheFolder, { recursive: true });
169
+ fs_1.default.cpSync(out, cacheFolder, { recursive: true });
170
+ fs_1.default.writeFileSync(cached, JSON.stringify(facts));
171
+ }
172
+ return facts;
173
+ }
174
+ finally {
175
+ fs_1.default.rmSync(work, { recursive: true, force: true });
176
+ }
177
+ };
178
+ if (options.keepScans) {
179
+ for (const side of ["base", "head"])
180
+ fs_1.default.rmSync(keepDir(side), { recursive: true, force: true });
181
+ }
182
+ const baseFacts = scanRevision(baseSha, options.keepScans ? keepDir("base") : null);
183
+ const headFacts = headSha === baseSha ? baseFacts : scanRevision(headSha, options.keepScans ? keepDir("head") : null);
184
+ let scanDirs;
185
+ if (options.keepScans) {
186
+ if (headSha === baseSha)
187
+ fs_1.default.cpSync(keepDir("base"), keepDir("head"), { recursive: true });
188
+ scanDirs = { base: keepDir("base"), head: keepDir("head") };
189
+ stampCommit(path_1.default.join(scanDirs.base, "facts.json"), baseSha, root);
190
+ stampCommit(path_1.default.join(scanDirs.head, "facts.json"), headSha, root);
191
+ }
192
+ // The rename map makes renamed and moved elements "renamed" instead of removed plus added (DATAP-866).
193
+ const renames = renameMap(repo, baseSha, headSha);
194
+ const changeSet = (0, kb_compare_1.compareScans)(baseFacts, headFacts, { configChanged, renames });
195
+ const summary = (0, kb_compare_1.summarizeChangeSet)(changeSet);
196
+ fs_1.default.mkdirSync(options.outputDir, { recursive: true });
197
+ const files = {
198
+ changeSet: path_1.default.join(options.outputDir, "change-set.json"),
199
+ summary: path_1.default.join(options.outputDir, "summary.txt"),
200
+ renames: path_1.default.join(options.outputDir, "renames.json"),
201
+ };
202
+ fs_1.default.writeFileSync(files.changeSet, `${JSON.stringify(changeSet, null, 2)}\n`);
203
+ fs_1.default.writeFileSync(files.summary, `${summary}\n`);
204
+ fs_1.default.writeFileSync(files.renames, `${JSON.stringify({ rootCommit: root, base: baseSha, head: headSha, renames }, null, 2)}\n`);
205
+ return { changeSet, summary, baseSha, headSha, rootCommit: root, renames, files, ...(scanDirs ? { scanDirs } : {}) };
206
+ }