@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
@@ -0,0 +1,128 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The parts of a scan's `facts.json` that a comparison reads. The CLI owns the full schema
4
+ * (`cli/src/facts/schema.ts`); this package declares only what it needs, so it does not depend
5
+ * on the CLI. Unknown fields are ignored.
6
+ */
7
+ export declare const identityInputSchema: z.ZodObject<{
8
+ kind: z.ZodEnum<{
9
+ component: "component";
10
+ dataFlow: "dataFlow";
11
+ dataItem: "dataItem";
12
+ group: "group";
13
+ }>;
14
+ key: z.ZodString;
15
+ parts: z.ZodRecord<z.ZodString, z.ZodString>;
16
+ duplicateIndex: z.ZodOptional<z.ZodNumber>;
17
+ }, z.core.$strip>;
18
+ /** `facts.scan.stamps` (DATAP-876); see cli/src/facts/schema.ts. */
19
+ export declare const stampsInputSchema: z.ZodObject<{
20
+ scannerCommit: z.ZodString;
21
+ cliVersion: z.ZodString;
22
+ catalogHash: z.ZodString;
23
+ configHash: z.ZodString;
24
+ aiInference: z.ZodBoolean;
25
+ structureGraph: z.ZodBoolean;
26
+ commitSha: z.ZodNullable<z.ZodString>;
27
+ dirty: z.ZodNullable<z.ZodBoolean>;
28
+ rootCommitSha: z.ZodNullable<z.ZodString>;
29
+ scanRoot: z.ZodNullable<z.ZodString>;
30
+ }, z.core.$strip>;
31
+ export declare const factsInputSchema: z.ZodObject<{
32
+ schemaVersion: z.ZodLiteral<1>;
33
+ scan: z.ZodOptional<z.ZodObject<{
34
+ stamps: z.ZodOptional<z.ZodObject<{
35
+ scannerCommit: z.ZodString;
36
+ cliVersion: z.ZodString;
37
+ catalogHash: z.ZodString;
38
+ configHash: z.ZodString;
39
+ aiInference: z.ZodBoolean;
40
+ structureGraph: z.ZodBoolean;
41
+ commitSha: z.ZodNullable<z.ZodString>;
42
+ dirty: z.ZodNullable<z.ZodBoolean>;
43
+ rootCommitSha: z.ZodNullable<z.ZodString>;
44
+ scanRoot: z.ZodNullable<z.ZodString>;
45
+ }, z.core.$strip>>;
46
+ }, z.core.$strip>>;
47
+ components: z.ZodArray<z.ZodObject<{
48
+ id: z.ZodString;
49
+ identity: z.ZodOptional<z.ZodObject<{
50
+ kind: z.ZodEnum<{
51
+ component: "component";
52
+ dataFlow: "dataFlow";
53
+ dataItem: "dataItem";
54
+ group: "group";
55
+ }>;
56
+ key: z.ZodString;
57
+ parts: z.ZodRecord<z.ZodString, z.ZodString>;
58
+ duplicateIndex: z.ZodOptional<z.ZodNumber>;
59
+ }, z.core.$strip>>;
60
+ sourceLocations: z.ZodOptional<z.ZodArray<z.ZodObject<{
61
+ filePath: z.ZodString;
62
+ }, z.core.$strip>>>;
63
+ name: z.ZodString;
64
+ type: z.ZodString;
65
+ subType: z.ZodString;
66
+ confidence: z.ZodNumber;
67
+ }, z.core.$strip>>;
68
+ dataFlows: z.ZodArray<z.ZodObject<{
69
+ id: z.ZodString;
70
+ identity: z.ZodOptional<z.ZodObject<{
71
+ kind: z.ZodEnum<{
72
+ component: "component";
73
+ dataFlow: "dataFlow";
74
+ dataItem: "dataItem";
75
+ group: "group";
76
+ }>;
77
+ key: z.ZodString;
78
+ parts: z.ZodRecord<z.ZodString, z.ZodString>;
79
+ duplicateIndex: z.ZodOptional<z.ZodNumber>;
80
+ }, z.core.$strip>>;
81
+ sourceLocations: z.ZodOptional<z.ZodArray<z.ZodObject<{
82
+ filePath: z.ZodString;
83
+ }, z.core.$strip>>>;
84
+ sourceComponentId: z.ZodString;
85
+ targetComponentId: z.ZodString;
86
+ type: z.ZodString;
87
+ targetScope: z.ZodOptional<z.ZodString>;
88
+ confidence: z.ZodNumber;
89
+ }, z.core.$strip>>;
90
+ dataItems: z.ZodArray<z.ZodObject<{
91
+ id: z.ZodString;
92
+ identity: z.ZodOptional<z.ZodObject<{
93
+ kind: z.ZodEnum<{
94
+ component: "component";
95
+ dataFlow: "dataFlow";
96
+ dataItem: "dataItem";
97
+ group: "group";
98
+ }>;
99
+ key: z.ZodString;
100
+ parts: z.ZodRecord<z.ZodString, z.ZodString>;
101
+ duplicateIndex: z.ZodOptional<z.ZodNumber>;
102
+ }, z.core.$strip>>;
103
+ name: z.ZodString;
104
+ labels: z.ZodArray<z.ZodString>;
105
+ groups: z.ZodArray<z.ZodObject<{
106
+ id: z.ZodString;
107
+ identity: z.ZodOptional<z.ZodObject<{
108
+ kind: z.ZodEnum<{
109
+ component: "component";
110
+ dataFlow: "dataFlow";
111
+ dataItem: "dataItem";
112
+ group: "group";
113
+ }>;
114
+ key: z.ZodString;
115
+ parts: z.ZodRecord<z.ZodString, z.ZodString>;
116
+ duplicateIndex: z.ZodOptional<z.ZodNumber>;
117
+ }, z.core.$strip>>;
118
+ label: z.ZodString;
119
+ basis: z.ZodOptional<z.ZodString>;
120
+ handledBy: z.ZodArray<z.ZodString>;
121
+ }, z.core.$strip>>;
122
+ }, z.core.$strip>>;
123
+ }, z.core.$strip>;
124
+ export type IdentityInput = z.infer<typeof identityInputSchema>;
125
+ export type FactsInput = z.infer<typeof factsInputSchema>;
126
+ export type StampsInput = z.infer<typeof stampsInputSchema>;
127
+ /** Parses a `facts.json` value. Throws a ZodError that names the bad field. */
128
+ export declare function parseFacts(value: unknown): FactsInput;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.factsInputSchema = exports.stampsInputSchema = exports.identityInputSchema = void 0;
4
+ exports.parseFacts = parseFacts;
5
+ const zod_1 = require("zod");
6
+ /**
7
+ * The parts of a scan's `facts.json` that a comparison reads. The CLI owns the full schema
8
+ * (`cli/src/facts/schema.ts`); this package declares only what it needs, so it does not depend
9
+ * on the CLI. Unknown fields are ignored.
10
+ */
11
+ exports.identityInputSchema = zod_1.z.object({
12
+ kind: zod_1.z.enum(["component", "dataFlow", "dataItem", "group"]),
13
+ key: zod_1.z.string(),
14
+ parts: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
15
+ duplicateIndex: zod_1.z.number().int().min(2).optional(),
16
+ });
17
+ /** Only the file paths are read (for rename matching, DATAP-866). */
18
+ const sourceLocationsInputSchema = zod_1.z.array(zod_1.z.object({ filePath: zod_1.z.string() })).optional();
19
+ const componentInputSchema = zod_1.z.object({
20
+ id: zod_1.z.string(),
21
+ identity: exports.identityInputSchema.optional(),
22
+ sourceLocations: sourceLocationsInputSchema,
23
+ name: zod_1.z.string(),
24
+ type: zod_1.z.string(),
25
+ subType: zod_1.z.string(),
26
+ confidence: zod_1.z.number(),
27
+ });
28
+ const dataFlowInputSchema = zod_1.z.object({
29
+ id: zod_1.z.string(),
30
+ identity: exports.identityInputSchema.optional(),
31
+ sourceLocations: sourceLocationsInputSchema,
32
+ sourceComponentId: zod_1.z.string(),
33
+ targetComponentId: zod_1.z.string(),
34
+ type: zod_1.z.string(),
35
+ targetScope: zod_1.z.string().optional(),
36
+ confidence: zod_1.z.number(),
37
+ });
38
+ const groupInputSchema = zod_1.z.object({
39
+ id: zod_1.z.string(),
40
+ identity: exports.identityInputSchema.optional(),
41
+ label: zod_1.z.string(),
42
+ basis: zod_1.z.string().optional(),
43
+ handledBy: zod_1.z.array(zod_1.z.string()),
44
+ });
45
+ const dataItemInputSchema = zod_1.z.object({
46
+ id: zod_1.z.string(),
47
+ identity: exports.identityInputSchema.optional(),
48
+ name: zod_1.z.string(),
49
+ labels: zod_1.z.array(zod_1.z.string()),
50
+ groups: zod_1.z.array(groupInputSchema),
51
+ });
52
+ /** `facts.scan.stamps` (DATAP-876); see cli/src/facts/schema.ts. */
53
+ exports.stampsInputSchema = zod_1.z.object({
54
+ scannerCommit: zod_1.z.string(),
55
+ cliVersion: zod_1.z.string(),
56
+ catalogHash: zod_1.z.string(),
57
+ configHash: zod_1.z.string(),
58
+ aiInference: zod_1.z.boolean(),
59
+ structureGraph: zod_1.z.boolean(),
60
+ commitSha: zod_1.z.string().nullable(),
61
+ dirty: zod_1.z.boolean().nullable(),
62
+ rootCommitSha: zod_1.z.string().nullable(),
63
+ scanRoot: zod_1.z.string().nullable(),
64
+ });
65
+ exports.factsInputSchema = zod_1.z.object({
66
+ schemaVersion: zod_1.z.literal(1),
67
+ scan: zod_1.z.object({ stamps: exports.stampsInputSchema.optional() }).optional(),
68
+ components: zod_1.z.array(componentInputSchema),
69
+ dataFlows: zod_1.z.array(dataFlowInputSchema),
70
+ dataItems: zod_1.z.array(dataItemInputSchema),
71
+ });
72
+ /** Parses a `facts.json` value. Throws a ZodError that names the bad field. */
73
+ function parseFacts(value) {
74
+ return exports.factsInputSchema.parse(value);
75
+ }
@@ -0,0 +1,69 @@
1
+ import { z } from "zod";
2
+ import type { ChangeSet } from "./change-set";
3
+ import { type Fingerprint } from "./fingerprint";
4
+ /**
5
+ * The slot rules (DATAP-874): whether an answer given at a base revision still holds at a head
6
+ * revision. Each answer is carried (still holds), reopened (the question must be asked again) or
7
+ * retired (its element is gone). A reopened answer becomes the prior answer of the new question.
8
+ *
9
+ * | Slot | Carry when | Reopen when | Retire when |
10
+ * | ----------------- | --------------------------------------------- | --------------------------------------------- | ----------- |
11
+ * | `in_scope` | element corresponds | type or subType changed, or split or merge | removed |
12
+ * | `actor_kind` | element corresponds | subType changed | removed |
13
+ * | `data_categories` | element corresponds, neighbours unchanged | neighbours changed | removed |
14
+ * | `purpose` | element corresponds, neighbours and type same | neighbours or type changed, or split or merge | removed |
15
+ * | any other slot | element corresponds | (never) | removed |
16
+ *
17
+ * "Corresponds" means the element is in the head under its key, under the key it was renamed
18
+ * to, or under the key it got when only its type, subtype or (for a flow) endpoints changed, all of
19
+ * which are part of the key. A code-hash change alone never reopens an answer: the fingerprint holds no code hash.
20
+ * `data_categories` uses neighbours only until flows carry observed data categories (DATAP-856);
21
+ * then "gained a category" reopens it too. Answers about the whole system (`dp:a0/system`) are
22
+ * always carried. A retired answer is re-attached (carried) when its key reappears with the same
23
+ * fingerprint. Answers on occurrences are not carried (DATAP-862).
24
+ */
25
+ export declare const SYSTEM_KEY = "dp:a0/system";
26
+ export declare const carryInputSchema: z.ZodObject<{
27
+ id: z.ZodString;
28
+ slot: z.ZodString;
29
+ identityKey: z.ZodString;
30
+ fingerprint: z.ZodNullable<z.ZodObject<{
31
+ version: z.ZodLiteral<1>;
32
+ subject: z.ZodEnum<{
33
+ component: "component";
34
+ dataFlow: "dataFlow";
35
+ dataItem: "dataItem";
36
+ group: "group";
37
+ }>;
38
+ key: z.ZodString;
39
+ shape: z.ZodObject<{
40
+ type: z.ZodNullable<z.ZodString>;
41
+ subType: z.ZodNullable<z.ZodString>;
42
+ targetScope: z.ZodNullable<z.ZodString>;
43
+ }, z.core.$strip>;
44
+ neighbours: z.ZodNullable<z.ZodObject<{
45
+ source: z.ZodString;
46
+ target: z.ZodString;
47
+ }, z.core.$strip>>;
48
+ handledGroups: z.ZodArray<z.ZodString>;
49
+ }, z.core.$strip>>;
50
+ retired: z.ZodOptional<z.ZodBoolean>;
51
+ }, z.core.$strip>;
52
+ export type CarryInput = z.infer<typeof carryInputSchema>;
53
+ export type CarryReason = "system" | "unchanged" | "renamed" | "rekeyed" | "reattached" | "type_changed" | "subtype_changed" | "neighbours_changed" | "split" | "merge" | "removed" | "no_fingerprint";
54
+ export interface CarryDecision {
55
+ answerId: string;
56
+ decision: "carry" | "reopen" | "retire";
57
+ reason: CarryReason;
58
+ /** The element's key at the head (after a rename); the base key for a retired answer. */
59
+ headKey: string;
60
+ /** The element's fingerprint at the head, to store with the carried answer. Null when retired or system. */
61
+ headFingerprint: Fingerprint | null;
62
+ /** For a reopened answer: the answer the new question replaces (`prior_answer_id`). */
63
+ priorAnswerId?: string;
64
+ }
65
+ /**
66
+ * Decide each answer at the head of a comparison. `changeSet` is the comparison of the base scan
67
+ * (where the answers' keys and fingerprints were taken) with `head`, a parsed `facts.json`.
68
+ */
69
+ export declare function applySlotRules(changeSet: ChangeSet, head: unknown, answers: CarryInput[]): CarryDecision[];
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.carryInputSchema = exports.SYSTEM_KEY = void 0;
4
+ exports.applySlotRules = applySlotRules;
5
+ const zod_1 = require("zod");
6
+ const canonical_1 = require("./canonical");
7
+ const fingerprint_1 = require("./fingerprint");
8
+ const input_1 = require("./input");
9
+ /**
10
+ * The slot rules (DATAP-874): whether an answer given at a base revision still holds at a head
11
+ * revision. Each answer is carried (still holds), reopened (the question must be asked again) or
12
+ * retired (its element is gone). A reopened answer becomes the prior answer of the new question.
13
+ *
14
+ * | Slot | Carry when | Reopen when | Retire when |
15
+ * | ----------------- | --------------------------------------------- | --------------------------------------------- | ----------- |
16
+ * | `in_scope` | element corresponds | type or subType changed, or split or merge | removed |
17
+ * | `actor_kind` | element corresponds | subType changed | removed |
18
+ * | `data_categories` | element corresponds, neighbours unchanged | neighbours changed | removed |
19
+ * | `purpose` | element corresponds, neighbours and type same | neighbours or type changed, or split or merge | removed |
20
+ * | any other slot | element corresponds | (never) | removed |
21
+ *
22
+ * "Corresponds" means the element is in the head under its key, under the key it was renamed
23
+ * to, or under the key it got when only its type, subtype or (for a flow) endpoints changed, all of
24
+ * which are part of the key. A code-hash change alone never reopens an answer: the fingerprint holds no code hash.
25
+ * `data_categories` uses neighbours only until flows carry observed data categories (DATAP-856);
26
+ * then "gained a category" reopens it too. Answers about the whole system (`dp:a0/system`) are
27
+ * always carried. A retired answer is re-attached (carried) when its key reappears with the same
28
+ * fingerprint. Answers on occurrences are not carried (DATAP-862).
29
+ */
30
+ exports.SYSTEM_KEY = "dp:a0/system";
31
+ exports.carryInputSchema = zod_1.z.object({
32
+ /** The answer's id. */
33
+ id: zod_1.z.string(),
34
+ /** The slot or property the answer sets. */
35
+ slot: zod_1.z.string(),
36
+ /** `identityKey` of the answer at the base revision: an element key, or `dp:a0/system`. */
37
+ identityKey: zod_1.z.string(),
38
+ /** The element's fingerprint at the base revision. Null for system answers or when unknown. */
39
+ fingerprint: fingerprint_1.fingerprintSchema.nullable(),
40
+ /** True when the answer was retired at an earlier revision. */
41
+ retired: zod_1.z.boolean().optional(),
42
+ });
43
+ const SPLIT_REOPENS = new Set(["in_scope", "purpose"]);
44
+ function fpKey(subject, key) {
45
+ return `${subject}\u0000${key}`;
46
+ }
47
+ /**
48
+ * Looser forms of a key, so an element that changed in a way that changes its key can still be
49
+ * found: `retype` blanks the type fields (an `app:` key's type and subtype, a flow key's type),
50
+ * `rewire` blanks a flow key's endpoints (the same call now reaches another component).
51
+ */
52
+ const LOOSE_KEYS = [
53
+ {
54
+ name: "retype",
55
+ apply: (subject, key) => {
56
+ if (subject === "component" && key.startsWith("app:")) {
57
+ const parts = key.split("|");
58
+ return parts.length < 5 ? null : [parts[0], "", "", ...parts.slice(3)].join("|");
59
+ }
60
+ const flow = subject === "dataFlow" ? flowParts(key) : null;
61
+ return flow ? JSON.stringify([...flow.slice(0, 3), "", ...flow.slice(4)]) : null;
62
+ },
63
+ },
64
+ {
65
+ name: "rewire",
66
+ apply: (subject, key) => {
67
+ const flow = subject === "dataFlow" ? flowParts(key) : null;
68
+ return flow ? JSON.stringify([flow[0], "", "", ...flow.slice(3)]) : null;
69
+ },
70
+ },
71
+ ];
72
+ function flowParts(key) {
73
+ if (!key.startsWith("["))
74
+ return null;
75
+ try {
76
+ const parts = JSON.parse(key);
77
+ return Array.isArray(parts) && parts[0] === "flow/v1" ? parts : null;
78
+ }
79
+ catch {
80
+ return null;
81
+ }
82
+ }
83
+ function sameFingerprint(a, b) {
84
+ return JSON.stringify(a) === JSON.stringify(b);
85
+ }
86
+ /**
87
+ * Decide each answer at the head of a comparison. `changeSet` is the comparison of the base scan
88
+ * (where the answers' keys and fingerprints were taken) with `head`, a parsed `facts.json`.
89
+ */
90
+ function applySlotRules(changeSet, head, answers) {
91
+ const headPrints = (0, fingerprint_1.fingerprintsOfScan)((0, canonical_1.canonicalize)((0, input_1.parseFacts)(head)));
92
+ const renamedTo = new Map();
93
+ const removed = new Set();
94
+ for (const change of changeSet.changes) {
95
+ if (change.change === "renamed" && change.previousKey) {
96
+ renamedTo.set(fpKey(change.subject, change.previousKey), change.key);
97
+ }
98
+ else if (change.change === "removed") {
99
+ removed.add(fpKey(change.subject, change.key));
100
+ }
101
+ }
102
+ const componentKeyAtHead = (key) => renamedTo.get(fpKey("component", key)) ?? key;
103
+ // Added elements by each loose key: where a removed element reappears changed.
104
+ const addedLoose = new Map();
105
+ for (const change of changeSet.changes) {
106
+ if (change.change !== "added")
107
+ continue;
108
+ for (const loose of LOOSE_KEYS) {
109
+ const value = loose.apply(change.subject, change.key);
110
+ if (!value)
111
+ continue;
112
+ const id = `${loose.name}\u0000${fpKey(change.subject, value)}`;
113
+ addedLoose.set(id, [...(addedLoose.get(id) ?? []), change.key]);
114
+ }
115
+ }
116
+ const changedTo = (subject, key) => {
117
+ for (const loose of LOOSE_KEYS) {
118
+ const value = loose.apply(subject, key);
119
+ if (!value)
120
+ continue;
121
+ const found = addedLoose.get(`${loose.name}\u0000${fpKey(subject, value)}`) ?? [];
122
+ if (found.length === 1)
123
+ return found[0];
124
+ }
125
+ return undefined;
126
+ };
127
+ const splitOf = new Map();
128
+ for (const split of changeSet.splits) {
129
+ for (const key of split.base)
130
+ splitOf.set(key, split.kind);
131
+ }
132
+ return answers.map((answer) => {
133
+ const base = { answerId: answer.id };
134
+ if (answer.identityKey === exports.SYSTEM_KEY) {
135
+ return { ...base, decision: "carry", reason: "system", headKey: exports.SYSTEM_KEY, headFingerprint: null };
136
+ }
137
+ const fp = answer.fingerprint;
138
+ if (!fp) {
139
+ // Without a fingerprint the subject is unknown; the answer cannot be judged, so it is reopened.
140
+ return { ...base, decision: "reopen", reason: "no_fingerprint", headKey: answer.identityKey, headFingerprint: null, priorAnswerId: answer.id };
141
+ }
142
+ if (answer.retired) {
143
+ const back = headPrints.get(fpKey(fp.subject, fp.key));
144
+ return back && sameFingerprint(back, fp)
145
+ ? { ...base, decision: "carry", reason: "reattached", headKey: fp.key, headFingerprint: back }
146
+ : { ...base, decision: "retire", reason: "removed", headKey: fp.key, headFingerprint: null };
147
+ }
148
+ const isRemoved = removed.has(fpKey(fp.subject, fp.key));
149
+ const byRename = renamedTo.get(fpKey(fp.subject, fp.key));
150
+ const renamed = byRename ?? (isRemoved ? changedTo(fp.subject, fp.key) : undefined);
151
+ const headKey = renamed ?? fp.key;
152
+ const now = headPrints.get(fpKey(fp.subject, headKey));
153
+ const split = fp.subject === "component" ? splitOf.get(fp.key) : undefined;
154
+ if (!now || (isRemoved && !renamed)) {
155
+ if (split) {
156
+ // The element was split or merged into others: ask again rather than drop the answer.
157
+ return { ...base, decision: "reopen", reason: split, headKey: fp.key, headFingerprint: null, priorAnswerId: answer.id };
158
+ }
159
+ return { ...base, decision: "retire", reason: "removed", headKey: fp.key, headFingerprint: null };
160
+ }
161
+ const reopen = (reason) => ({
162
+ ...base,
163
+ decision: "reopen",
164
+ reason,
165
+ headKey,
166
+ headFingerprint: now,
167
+ priorAnswerId: answer.id,
168
+ });
169
+ if (split && SPLIT_REOPENS.has(answer.slot))
170
+ return reopen(split);
171
+ const neighboursChanged = () => {
172
+ if (!fp.neighbours || !now.neighbours)
173
+ return fp.neighbours !== now.neighbours;
174
+ return (componentKeyAtHead(fp.neighbours.source) !== now.neighbours.source ||
175
+ componentKeyAtHead(fp.neighbours.target) !== now.neighbours.target);
176
+ };
177
+ switch (answer.slot) {
178
+ case "in_scope":
179
+ if (fp.shape.type !== now.shape.type)
180
+ return reopen("type_changed");
181
+ if (fp.shape.subType !== now.shape.subType)
182
+ return reopen("subtype_changed");
183
+ break;
184
+ case "actor_kind":
185
+ if (fp.shape.subType !== now.shape.subType)
186
+ return reopen("subtype_changed");
187
+ break;
188
+ case "data_categories":
189
+ if (neighboursChanged())
190
+ return reopen("neighbours_changed");
191
+ break;
192
+ case "purpose":
193
+ if (neighboursChanged())
194
+ return reopen("neighbours_changed");
195
+ if (fp.shape.type !== now.shape.type)
196
+ return reopen("type_changed");
197
+ break;
198
+ default:
199
+ break;
200
+ }
201
+ return { ...base, decision: "carry", reason: byRename ? "renamed" : renamed ? "rekeyed" : "unchanged", headKey, headFingerprint: now };
202
+ });
203
+ }
@@ -0,0 +1,3 @@
1
+ import type { ChangeSet } from "./change-set";
2
+ /** A short text summary of a change set, for the terminal. */
3
+ export declare function summarizeChangeSet(changeSet: ChangeSet): string;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.summarizeChangeSet = summarizeChangeSet;
4
+ const NOUNS = {
5
+ component: ["component", "components"],
6
+ dataFlow: ["flow", "flows"],
7
+ dataItem: ["data item", "data items"],
8
+ group: ["group", "groups"],
9
+ };
10
+ function count(n, subject) {
11
+ return `${n} ${NOUNS[subject][n === 1 ? 0 : 1]}`;
12
+ }
13
+ function line(change) {
14
+ const sign = change.change === "added" ? "+" : change.change === "removed" ? "-" : change.change === "renamed" ? ">" : "~";
15
+ const what = change.subject === "group" ? `${change.parent} / ${change.name}` : change.name;
16
+ const ends = change.source && change.target ? ` (${change.source} → ${change.target})` : "";
17
+ const props = change.properties?.length ? `: ${change.properties.map((p) => p.property).join(", ")}` : "";
18
+ return ` ${sign} ${NOUNS[change.subject][0]} ${what}${ends}${props}`;
19
+ }
20
+ /** A short text summary of a change set, for the terminal. */
21
+ function summarizeChangeSet(changeSet) {
22
+ if (changeSet.unchanged)
23
+ return "No changes.";
24
+ if (changeSet.changes.length === 0) {
25
+ return `No changes among the Facts that have an identity. ${changeSet.unmatched.length} Facts have no identity and were not compared, so the scans may still differ.`;
26
+ }
27
+ const totals = ["added", "removed", "renamed", "modified"]
28
+ .map((kind) => {
29
+ const of = changeSet.changes.filter((c) => c.change === kind);
30
+ if (of.length === 0)
31
+ return null;
32
+ const bySubject = ["component", "dataFlow", "dataItem", "group"]
33
+ .map((s) => [s, of.filter((c) => c.subject === s).length])
34
+ .filter(([, n]) => n > 0)
35
+ .map(([s, n]) => count(n, s));
36
+ return `${kind}: ${bySubject.join(", ")}`;
37
+ })
38
+ .filter((t) => t !== null);
39
+ const lines = [totals.join("; "), ...changeSet.changes.map(line)];
40
+ for (const s of changeSet.splits)
41
+ lines.push(` * ${s.kind} ${s.name}: ${s.base.length} base → ${s.head.length} head components`);
42
+ if (changeSet.unmatched.length > 0)
43
+ lines.push(`${changeSet.unmatched.length} Facts have no identity and were not compared.`);
44
+ if (changeSet.configChanged)
45
+ lines.push("The scan configuration changed; both revisions were scanned with the head's configuration.");
46
+ return lines.join("\n");
47
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "@dataparade/kb-compare",
3
+ "version": "0.0.1",
4
+ "description": "Vendored build of @dataparade/kb-compare bundled into @dataparade/cli",
5
+ "main": "dist/src/index.js"
6
+ }
@@ -32,6 +32,12 @@ export interface PythonPatternConfig {
32
32
  importModules: string[];
33
33
  contentRegexes: RegExp[];
34
34
  strategy?: string;
35
+ /**
36
+ * The match is a request header (`Authorization: Bearer ...`). When the header is sent
37
+ * on an outbound request it is a credential for that API, not an auth service of this
38
+ * code, so it is not reported (DATAP-818).
39
+ */
40
+ outgoingHeader: boolean;
35
41
  confidence: number;
36
42
  }>;
37
43
  };
@@ -84,6 +90,11 @@ export interface PythonPatternConfig {
84
90
  clientName: string;
85
91
  importModules: string[];
86
92
  callNames: string[];
93
+ /**
94
+ * Session/client classes of a raw HTTP library (`AsyncClient`, `Session`). When set,
95
+ * request calls are resolved to their destination host in the same file (DATAP-818).
96
+ */
97
+ clientConstructors: string[];
87
98
  urlRegex: RegExp;
88
99
  confidence: number;
89
100
  }>;
@@ -62,6 +62,7 @@ function normalizeRawConfig(raw) {
62
62
  contentRegexes: (lib.contentRegexes ?? []).map((p) => new RegExp(p)),
63
63
  importModules: lib.importModules ?? [],
64
64
  strategy: lib.strategy,
65
+ outgoingHeader: lib.outgoingHeader ?? false,
65
66
  confidence: lib.confidence ?? DEFAULT_CONFIDENCE,
66
67
  })) ?? [];
67
68
  const serverlessHandlers = raw.serverless?.handlers?.map((handler) => ({
@@ -115,6 +116,7 @@ function normalizeRawConfig(raw) {
115
116
  clientName: client.clientName,
116
117
  importModules: client.importModules ?? [],
117
118
  callNames: client.callNames ?? [],
119
+ clientConstructors: client.clientConstructors ?? [],
118
120
  urlRegex: new RegExp(client.urlRegex ??
119
121
  "['\\\"](https?:\\/\\/[^\\s'\\\"]+)['\\\"]"),
120
122
  confidence: client.confidence ?? DEFAULT_CONFIDENCE,
@@ -6,6 +6,8 @@ export interface RunAnalyzersOptions {
6
6
  terraformModuleManifest?: TerraformModuleCallManifest;
7
7
  terraformScanRootPath?: string;
8
8
  organizationDomains?: readonly string[];
9
+ /** Owner of the scanned repository's git `origin` remote, a first-party signal. */
10
+ gitRemoteOwner?: string;
9
11
  }
10
12
  export declare function registerAnalyzer(language: FileLanguage, analyzer: Analyzer): void;
11
13
  export declare function getAnalyzerForFile(file: FileInfo): Analyzer | undefined;
@@ -23,6 +23,7 @@ const ruby_2 = require("../patterns/detectors/ruby");
23
23
  const config_1 = require("../patterns/config");
24
24
  const parser_1 = require("./ruby/parser");
25
25
  const organization_domains_scan_scope_1 = require("../classifier/organization-domains-scan-scope");
26
+ const source_module_index_1 = require("../patterns/detectors/source-module-index");
26
27
  const typeScriptAnalyzer = (0, typescript_1.createTypeScriptAnalyzer)();
27
28
  const pythonAnalyzer = (0, python_1.createPythonAnalyzer)();
28
29
  const cppAnalyzer = (0, cpp_1.createCppAnalyzer)();
@@ -63,7 +64,7 @@ function runAnalyzers(files, opts) {
63
64
  scanRootPath: opts.terraformScanRootPath,
64
65
  }
65
66
  : undefined;
66
- return (0, organization_domains_scan_scope_1.runWithOrganizationDomainsScope)(opts?.organizationDomains, () => {
67
+ return (0, organization_domains_scan_scope_1.runWithOrganizationDomainsScope)(opts?.organizationDomains, () => (0, source_module_index_1.runWithPythonModuleIndex)(files, () => {
67
68
  for (const file of files) {
68
69
  if (file.language === "terraform") {
69
70
  findings.push(...(0, detector_2.detectTerraformPatterns)(file, tfConfig, tfOpts));
@@ -94,7 +95,7 @@ function runAnalyzers(files, opts) {
94
95
  }
95
96
  }
96
97
  return findings;
97
- });
98
+ }, { gitRemoteOwner: opts?.gitRemoteOwner }));
98
99
  }
99
100
  async function runAnalyzersForRootPath(rootPath) {
100
101
  const files = await (0, file_system_1.ingestFileSystem)(rootPath);
@@ -43,12 +43,29 @@ export interface ServerlessHandlerConfig extends WithPatternId {
43
43
  typeNames: string[];
44
44
  confidence: number;
45
45
  }
46
+ /**
47
+ * A raw HTTP library whose request URLs the TS/JS AST detector resolves (DATAP-818). Its
48
+ * line regexes then stay off, so the library is never reported as a destination.
49
+ */
50
+ export interface RawHttpClientConfig {
51
+ /** Import specifiers that load it (`axios`, `node-fetch`). */
52
+ modules: string[];
53
+ /** The default import is itself a request function (`axios(url)`, `got(url)`). */
54
+ callable: boolean;
55
+ /** Named exports that are request functions (`fetch` from undici). */
56
+ namedFunctions: string[];
57
+ /** Factory methods returning a configured instance (`axios.create`, `got.extend`). */
58
+ instanceFactories: string[];
59
+ /** Option keys that hold the instance base URL (`baseURL`, `prefixUrl`). */
60
+ baseUrlKeys: string[];
61
+ }
46
62
  export interface ExternalApiClientConfig extends WithPatternId {
47
63
  id: string;
48
64
  clientName: string;
49
65
  importFragments: string[];
50
66
  callRegexes: RegExp[];
51
67
  confidence: number;
68
+ rawHttp?: RawHttpClientConfig;
52
69
  }
53
70
  export interface ConfigLoaderConfig extends WithPatternId {
54
71
  id: string;
@@ -99,6 +99,17 @@ function normalizeRawConfig(raw) {
99
99
  importFragments: client.importFragments ?? [],
100
100
  callRegexes: compileRegexList(client.regexes),
101
101
  confidence: client.confidence ?? DEFAULT_CONFIDENCE,
102
+ ...(client.rawHttp
103
+ ? {
104
+ rawHttp: {
105
+ modules: client.rawHttp.modules,
106
+ callable: client.rawHttp.callable ?? false,
107
+ namedFunctions: client.rawHttp.namedFunctions ?? [],
108
+ instanceFactories: client.rawHttp.instanceFactories ?? [],
109
+ baseUrlKeys: client.rawHttp.baseUrlKeys ?? [],
110
+ },
111
+ }
112
+ : {}),
102
113
  };
103
114
  }) ?? [];
104
115
  const configLoaders = raw.config_loaders?.map((loader) => {