@dataparade/cli 0.0.35 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/package.json +4 -4
- package/dist/src/ai-enrichment/pii-signal-rules.d.ts +5 -0
- package/dist/src/ai-enrichment/pii-signal-rules.js +2 -3
- package/dist/src/ai-enrichment/provider-prompt.js +1 -0
- package/dist/src/ai-enrichment/providers/provider-contract.js +2 -44
- package/dist/src/ai-enrichment/third-party-data-flow.js +5 -4
- package/dist/src/cli.js +9 -3
- package/dist/src/discoveries/contract/ocsf-discovery-record.d.ts +4 -1
- package/dist/src/discoveries/contract/ocsf-discovery-record.js +1 -1
- package/dist/src/discoveries/contract/ontology-pins.d.ts +6 -4
- package/dist/src/discoveries/contract/ontology-pins.js +7 -5
- package/dist/src/facts/build-facts.d.ts +2 -0
- package/dist/src/facts/build-facts.js +18 -0
- package/dist/src/facts/layout.d.ts +4 -0
- package/dist/src/facts/layout.js +5 -1
- package/dist/src/facts/scan-stamps.d.ts +7 -0
- package/dist/src/facts/scan-stamps.js +30 -0
- package/dist/src/facts/schema.d.ts +178 -0
- package/dist/src/facts/schema.js +37 -1
- package/dist/src/kb/data-category-catalog.generated.d.ts +34 -0
- package/dist/src/kb/data-category-catalog.generated.js +962 -0
- package/dist/src/kb/kb-store.js +4 -1
- package/dist/src/kb/migrate.js +4 -2
- package/dist/src/kb/slot-shapes.d.ts +3 -2
- package/dist/src/kb/slot-shapes.js +13 -8
- package/dist/src/kb/taxonomy.d.ts +12 -6
- package/dist/src/kb/taxonomy.js +13 -18
- package/dist/src/output/scan-output-excludes.js +2 -0
- package/dist/src/output/write-scan-knowledge.d.ts +5 -1
- package/dist/src/output/write-scan-knowledge.js +21 -0
- package/dist/src/threat-model/build-threat-model.d.ts +3 -0
- package/dist/src/threat-model/build-threat-model.js +71 -0
- package/dist/src/threat-model/carry-forward-person-set-statuses.d.ts +8 -0
- package/dist/src/threat-model/carry-forward-person-set-statuses.js +87 -0
- package/dist/src/threat-model/io.d.ts +19 -0
- package/dist/src/threat-model/io.js +63 -0
- package/dist/src/threat-model/schema.d.ts +214 -0
- package/dist/src/threat-model/schema.js +75 -0
- package/dist/src/ui/scan-progress-renderer.d.ts +8 -1
- package/dist/src/ui/scan-progress-renderer.js +20 -1
- package/dist/src/upload/collect-scan-sidecars.d.ts +2 -1
- package/dist/src/upload/collect-scan-sidecars.js +3 -1
- package/dist/tests/cli/cli.spec.js +10 -1
- package/dist/tests/helpers/facts-fixture.js +16 -16
- package/dist/tests/schema/scan-result.schema.spec.js +1 -1
- package/dist/tests/unit/ai-enrichment/provider-contract.spec.js +1 -1
- package/dist/tests/unit/ai-enrichment/third-party-data-flow.spec.js +5 -5
- package/dist/tests/unit/core/graph-mapping.spec.js +4 -3
- package/dist/tests/unit/discoveries/write-ocsf-discoveries-long-ids.spec.js +3 -3
- package/dist/tests/unit/export/export-ocsf.spec.js +4 -4
- package/dist/tests/unit/facts/apply-answers.spec.js +20 -20
- package/dist/tests/unit/facts/build-facts.spec.js +143 -45
- package/dist/tests/unit/facts/identity.spec.js +13 -0
- package/dist/tests/unit/facts/scan-stamps.spec.js +32 -0
- package/dist/tests/unit/facts/slug.spec.js +2 -0
- package/dist/tests/unit/kb/answer-fingerprint.spec.js +9 -9
- package/dist/tests/unit/kb/data-category-catalog.spec.d.ts +1 -0
- package/dist/tests/unit/kb/data-category-catalog.spec.js +65 -0
- package/dist/tests/unit/kb/kb-interview-loop.spec.js +8 -7
- package/dist/tests/unit/kb/migrate.spec.js +2 -2
- package/dist/tests/unit/output/scan-output-excludes.spec.js +1 -1
- package/dist/tests/unit/threat-model/build-threat-model.spec.d.ts +1 -0
- package/dist/tests/unit/threat-model/build-threat-model.spec.js +189 -0
- package/dist/tests/unit/threat-model/carry-forward-person-set-statuses.spec.d.ts +1 -0
- package/dist/tests/unit/threat-model/carry-forward-person-set-statuses.spec.js +163 -0
- package/dist/tests/unit/threat-model/io.spec.d.ts +1 -0
- package/dist/tests/unit/threat-model/io.spec.js +103 -0
- package/dist/tests/unit/threat-model/schema.spec.d.ts +1 -0
- package/dist/tests/unit/threat-model/schema.spec.js +42 -0
- package/dist/tests/unit/ui/scan-progress-renderer.spec.js +58 -0
- package/dist/tests/unit/upload/collect-scan-sidecars.spec.js +8 -5
- package/dist/vendor/scanner/dist/src/analyze/code-navigator.d.ts +1 -1
- package/dist/vendor/scanner/dist/src/analyze/code-navigator.js +4 -0
- package/dist/vendor/scanner/dist/src/analyze/column-catalog.d.ts +1 -1
- package/dist/vendor/scanner/dist/src/analyze/column-catalog.js +2 -2
- package/dist/vendor/scanner/dist/src/analyze/concept-profile.d.ts +2 -2
- package/dist/vendor/scanner/dist/src/analyze/concept-profile.js +5 -3
- package/dist/vendor/scanner/dist/src/core/pipeline/build-scan-personal-data-layers.js +1 -1
- package/dist/vendor/scanner/dist/src/core/pipeline/deterministic-scan.js +43 -0
- package/dist/vendor/scanner/dist/src/core/pipeline/graph-mapping.js +23 -2
- package/dist/vendor/scanner/dist/src/core/pipeline/mixed-app-terraform-scan.js +1 -0
- package/dist/vendor/scanner/dist/src/core/pipeline/orchestrator-result.d.ts +2 -2
- package/dist/vendor/scanner/dist/src/core/pipeline/terraform-minimal-services.js +1 -0
- package/dist/vendor/scanner/dist/src/core/schema/scan-result.schema.d.ts +160 -2
- package/dist/vendor/scanner/dist/src/core/schema/scan-result.schema.js +24 -0
- package/dist/vendor/scanner/dist/src/core/types/data-flow.d.ts +48 -0
- package/dist/vendor/scanner/dist/src/core/types/data-flow.js +53 -0
- package/dist/vendor/scanner/dist/src/data-flow/detect.js +1 -0
- package/dist/vendor/scanner/dist/src/data-flow/ensure-hub-linked-assets.js +1 -0
- package/dist/vendor/scanner/dist/src/data-flow/ensure-manifest-declared-flows.js +1 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-authentication.d.ts +30 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-authentication.js +277 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-builder.js +6 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-controls.d.ts +24 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-controls.js +238 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-data-categories.d.ts +22 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-data-categories.js +69 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-interaction-description.d.ts +13 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-interaction-description.js +263 -0
- package/dist/vendor/scanner/dist/src/data-flow/hub-link-policy.d.ts +2 -1
- package/dist/vendor/scanner/dist/src/data-flow/hub-link-policy.js +3 -0
- package/dist/vendor/scanner/dist/src/data-flow/human-interaction-channels.d.ts +37 -0
- package/dist/vendor/scanner/dist/src/data-flow/human-interaction-channels.js +483 -0
- package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.d.ts +3 -0
- package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.js +12 -17
- package/dist/vendor/scanner/dist/src/data-flow/terraform-flows.js +5 -1
- package/dist/vendor/scanner/dist/src/data-flow/transformation-patterns.d.ts +5 -1
- package/dist/vendor/scanner/dist/src/data-flow/transformation-patterns.js +17 -37
- package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.d.ts +36 -5
- package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.js +53 -60
- package/dist/vendor/scanner/dist/src/eval/canonical/graph/endpoints.js +2 -9
- package/dist/vendor/scanner/dist/src/eval/canonical/scanner/personal-data.js +10 -7
- package/dist/vendor/scanner/dist/src/graph/build-dataparade-graph.js +3 -1
- package/dist/vendor/scanner/dist/src/index.d.ts +6 -0
- package/dist/vendor/scanner/dist/src/index.js +16 -1
- package/dist/vendor/scanner/dist/src/patterns/engine.js +1 -0
- package/dist/vendor/scanner/dist/src/pii-signals/match-pii-signals.d.ts +1 -1
- package/dist/vendor/scanner/dist/src/pii-signals/match-pii-signals.js +2 -2
- package/dist/vendor/scanner/dist/src/pii-signals/occurrence-group.d.ts +3 -3
- package/dist/vendor/scanner/dist/src/pii-signals/occurrence-group.js +12 -11
- package/dist/vendor/scanner/dist/src/pii-signals/personal-data-taxonomy.d.ts +44 -0
- package/dist/vendor/scanner/dist/src/pii-signals/personal-data-taxonomy.js +167 -0
- package/dist/vendor/scanner/dist/src/pii-signals/pii-signal-aliases.js +43 -43
- package/dist/vendor/scanner/dist/src/pii-signals/pii-signal-rules.d.ts +12 -1
- package/dist/vendor/scanner/dist/src/pii-signals/pii-signal-rules.js +28 -7
- package/dist/vendor/scanner/dist/src/pii-signals/signal-token.js +1 -1
- package/dist/vendor/scanner/dist/src/threats/stride.d.ts +98 -0
- package/dist/vendor/scanner/dist/src/threats/stride.js +179 -0
- package/dist/vendor/scanner/package.json +2 -2
- package/dist/vendor/scanner/patterns/concept-profiles.yaml +2 -2
- package/dist/vendor/scanner/patterns/flow-authentication.rules.yaml +75 -0
- package/dist/vendor/scanner/patterns/flow-controls.rules.yaml +68 -0
- package/dist/vendor/scanner/patterns/personal-data-taxonomy.yaml +155 -0
- package/dist/vendor/scanner/patterns/pii-signals.rules.yaml +38 -49
- package/dist/vendor/scanner/patterns/stride.rules.yaml +86 -0
- package/package.json +4 -4
- package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.validate.d.ts +0 -17
- package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.validate.js +0 -108
- package/dist/vendor/scanner/patterns/personal-data-concept-map.yaml +0 -76
package/README.md
CHANGED
|
@@ -126,6 +126,7 @@ By default, a scan writes these files to `./.dataparade/`:
|
|
|
126
126
|
| --- | --- |
|
|
127
127
|
| `dataflow.json` | The diagram the web app imports: a wrapper with `schemaVersion`, `graph` (`DiagramGraphJson`: nodes, edges, viewport) and `metadata` (files scanned, duration, C4 `hierarchy`, etc.). |
|
|
128
128
|
| `facts.json` | What the latest scan found: components, data flows, data items (with groups) and the links between them. Replaced on every scan. |
|
|
129
|
+
| `threat-model.json` | STRIDE threat categories for each component and data flow, with the status the scan's rules give and a separate status a person can set. A rescan keeps the person-set status. |
|
|
129
130
|
| `data-items/<name>.json` | One file per data item, with every place it occurs in the code. |
|
|
130
131
|
| `graphify.json` | The code-structure graph from [Graphify](https://github.com/Graphify-Labs/graphify), when it is installed. |
|
|
131
132
|
| `answers.json` | People's decisions (interview answers, reviews). A scan never writes or changes it. |
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dataparade/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "dataPARADE CLI — scan codebases for privacy and security data flows",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"eval:models": "pnpm exec node dist/src/evals/run-model-matrix.js"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@clack/prompts": "^1.
|
|
58
|
+
"@clack/prompts": "^1.9.0",
|
|
59
59
|
"@sentry/node": "^10.75.2",
|
|
60
60
|
"commander": "^14.0.3",
|
|
61
61
|
"dotenv": "^16.4.7",
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
"zod": "^4.3.5"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@dataparade/scanner": "github:DataParade-io/scanner#
|
|
70
|
+
"@dataparade/scanner": "github:DataParade-io/scanner#798ba353eff174ae0210df166c55ea6aef351b97",
|
|
71
71
|
"@eslint/js": "^9.18.0",
|
|
72
72
|
"@types/jest": "^30.0.0",
|
|
73
73
|
"@types/node": "^22.0.0",
|
|
74
74
|
"eslint": "^9.18.0",
|
|
75
75
|
"globals": "^15.14.0",
|
|
76
76
|
"jest": "^30.5.2",
|
|
77
|
-
"ts-jest": "^29.4.
|
|
77
|
+
"ts-jest": "^29.4.15",
|
|
78
78
|
"typescript-eslint": "^8.20.0"
|
|
79
79
|
},
|
|
80
80
|
"files": [
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A scanner detector rule. Its `id` is the personal-data type it detects, a W3C DPV concept
|
|
3
|
+
* CURIE from the scanner's patterns/personal-data-taxonomy.yaml (`pd:EmailAddress`,
|
|
4
|
+
* `dpx:FirstName`; DATAP-947). `labels` is that type, which `dataShared` reports.
|
|
5
|
+
*/
|
|
1
6
|
export interface PiiSignalRule {
|
|
2
7
|
id: string;
|
|
3
8
|
category: "identifiers" | "profile_data" | "credentials";
|
|
@@ -13,7 +13,6 @@ const scanner_package_root_1 = require("../scanner-package-root");
|
|
|
13
13
|
const piiSignalRuleSchema = zod_1.z.object({
|
|
14
14
|
id: zod_1.z.string().min(1),
|
|
15
15
|
category: zod_1.z.enum(["identifiers", "profile_data", "credentials"]),
|
|
16
|
-
labels: zod_1.z.array(zod_1.z.string().min(1)).default([]),
|
|
17
16
|
patterns: zod_1.z.array(zod_1.z.string().min(1)).default([]),
|
|
18
17
|
});
|
|
19
18
|
const piiSignalCatalogSchema = zod_1.z.object({
|
|
@@ -55,9 +54,9 @@ function loadPiiSignalRules() {
|
|
|
55
54
|
throw new Error(`PII signal rules at '${configPath}' failed schema validation: ${message}`);
|
|
56
55
|
}
|
|
57
56
|
cachedRules = normalized.pii_signal_rules.map((rule) => ({
|
|
58
|
-
id: rule.id.trim()
|
|
57
|
+
id: rule.id.trim(),
|
|
59
58
|
category: rule.category,
|
|
60
|
-
labels: rule.
|
|
59
|
+
labels: [rule.id.trim()],
|
|
61
60
|
patterns: rule.patterns.map((pattern) => new RegExp(pattern, "i")),
|
|
62
61
|
}));
|
|
63
62
|
return cachedRules;
|
|
@@ -247,6 +247,7 @@ function buildProviderPromptPayload(input) {
|
|
|
247
247
|
'Propose `relay` only when cited code/config corroborates passthrough/proxy/gateway behavior; otherwise omit relay. ' +
|
|
248
248
|
'Cite `propertyEvidence.data_action` with filePath + line range + reason for every verb you assert. ' +
|
|
249
249
|
'Other multi-value fields such as `data_categories_received`, `supported_export_formats`, `cloud_services_used`, `regions_availability_zones` must be string arrays, not one comma-joined string. ' +
|
|
250
|
+
'`data_categories_received` values are W3C DPV data category concepts written as compact IRIs, such as `pd:EmailAddress`, `pd:Financial`, `pd:Authenticating` or `dpv:NonPersonalData`; use `dpv:UncategorisedData` when none fits. ' +
|
|
250
251
|
'Booleans must be true/false (not strings). Prefer enum-like values in lowercase snake_case (e.g. integration_status: "active"). ' +
|
|
251
252
|
'For any field that corresponds to an app dropdown or multi-select, use the product\'s option tokens (snake_case / exact strings) — e.g. legal_basis: "contractual_necessity" not "contract"; pci_scope: "saq_d" not "full"; data_transfer_mechanism: "standard_contractual_clauses" not raw "HTTPS"; risk_rating and encrypt_at_rest must match allowed values.';
|
|
252
253
|
const groundedInstructions = "Walk every key in sparsePropertyKeys and emit every key you can **ground in code/config text**. You may output multiple component_patch proposals for one target when each patch has a different, disjoint key set. Use propertiesSet as truth for fields already set and never rewrite those values. For every key in setProperties, **propertyEvidence[key]** must be a non-empty array citing filePath + startLine/endLine + reason where that key's value appears in relevantFileContents (when provided) or in the file paths listed on that component in detectedFrom/sourceLocations. If you cannot tie a property to cited text or a cited path, **omit that key**. Indirect guesses are not allowed. It is valid to return **no proposals** only when no sparse key can be cited. Never invent URLs, vendor names, analytics products, retention numbers, or compliance labels without a literal basis in the excerpts or cited lines. `targetComponentId` must be exactly one of canonicalComponentIds (componentContext keys). ";
|
|
@@ -5,6 +5,7 @@ exports.buildProposalsValidationContext = buildProposalsValidationContext;
|
|
|
5
5
|
exports.parseAgentFromPrompt = parseAgentFromPrompt;
|
|
6
6
|
exports.aiDebugEnabled = aiDebugEnabled;
|
|
7
7
|
exports.strictParseAndNormalizeProposals = strictParseAndNormalizeProposals;
|
|
8
|
+
const data_category_catalog_generated_1 = require("../../kb/data-category-catalog.generated");
|
|
8
9
|
const scanner_1 = require("../../../vendor/scanner/dist/src/index.js");
|
|
9
10
|
const openai_proposals_response_schema_1 = require("../openai-proposals-response.schema");
|
|
10
11
|
const scan_paths_1 = require("../scan-paths");
|
|
@@ -195,49 +196,6 @@ function sanitizeSetProperties(raw) {
|
|
|
195
196
|
}
|
|
196
197
|
return sanitized;
|
|
197
198
|
}
|
|
198
|
-
const UI_DATA_CATEGORY_ALLOWED = new Set([
|
|
199
|
-
"personal_identifiers",
|
|
200
|
-
"contact_information",
|
|
201
|
-
"financial_information",
|
|
202
|
-
"health_data",
|
|
203
|
-
"biometric_data",
|
|
204
|
-
"location_data",
|
|
205
|
-
"behavioral_data",
|
|
206
|
-
"employment_data",
|
|
207
|
-
"education_data",
|
|
208
|
-
"special_category_data",
|
|
209
|
-
"criminal_records",
|
|
210
|
-
"demographic_data",
|
|
211
|
-
"online_identifiers",
|
|
212
|
-
"device_identifiers",
|
|
213
|
-
"usage_data",
|
|
214
|
-
"aggregated_analytics",
|
|
215
|
-
"financial_data",
|
|
216
|
-
"geolocation_gps",
|
|
217
|
-
"geolocation_ip",
|
|
218
|
-
"photos_selfies",
|
|
219
|
-
"professional_data",
|
|
220
|
-
"sensitive_personal_data",
|
|
221
|
-
"special_categories",
|
|
222
|
-
"user_identity_direct",
|
|
223
|
-
"user_identity_indirect",
|
|
224
|
-
"other",
|
|
225
|
-
]);
|
|
226
|
-
const UI_DATA_CATEGORY_ALIASES = {
|
|
227
|
-
personal_data: "user_identity_direct",
|
|
228
|
-
pii: "user_identity_direct",
|
|
229
|
-
personally_identifiable_information: "user_identity_direct",
|
|
230
|
-
document_files: "other",
|
|
231
|
-
document_metadata: "other",
|
|
232
|
-
file_content: "other",
|
|
233
|
-
file_metadata: "other",
|
|
234
|
-
email_address: "contact_information",
|
|
235
|
-
credit_card_data: "financial_data",
|
|
236
|
-
payment_data: "financial_data",
|
|
237
|
-
phi: "health_data",
|
|
238
|
-
ip_address: "geolocation_ip",
|
|
239
|
-
device_id: "device_identifiers",
|
|
240
|
-
};
|
|
241
199
|
const UI_PROCESSING_PURPOSE_ALLOWED = new Set([
|
|
242
200
|
"authentication",
|
|
243
201
|
"service_provision",
|
|
@@ -375,7 +333,7 @@ function normalizeThirdPartySetPropertiesForUi(input) {
|
|
|
375
333
|
const evidenceSourceByKey = {};
|
|
376
334
|
if (Object.prototype.hasOwnProperty.call(normalized, "data_categories_received")) {
|
|
377
335
|
const values = toStringArray(normalized.data_categories_received);
|
|
378
|
-
const mapped =
|
|
336
|
+
const mapped = (0, data_category_catalog_generated_1.resolveDataCategoryValues)(values);
|
|
379
337
|
if (mapped.length > 0)
|
|
380
338
|
normalized.data_categories_received = mapped;
|
|
381
339
|
else
|
|
@@ -34,22 +34,23 @@ function resolveComponentId(id, remap) {
|
|
|
34
34
|
}
|
|
35
35
|
const OPERATION_RE = /\b(fetch|axios|request|invoke|send|post|get|put|patch|delete|upload|download|signIn|signOut|auth|token|storage|bucket|client|generateContent|chat|completions|models)\b/i;
|
|
36
36
|
const AI_VENDOR_TOKEN_RE = /\b(openai|googleai|gemini|anthropic|claude|mistral|cohere|vertex|vertexai|generativeai|generativelanguage|genai)\b/i;
|
|
37
|
+
/** Personal-data labels are W3C DPV concepts from the scanner taxonomy (DATAP-947). */
|
|
37
38
|
const PATTERN_RULES = [
|
|
38
39
|
{
|
|
39
40
|
re: /\b(card|payment|invoice|iban|bank[_-]?account|checkout)\b/i,
|
|
40
41
|
category: "financial",
|
|
41
|
-
labels: ["
|
|
42
|
+
labels: ["pd:Financial"],
|
|
42
43
|
capabilities: ["payments"],
|
|
43
44
|
},
|
|
44
45
|
{
|
|
45
46
|
re: /\b(patient|diagnosis|medical|health|phi)\b/i,
|
|
46
47
|
category: "health",
|
|
47
|
-
labels: ["
|
|
48
|
+
labels: ["pd:MedicalHealth"],
|
|
48
49
|
},
|
|
49
50
|
{
|
|
50
51
|
re: /\b(user[_-]?id|customer[_-]?id|ip[_-]?address|ip)\b/i,
|
|
51
52
|
category: "identifiers",
|
|
52
|
-
labels: ["
|
|
53
|
+
labels: ["pd:UID"],
|
|
53
54
|
},
|
|
54
55
|
];
|
|
55
56
|
function toBand(score) {
|
|
@@ -357,7 +358,7 @@ function inferDataSharedFromEvidenceReasons(evidence) {
|
|
|
357
358
|
}
|
|
358
359
|
if (/\b(db_password|password)\b/.test(text)) {
|
|
359
360
|
const labels = labelsByCategory.get("credentials") ?? new Set();
|
|
360
|
-
labels.add("
|
|
361
|
+
labels.add("pd:Password");
|
|
361
362
|
labelsByCategory.set("credentials", labels);
|
|
362
363
|
capabilities.add("auth");
|
|
363
364
|
directionHints.add("outbound_to_third_party");
|
package/dist/src/cli.js
CHANGED
|
@@ -322,6 +322,7 @@ function createProgram() {
|
|
|
322
322
|
(0, git_context_1.detectGitContext)(scanEntry.scanRootDir) ?? undefined;
|
|
323
323
|
// Read before the scan writes anything, so its own output never counts as a change (DATAP-876).
|
|
324
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);
|
|
325
|
+
const gitBranch = (0, scan_stamps_1.readGitBranch)(scanEntry.scanRootDir);
|
|
325
326
|
const [{ createDefaultScanConfiguration }, { runScanPipeline }, { buildDiagramGraphFromScanResult },] = await Promise.all([
|
|
326
327
|
Promise.resolve().then(() => __importStar(require('./core/pipeline/orchestrator'))),
|
|
327
328
|
Promise.resolve().then(() => __importStar(require('./core/pipeline/scan-pipeline'))),
|
|
@@ -646,7 +647,7 @@ function createProgram() {
|
|
|
646
647
|
gitContext: parsedGitContext,
|
|
647
648
|
hierarchy,
|
|
648
649
|
});
|
|
649
|
-
(0, write_scan_knowledge_1.writeScanFacts)(layout, {
|
|
650
|
+
const builtScanFacts = (0, write_scan_knowledge_1.writeScanFacts)(layout, {
|
|
650
651
|
knowledge,
|
|
651
652
|
scanRoot: scanEntry.scanRootDir,
|
|
652
653
|
projectName: resolvedProjectName,
|
|
@@ -661,7 +662,12 @@ function createProgram() {
|
|
|
661
662
|
structureGraph: Boolean(knowledge.result.structureGraph),
|
|
662
663
|
git: gitStamps,
|
|
663
664
|
}),
|
|
665
|
+
gitBranch,
|
|
664
666
|
});
|
|
667
|
+
const threatModelCarryForward = (0, write_scan_knowledge_1.writeScanThreatModel)(layout, builtScanFacts.facts);
|
|
668
|
+
if (threatModelCarryForward.unmatchedCount > 0) {
|
|
669
|
+
ui.warn(`${threatModelCarryForward.unmatchedCount} person-set threat status(es) no longer match a threat; they are kept under unmatchedPersonSetStatuses in threat-model.json.`);
|
|
670
|
+
}
|
|
665
671
|
if (options.sensitiveScan !== false) {
|
|
666
672
|
ui.sensitiveScanMessage('Scanning for sensitive information with LeftBlock');
|
|
667
673
|
}
|
|
@@ -682,7 +688,7 @@ function createProgram() {
|
|
|
682
688
|
if (!friendlyTty) {
|
|
683
689
|
console.log(`[scan] dataflow.json written to ${dataflowOutputPath}`);
|
|
684
690
|
}
|
|
685
|
-
console.log(`[scan] facts.json and data-items/ written to ${layout.dir}`);
|
|
691
|
+
console.log(`[scan] facts.json, threat-model.json and data-items/ written to ${layout.dir}`);
|
|
686
692
|
const skipAutoUpload = Boolean(options.skipAutoUpload) ||
|
|
687
693
|
(0, upload_env_1.resolveSkipAutoUpload)(process.env);
|
|
688
694
|
if (!skipAutoUpload) {
|
|
@@ -726,7 +732,7 @@ function createProgram() {
|
|
|
726
732
|
progressUi.onUploadFailed(describeAutoUploadFailure(uploadError, dataflowOutputPath, Boolean(workspaceApiKey)));
|
|
727
733
|
}
|
|
728
734
|
}
|
|
729
|
-
ui.finish();
|
|
735
|
+
ui.finish({ scanDurationMs: scanResult.scanDurationMs });
|
|
730
736
|
}
|
|
731
737
|
catch (dataflowError) {
|
|
732
738
|
reportedFailure = {
|
|
@@ -28,7 +28,10 @@ export declare const ocsfDiscoveryRecordSchema: z.ZodObject<{
|
|
|
28
28
|
}, z.core.$strip>>>;
|
|
29
29
|
dataparade: z.ZodObject<{
|
|
30
30
|
record_kind: z.ZodLiteral<"discovery">;
|
|
31
|
-
ontology_version: z.
|
|
31
|
+
ontology_version: z.ZodEnum<{
|
|
32
|
+
"0.4.0": "0.4.0";
|
|
33
|
+
"0.3.0": "0.3.0";
|
|
34
|
+
}>;
|
|
32
35
|
source: z.ZodEnum<{
|
|
33
36
|
scan: "scan";
|
|
34
37
|
interview: "interview";
|
|
@@ -14,7 +14,7 @@ const fullShaSchema = zod_1.z.string().regex(/^[0-9a-f]{40}$/, "must be a full 4
|
|
|
14
14
|
const dataparadePayloadSchema = zod_1.z
|
|
15
15
|
.object({
|
|
16
16
|
record_kind: zod_1.z.literal("discovery"),
|
|
17
|
-
ontology_version: zod_1.z.
|
|
17
|
+
ontology_version: zod_1.z.enum(ontology_pins_1.READABLE_ONTOLOGY_VERSIONS),
|
|
18
18
|
source: zod_1.z.enum(["scan", "cloud", "interview"]),
|
|
19
19
|
asserted_at: zod_1.z.string().datetime(),
|
|
20
20
|
asserts: zod_1.z.string().min(1),
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
/** Ontology pin: DataParade-io/ontology v0.
|
|
2
|
-
export declare const PINNED_ONTOLOGY_VERSION = "0.
|
|
3
|
-
export declare const PINNED_ONTOLOGY_TAG = "v0.
|
|
4
|
-
export declare const PINNED_ONTOLOGY_SHA = "
|
|
1
|
+
/** Ontology pin: DataParade-io/ontology v0.4.0 (DataCategory as W3C DPV concepts, DATAP-961; OCSF Architecture Discovery extension since 0.3.0, DATAP-696). */
|
|
2
|
+
export declare const PINNED_ONTOLOGY_VERSION = "0.4.0";
|
|
3
|
+
export declare const PINNED_ONTOLOGY_TAG = "v0.4.0";
|
|
4
|
+
export declare const PINNED_ONTOLOGY_SHA = "5b13b7224c8ea6e53a1b3e90ce14140db040530e";
|
|
5
|
+
/** Ontology versions whose Discovery records still load, so older KB folders can be read and migrated. */
|
|
6
|
+
export declare const READABLE_ONTOLOGY_VERSIONS: readonly ["0.3.0", "0.4.0"];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PINNED_ONTOLOGY_SHA = exports.PINNED_ONTOLOGY_TAG = exports.PINNED_ONTOLOGY_VERSION = void 0;
|
|
4
|
-
/** Ontology pin: DataParade-io/ontology v0.
|
|
5
|
-
exports.PINNED_ONTOLOGY_VERSION = "0.
|
|
6
|
-
exports.PINNED_ONTOLOGY_TAG = "v0.
|
|
7
|
-
exports.PINNED_ONTOLOGY_SHA = "
|
|
3
|
+
exports.READABLE_ONTOLOGY_VERSIONS = exports.PINNED_ONTOLOGY_SHA = exports.PINNED_ONTOLOGY_TAG = exports.PINNED_ONTOLOGY_VERSION = void 0;
|
|
4
|
+
/** Ontology pin: DataParade-io/ontology v0.4.0 (DataCategory as W3C DPV concepts, DATAP-961; OCSF Architecture Discovery extension since 0.3.0, DATAP-696). */
|
|
5
|
+
exports.PINNED_ONTOLOGY_VERSION = "0.4.0";
|
|
6
|
+
exports.PINNED_ONTOLOGY_TAG = "v0.4.0";
|
|
7
|
+
exports.PINNED_ONTOLOGY_SHA = "5b13b7224c8ea6e53a1b3e90ce14140db040530e";
|
|
8
|
+
/** Ontology versions whose Discovery records still load, so older KB folders can be read and migrated. */
|
|
9
|
+
exports.READABLE_ONTOLOGY_VERSIONS = ["0.3.0", exports.PINNED_ONTOLOGY_VERSION];
|
|
@@ -13,6 +13,8 @@ export interface BuildFactsInput {
|
|
|
13
13
|
scannedAt?: string;
|
|
14
14
|
/** Scan stamps (DATAP-876); left out of facts.json when not given. */
|
|
15
15
|
stamps?: ScanStamps;
|
|
16
|
+
/** The checked-out Git branch (DATAP-925); left out of facts.json when not given. */
|
|
17
|
+
gitBranch?: string | null;
|
|
16
18
|
}
|
|
17
19
|
export interface BuiltFacts {
|
|
18
20
|
facts: FactsFile;
|
|
@@ -115,9 +115,26 @@ function buildFacts(input) {
|
|
|
115
115
|
targetComponentId: scrub(f.targetComponentId),
|
|
116
116
|
type: f.type,
|
|
117
117
|
...(f.targetScope !== undefined ? { targetScope: f.targetScope } : {}),
|
|
118
|
+
...(f.dataCategories !== undefined ? { dataCategories: [...f.dataCategories].sort() } : {}),
|
|
119
|
+
...(f.relationship !== undefined ? { relationship: f.relationship } : {}),
|
|
120
|
+
...(f.protocol !== undefined ? { protocol: f.protocol } : {}),
|
|
121
|
+
...(f.transport !== undefined ? { transport: f.transport } : {}),
|
|
122
|
+
...(f.channel !== undefined ? { channel: f.channel } : {}),
|
|
118
123
|
confidence: f.confidence,
|
|
119
124
|
sourceLocations: locations(f.sourceLocations ?? (f.sourceLocation ? [f.sourceLocation] : [])),
|
|
120
125
|
codeRefs: refsFor(scrub(f.id)),
|
|
126
|
+
...(f.authentication
|
|
127
|
+
? {
|
|
128
|
+
authentication: {
|
|
129
|
+
status: f.authentication.status,
|
|
130
|
+
kinds: [...f.authentication.kinds],
|
|
131
|
+
evidence: f.authentication.evidence.map((e) => ({ kind: e.kind, filePath: scrub(e.filePath), line: e.line })),
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
: {}),
|
|
135
|
+
...(f.controls
|
|
136
|
+
? { controls: f.controls.map((e) => ({ control: e.control, effect: e.effect, filePath: scrub(e.filePath), line: e.line })) }
|
|
137
|
+
: {}),
|
|
121
138
|
}));
|
|
122
139
|
// Data items.
|
|
123
140
|
const occurrenceById = new Map(result.occurrences.map((o) => [o.id, o]));
|
|
@@ -196,6 +213,7 @@ function buildFacts(input) {
|
|
|
196
213
|
cliVersion: input.cliVersion,
|
|
197
214
|
scannerVersion: input.scannerVersion,
|
|
198
215
|
...(input.stamps ? { stamps: input.stamps } : {}),
|
|
216
|
+
...(input.gitBranch !== undefined ? { gitBranch: input.gitBranch } : {}),
|
|
199
217
|
},
|
|
200
218
|
components: byId(components),
|
|
201
219
|
dataFlows: byId(dataFlows),
|
|
@@ -7,6 +7,8 @@ export declare const FACTS_BASENAME = "facts.json";
|
|
|
7
7
|
export declare const DATA_ITEMS_DIRNAME = "data-items";
|
|
8
8
|
export declare const GRAPHIFY_BASENAME = "graphify.json";
|
|
9
9
|
export declare const ANSWERS_BASENAME = "answers.json";
|
|
10
|
+
export declare const THREAT_MODEL_BASENAME = "threat-model.json";
|
|
11
|
+
export declare const THREAT_MODEL_UNREADABLE_COPY_BASENAME = "threat-model.unreadable.json";
|
|
10
12
|
/** Every file and folder a scan or `dataparade kb` keeps in the output folder. */
|
|
11
13
|
export interface OutputLayout {
|
|
12
14
|
/** The output folder, i.e. the folder that holds dataflow.json. */
|
|
@@ -16,6 +18,8 @@ export interface OutputLayout {
|
|
|
16
18
|
dataItemsDir: string;
|
|
17
19
|
graphifyPath: string;
|
|
18
20
|
answersPath: string;
|
|
21
|
+
threatModelPath: string;
|
|
22
|
+
threatModelUnreadableCopyPath: string;
|
|
19
23
|
/** Interview briefs (`dataparade kb brief`). */
|
|
20
24
|
briefsDir: string;
|
|
21
25
|
/** Unedited interview transcripts. */
|
package/dist/src/facts/layout.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ANSWERS_BASENAME = exports.GRAPHIFY_BASENAME = exports.DATA_ITEMS_DIRNAME = exports.FACTS_BASENAME = exports.DATAFLOW_BASENAME = exports.DEFAULT_DATAFLOW_OUTPUT = exports.DEFAULT_OUTPUT_DIRNAME = void 0;
|
|
6
|
+
exports.THREAT_MODEL_UNREADABLE_COPY_BASENAME = exports.THREAT_MODEL_BASENAME = exports.ANSWERS_BASENAME = exports.GRAPHIFY_BASENAME = exports.DATA_ITEMS_DIRNAME = exports.FACTS_BASENAME = exports.DATAFLOW_BASENAME = exports.DEFAULT_DATAFLOW_OUTPUT = exports.DEFAULT_OUTPUT_DIRNAME = void 0;
|
|
7
7
|
exports.resolveOutputLayout = resolveOutputLayout;
|
|
8
8
|
exports.layoutForDir = layoutForDir;
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -16,6 +16,8 @@ exports.FACTS_BASENAME = "facts.json";
|
|
|
16
16
|
exports.DATA_ITEMS_DIRNAME = "data-items";
|
|
17
17
|
exports.GRAPHIFY_BASENAME = "graphify.json";
|
|
18
18
|
exports.ANSWERS_BASENAME = "answers.json";
|
|
19
|
+
exports.THREAT_MODEL_BASENAME = "threat-model.json";
|
|
20
|
+
exports.THREAT_MODEL_UNREADABLE_COPY_BASENAME = "threat-model.unreadable.json";
|
|
19
21
|
/** `-o/--output` names dataflow.json; every other file sits next to it. */
|
|
20
22
|
function resolveOutputLayout(dataflowOutputPath) {
|
|
21
23
|
const dataflowPath = path_1.default.resolve(dataflowOutputPath);
|
|
@@ -31,6 +33,8 @@ function layoutForDir(dir, dataflowPath) {
|
|
|
31
33
|
dataItemsDir: path_1.default.join(root, exports.DATA_ITEMS_DIRNAME),
|
|
32
34
|
graphifyPath: path_1.default.join(root, exports.GRAPHIFY_BASENAME),
|
|
33
35
|
answersPath: path_1.default.join(root, exports.ANSWERS_BASENAME),
|
|
36
|
+
threatModelPath: path_1.default.join(root, exports.THREAT_MODEL_BASENAME),
|
|
37
|
+
threatModelUnreadableCopyPath: path_1.default.join(root, exports.THREAT_MODEL_UNREADABLE_COPY_BASENAME),
|
|
34
38
|
briefsDir: path_1.default.join(root, "briefs"),
|
|
35
39
|
evidenceDir: path_1.default.join(root, "evidence"),
|
|
36
40
|
diagramPath: path_1.default.join(root, "diagram.json"),
|
|
@@ -42,6 +42,13 @@ export interface GitStamps {
|
|
|
42
42
|
* `fallbackCommitSha` comes from --git-context, for scans of archives that have no .git.
|
|
43
43
|
*/
|
|
44
44
|
export declare function readGitStamps(scanRoot: string, outputDir: string | null, fallbackCommitSha?: string): GitStamps;
|
|
45
|
+
/**
|
|
46
|
+
* The checked-out branch of the repository containing `scanRoot` (DATAP-925). A detached HEAD,
|
|
47
|
+
* as in most CI checkouts, falls back to the CI's branch variable (`GITHUB_HEAD_REF` for a pull
|
|
48
|
+
* request, then `GITHUB_REF_NAME` when `GITHUB_REF_TYPE` is `branch`, then `CI_COMMIT_REF_NAME`
|
|
49
|
+
* on GitLab). Null outside Git and when no branch is known.
|
|
50
|
+
*/
|
|
51
|
+
export declare function readGitBranch(scanRoot: string, environment?: NodeJS.ProcessEnv): string | null;
|
|
45
52
|
export declare function buildScanStamps(input: {
|
|
46
53
|
cliVersion: string;
|
|
47
54
|
scanner: {
|
|
@@ -8,6 +8,7 @@ exports.catalogHash = catalogHash;
|
|
|
8
8
|
exports.scannerBuildInfo = scannerBuildInfo;
|
|
9
9
|
exports.findCliPackageRoot = findCliPackageRoot;
|
|
10
10
|
exports.readGitStamps = readGitStamps;
|
|
11
|
+
exports.readGitBranch = readGitBranch;
|
|
11
12
|
exports.buildScanStamps = buildScanStamps;
|
|
12
13
|
const child_process_1 = require("child_process");
|
|
13
14
|
const crypto_1 = require("crypto");
|
|
@@ -152,6 +153,35 @@ function readGitStamps(scanRoot, outputDir, fallbackCommitSha) {
|
|
|
152
153
|
return { commitSha: fallbackCommitSha ?? null, dirty: fallbackCommitSha ? false : null, rootCommitSha: null, scanRoot: null };
|
|
153
154
|
}
|
|
154
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* The checked-out branch of the repository containing `scanRoot` (DATAP-925). A detached HEAD,
|
|
158
|
+
* as in most CI checkouts, falls back to the CI's branch variable (`GITHUB_HEAD_REF` for a pull
|
|
159
|
+
* request, then `GITHUB_REF_NAME` when `GITHUB_REF_TYPE` is `branch`, then `CI_COMMIT_REF_NAME`
|
|
160
|
+
* on GitLab). Null outside Git and when no branch is known.
|
|
161
|
+
*/
|
|
162
|
+
function readGitBranch(scanRoot, environment = process.env) {
|
|
163
|
+
const branchFromContinuousIntegration = () => {
|
|
164
|
+
const pullRequestHeadBranch = environment.GITHUB_HEAD_REF?.trim();
|
|
165
|
+
if (pullRequestHeadBranch)
|
|
166
|
+
return pullRequestHeadBranch;
|
|
167
|
+
const githubRefName = environment.GITHUB_REF_NAME?.trim();
|
|
168
|
+
if (githubRefName && environment.GITHUB_REF_TYPE === "branch")
|
|
169
|
+
return githubRefName;
|
|
170
|
+
const gitlabRefName = environment.CI_COMMIT_REF_NAME?.trim();
|
|
171
|
+
if (gitlabRefName && !environment.CI_COMMIT_TAG)
|
|
172
|
+
return gitlabRefName;
|
|
173
|
+
return null;
|
|
174
|
+
};
|
|
175
|
+
try {
|
|
176
|
+
const checkedOutBranch = git(scanRoot, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
177
|
+
if (checkedOutBranch && checkedOutBranch !== "HEAD")
|
|
178
|
+
return checkedOutBranch;
|
|
179
|
+
return branchFromContinuousIntegration();
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
155
185
|
function buildScanStamps(input) {
|
|
156
186
|
return {
|
|
157
187
|
scannerCommit: input.scanner.scannerCommit,
|