@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CROSS_BOUNDARY_PATTERNS = exports.AUTH_FUNCTION_PATTERNS_ADDENDUM = exports.SESSION_COOKIE_PATTERNS_ADDENDUM = exports.ORM_PERSISTENCE_PATTERNS_ADDENDUM = exports.PASSWORD_HASH_PATTERNS_ADDENDUM = exports.MODULE_REEXPORT_PATTERNS = exports.LOOKUP_PATTERNS = exports.PERSONAL_DATA_ASSOCIATION_PATTERNS = exports.RAILS_INITIALIZER_PATTERNS = exports.MODEL_ASSOCIATION_PATTERNS = exports.ROUTE_DECLARATION_PATTERNS = exports.CRYPTO_AUTH_PATTERNS = exports.PERSISTENCE_PATTERNS = exports.ORM_PATTERNS = void 0;
|
|
3
|
+
exports.DATA_CATEGORY_PATTERNS = exports.CROSS_BOUNDARY_PATTERNS = exports.AUTH_FUNCTION_PATTERNS_ADDENDUM = exports.SESSION_COOKIE_PATTERNS_ADDENDUM = exports.ORM_PERSISTENCE_PATTERNS_ADDENDUM = exports.PASSWORD_HASH_PATTERNS_ADDENDUM = exports.MODULE_REEXPORT_PATTERNS = exports.LOOKUP_PATTERNS = exports.PERSONAL_DATA_ASSOCIATION_PATTERNS = exports.RAILS_INITIALIZER_PATTERNS = exports.MODEL_ASSOCIATION_PATTERNS = exports.ROUTE_DECLARATION_PATTERNS = exports.CRYPTO_AUTH_PATTERNS = exports.PERSISTENCE_PATTERNS = exports.ORM_PATTERNS = void 0;
|
|
4
4
|
exports.hasPersonalDataRouteReference = hasPersonalDataRouteReference;
|
|
5
5
|
exports.findEnclosingPersonalDataRouteLine = findEnclosingPersonalDataRouteLine;
|
|
6
6
|
exports.isDeclarationOnlySpan = isDeclarationOnlySpan;
|
|
@@ -13,7 +13,6 @@ exports.hasCrossBoundaryEvidence = hasCrossBoundaryEvidence;
|
|
|
13
13
|
exports.hasIntraComponentTransformationEvidence = hasIntraComponentTransformationEvidence;
|
|
14
14
|
exports.hasStrongTransformationOnSpan = hasStrongTransformationOnSpan;
|
|
15
15
|
exports.inferFlowTypeFromSpan = inferFlowTypeFromSpan;
|
|
16
|
-
exports.piiRuleIdToDataCategory = piiRuleIdToDataCategory;
|
|
17
16
|
exports.inferDataCategoriesFromSpan = inferDataCategoriesFromSpan;
|
|
18
17
|
exports.ORM_PATTERNS = [
|
|
19
18
|
/models\./i,
|
|
@@ -460,9 +459,10 @@ function inferFlowTypeFromSpan(span, contextSpan) {
|
|
|
460
459
|
}
|
|
461
460
|
return "data_transfer";
|
|
462
461
|
}
|
|
463
|
-
|
|
462
|
+
/** Personal-data types (taxonomy concept CURIEs) that a span names, by pattern (DATAP-947). */
|
|
463
|
+
exports.DATA_CATEGORY_PATTERNS = [
|
|
464
464
|
{
|
|
465
|
-
category: "
|
|
465
|
+
category: "pd:Password",
|
|
466
466
|
patterns: [
|
|
467
467
|
/\bpassword\b/i,
|
|
468
468
|
/\bpasswd\b/i,
|
|
@@ -474,9 +474,9 @@ const DATA_CATEGORY_PATTERNS = [
|
|
|
474
474
|
/sendPasswordReset/i,
|
|
475
475
|
],
|
|
476
476
|
},
|
|
477
|
-
{ category: "
|
|
477
|
+
{ category: "pd:EmailAddress", patterns: [/\bemail\b/i, /\bvalidates\s+:email\b/i, /\bvalidates\s+:primary\b/i, /\bEmailToken\b/i] },
|
|
478
478
|
{
|
|
479
|
-
category: "
|
|
479
|
+
category: "dpx:AccessToken",
|
|
480
480
|
patterns: [
|
|
481
481
|
/\baccess_token\b/i,
|
|
482
482
|
/\bid_token\b/i,
|
|
@@ -487,58 +487,38 @@ const DATA_CATEGORY_PATTERNS = [
|
|
|
487
487
|
],
|
|
488
488
|
},
|
|
489
489
|
{
|
|
490
|
-
category: "
|
|
490
|
+
category: "dpx:SessionToken",
|
|
491
491
|
patterns: [/\bsession\b/i, /\bcookie\b/i, /\bsession_store\b/i],
|
|
492
492
|
},
|
|
493
493
|
{
|
|
494
|
-
category: "
|
|
494
|
+
category: "pd:Username",
|
|
495
495
|
patterns: [/\bbelongs_to\s+:customer\b/i, /\bhas_one\s+:user\b/i],
|
|
496
496
|
},
|
|
497
|
-
{ category: "
|
|
498
|
-
{ category: "
|
|
499
|
-
{ category: "
|
|
500
|
-
{ category: "
|
|
497
|
+
{ category: "dpx:SocialSecurityNumber", patterns: [/\bssn\b/i, /social_security/i] },
|
|
498
|
+
{ category: "pd:TelephoneNumber", patterns: [/\bphone\b/i] },
|
|
499
|
+
{ category: "pd:PhysicalAddress", patterns: [/\baddress\b/i] },
|
|
500
|
+
{ category: "pd:PaymentCard", patterns: [/\bcard\b/i, /\bpayment\b/i] },
|
|
501
501
|
];
|
|
502
|
-
const PII_RULE_ID_TO_CATEGORY = {
|
|
503
|
-
email: "email",
|
|
504
|
-
password: "password",
|
|
505
|
-
ssn: "social_security_number",
|
|
506
|
-
address: "address",
|
|
507
|
-
phone_number: "phone_number",
|
|
508
|
-
username: "username",
|
|
509
|
-
first_name: "first_name",
|
|
510
|
-
last_name: "last_name",
|
|
511
|
-
full_name: "full_name",
|
|
512
|
-
date_of_birth: "date_of_birth",
|
|
513
|
-
passport: "passport_number",
|
|
514
|
-
national_id: "national_id",
|
|
515
|
-
drivers_license: "drivers_license_number",
|
|
516
|
-
tax_id: "tax_identifier",
|
|
517
|
-
account_number: "account_number",
|
|
518
|
-
};
|
|
519
|
-
function piiRuleIdToDataCategory(ruleId) {
|
|
520
|
-
return PII_RULE_ID_TO_CATEGORY[ruleId] ?? ruleId;
|
|
521
|
-
}
|
|
522
502
|
function inferDataCategoriesFromSpan(span, contextSpan) {
|
|
523
503
|
const text = `${span}\n${contextSpan}`;
|
|
524
504
|
const categories = new Set();
|
|
525
|
-
for (const entry of DATA_CATEGORY_PATTERNS) {
|
|
505
|
+
for (const entry of exports.DATA_CATEGORY_PATTERNS) {
|
|
526
506
|
if (entry.patterns.some((pattern) => pattern.test(text))) {
|
|
527
507
|
categories.add(entry.category);
|
|
528
508
|
}
|
|
529
509
|
}
|
|
530
510
|
if (hasPersonalDataAssociationReference(span, contextSpan)) {
|
|
531
511
|
if (/password|user_password|hashed_password|check_password|has_secure_password/i.test(text)) {
|
|
532
|
-
categories.add("
|
|
512
|
+
categories.add("pd:Password");
|
|
533
513
|
}
|
|
534
514
|
if (/\b(?:validates|normalizes)\s+:email\b|:email\b|primary_email|user_email|:primary\b/i.test(text)) {
|
|
535
|
-
categories.add("
|
|
515
|
+
categories.add("pd:EmailAddress");
|
|
536
516
|
}
|
|
537
517
|
if (/session|session_store|cookie/i.test(text)) {
|
|
538
|
-
categories.add("
|
|
518
|
+
categories.add("dpx:SessionToken");
|
|
539
519
|
}
|
|
540
520
|
if (/\bbelongs_to\s+:customer\b/i.test(text)) {
|
|
541
|
-
categories.add("
|
|
521
|
+
categories.add("pd:Username");
|
|
542
522
|
}
|
|
543
523
|
}
|
|
544
524
|
return [...categories].sort((left, right) => left.localeCompare(right));
|
|
@@ -1,11 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Detector rule id -> taxonomy concept, for evaluation (DATAP-947). A rule's id is the
|
|
3
|
+
* personal-data type it detects (`pd:EmailAddress`), so the concept leaf is the rule id and
|
|
4
|
+
* the ancestry is its chain in patterns/personal-data-taxonomy.yaml, top-level DPV category
|
|
5
|
+
* first. Lookups ignore case, because evaluation keys are compared lower-cased; results keep
|
|
6
|
+
* the taxonomy's spelling.
|
|
7
|
+
*/
|
|
8
|
+
export interface PersonalDataConceptMapEntry {
|
|
9
|
+
ruleId: string;
|
|
10
|
+
conceptLeaf: string;
|
|
11
|
+
conceptAncestry: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export interface PersonalDataConceptMap {
|
|
14
|
+
/** The taxonomy's version. */
|
|
15
|
+
version: string;
|
|
16
|
+
entries: readonly PersonalDataConceptMapEntry[];
|
|
17
|
+
}
|
|
2
18
|
export declare function clearPersonalDataConceptMapCacheForTest(): void;
|
|
19
|
+
/** Case-insensitive lookup key for a concept CURIE. */
|
|
20
|
+
export declare function normalizeConceptToken(token: string): string;
|
|
3
21
|
export declare function loadPersonalDataConceptMap(): PersonalDataConceptMap;
|
|
4
22
|
/** Lookup a concept-map entry without throwing when the rule id is unknown. */
|
|
5
23
|
export declare function tryRuleIdToConceptEntry(ruleId: string): PersonalDataConceptMapEntry | undefined;
|
|
6
|
-
/** Canonical concept leaf for a detector rule id
|
|
24
|
+
/** Canonical concept leaf for a detector rule id: the rule's taxonomy concept. */
|
|
7
25
|
export declare function ruleIdToConceptLeaf(ruleId: string): string;
|
|
8
|
-
/** Taxonomy ancestry for a detector rule id;
|
|
26
|
+
/** Taxonomy ancestry for a detector rule id; the last element is the concept leaf. */
|
|
9
27
|
export declare function ruleIdToAncestry(ruleId: string): readonly string[];
|
|
10
|
-
|
|
11
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Ancestry of any taxonomy concept, matched without case (`pd:emailaddress` works), or
|
|
30
|
+
* undefined when the token is not a concept. Gold labels name concepts at any depth.
|
|
31
|
+
*/
|
|
32
|
+
export declare function tryConceptAncestry(token: string): readonly string[] | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Taxonomy concepts no detector rule detects (`pd:Name`, `pd:OfficialID`, `pd:Street`). Gold
|
|
35
|
+
* may label an item with one; the scanner never reports one as a data item.
|
|
36
|
+
*/
|
|
37
|
+
export declare function categoryOnlyConcepts(): readonly string[];
|
|
38
|
+
/**
|
|
39
|
+
* The detector rule for a source field-name suffix (`email`, `phone_number`): a rule whose
|
|
40
|
+
* name words, joined by `_`, spell the suffix. Undefined when no rule's words do.
|
|
41
|
+
*/
|
|
42
|
+
export declare function ruleIdForFieldSuffix(suffix: string): string | undefined;
|
|
@@ -1,90 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validatePersonalDataConceptMapDocument = exports.normalizeConceptToken = exports.FORBIDDEN_CATEGORY_LEAVES = void 0;
|
|
7
3
|
exports.clearPersonalDataConceptMapCacheForTest = clearPersonalDataConceptMapCacheForTest;
|
|
4
|
+
exports.normalizeConceptToken = normalizeConceptToken;
|
|
8
5
|
exports.loadPersonalDataConceptMap = loadPersonalDataConceptMap;
|
|
9
6
|
exports.tryRuleIdToConceptEntry = tryRuleIdToConceptEntry;
|
|
10
7
|
exports.ruleIdToConceptLeaf = ruleIdToConceptLeaf;
|
|
11
8
|
exports.ruleIdToAncestry = ruleIdToAncestry;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
exports.tryConceptAncestry = tryConceptAncestry;
|
|
10
|
+
exports.categoryOnlyConcepts = categoryOnlyConcepts;
|
|
11
|
+
exports.ruleIdForFieldSuffix = ruleIdForFieldSuffix;
|
|
15
12
|
const pii_signal_rules_1 = require("../../pii-signals/pii-signal-rules");
|
|
16
|
-
const
|
|
13
|
+
const personal_data_taxonomy_1 = require("../../pii-signals/personal-data-taxonomy");
|
|
17
14
|
let cachedMap;
|
|
18
15
|
let cachedByRuleId;
|
|
19
16
|
function clearPersonalDataConceptMapCacheForTest() {
|
|
20
17
|
cachedMap = undefined;
|
|
21
18
|
cachedByRuleId = undefined;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const repoRoot = distIndex !== -1
|
|
27
|
-
? parts.slice(0, distIndex).join(path_1.default.sep)
|
|
28
|
-
: path_1.default.resolve(__dirname, "..", "..", "..");
|
|
29
|
-
return path_1.default.join(repoRoot, "patterns", "personal-data-concept-map.yaml");
|
|
30
|
-
}
|
|
31
|
-
function indexByRuleId(map) {
|
|
32
|
-
const index = new Map();
|
|
33
|
-
for (const entry of map.entries) {
|
|
34
|
-
index.set(entry.ruleId, entry);
|
|
35
|
-
}
|
|
36
|
-
return index;
|
|
20
|
+
/** Case-insensitive lookup key for a concept CURIE. */
|
|
21
|
+
function normalizeConceptToken(token) {
|
|
22
|
+
return token.trim().toLowerCase();
|
|
37
23
|
}
|
|
38
24
|
function loadPersonalDataConceptMap() {
|
|
39
|
-
if (cachedMap)
|
|
25
|
+
if (cachedMap)
|
|
40
26
|
return cachedMap;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
49
|
-
throw new Error(`Personal data concept map required but could not be read from '${configPath}': ${message}`);
|
|
50
|
-
}
|
|
51
|
-
let parsed;
|
|
52
|
-
try {
|
|
53
|
-
parsed = yaml_1.default.parse(rawText);
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
57
|
-
throw new Error(`Personal data concept map at '${configPath}' could not be parsed as YAML: ${message}`);
|
|
58
|
-
}
|
|
59
|
-
const expectedRuleIds = (0, pii_signal_rules_1.loadPiiSignalRules)().map((rule) => rule.id);
|
|
60
|
-
cachedMap = (0, concept_map_validate_1.validatePersonalDataConceptMapDocument)(parsed, expectedRuleIds);
|
|
61
|
-
cachedByRuleId = indexByRuleId(cachedMap);
|
|
27
|
+
const entries = (0, pii_signal_rules_1.loadPiiSignalRules)().map((rule) => ({
|
|
28
|
+
ruleId: rule.id,
|
|
29
|
+
conceptLeaf: rule.id,
|
|
30
|
+
conceptAncestry: (0, personal_data_taxonomy_1.personalDataAncestry)(rule.id),
|
|
31
|
+
}));
|
|
32
|
+
cachedMap = { version: (0, personal_data_taxonomy_1.loadPersonalDataTaxonomy)().version, entries };
|
|
33
|
+
cachedByRuleId = new Map(entries.map((entry) => [normalizeConceptToken(entry.ruleId), entry]));
|
|
62
34
|
return cachedMap;
|
|
63
35
|
}
|
|
36
|
+
/** Lookup a concept-map entry without throwing when the rule id is unknown. */
|
|
37
|
+
function tryRuleIdToConceptEntry(ruleId) {
|
|
38
|
+
loadPersonalDataConceptMap();
|
|
39
|
+
return cachedByRuleId?.get(normalizeConceptToken(ruleId));
|
|
40
|
+
}
|
|
64
41
|
function requireEntry(ruleId) {
|
|
65
|
-
const
|
|
66
|
-
const normalized = ruleId.trim().toLowerCase().replace(/-/g, "_");
|
|
67
|
-
const entry = cachedByRuleId?.get(normalized);
|
|
42
|
+
const entry = tryRuleIdToConceptEntry(ruleId);
|
|
68
43
|
if (!entry) {
|
|
69
|
-
throw new Error(`
|
|
44
|
+
throw new Error(`No detector rule detects '${ruleId}' (patterns/pii-signals.rules.yaml)`);
|
|
70
45
|
}
|
|
71
46
|
return entry;
|
|
72
47
|
}
|
|
73
|
-
/**
|
|
74
|
-
function tryRuleIdToConceptEntry(ruleId) {
|
|
75
|
-
loadPersonalDataConceptMap();
|
|
76
|
-
const normalized = ruleId.trim().toLowerCase().replace(/-/g, "_");
|
|
77
|
-
return cachedByRuleId?.get(normalized);
|
|
78
|
-
}
|
|
79
|
-
/** Canonical concept leaf for a detector rule id from patterns/pii-signals.rules.yaml. */
|
|
48
|
+
/** Canonical concept leaf for a detector rule id: the rule's taxonomy concept. */
|
|
80
49
|
function ruleIdToConceptLeaf(ruleId) {
|
|
81
50
|
return requireEntry(ruleId).conceptLeaf;
|
|
82
51
|
}
|
|
83
|
-
/** Taxonomy ancestry for a detector rule id;
|
|
52
|
+
/** Taxonomy ancestry for a detector rule id; the last element is the concept leaf. */
|
|
84
53
|
function ruleIdToAncestry(ruleId) {
|
|
85
54
|
return requireEntry(ruleId).conceptAncestry;
|
|
86
55
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Ancestry of any taxonomy concept, matched without case (`pd:emailaddress` works), or
|
|
58
|
+
* undefined when the token is not a concept. Gold labels name concepts at any depth.
|
|
59
|
+
*/
|
|
60
|
+
function tryConceptAncestry(token) {
|
|
61
|
+
const wanted = normalizeConceptToken(token);
|
|
62
|
+
for (const id of (0, personal_data_taxonomy_1.loadPersonalDataTaxonomy)().concepts.keys()) {
|
|
63
|
+
if (normalizeConceptToken(id) === wanted)
|
|
64
|
+
return (0, personal_data_taxonomy_1.personalDataAncestry)(id);
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Taxonomy concepts no detector rule detects (`pd:Name`, `pd:OfficialID`, `pd:Street`). Gold
|
|
70
|
+
* may label an item with one; the scanner never reports one as a data item.
|
|
71
|
+
*/
|
|
72
|
+
function categoryOnlyConcepts() {
|
|
73
|
+
const detected = new Set((0, pii_signal_rules_1.loadPiiSignalRules)().map((rule) => rule.id));
|
|
74
|
+
return [...(0, personal_data_taxonomy_1.loadPersonalDataTaxonomy)().concepts.keys()].filter((id) => !detected.has(id));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The detector rule for a source field-name suffix (`email`, `phone_number`): a rule whose
|
|
78
|
+
* name words, joined by `_`, spell the suffix. Undefined when no rule's words do.
|
|
79
|
+
*/
|
|
80
|
+
function ruleIdForFieldSuffix(suffix) {
|
|
81
|
+
const wanted = suffix.trim().toLowerCase();
|
|
82
|
+
return (0, pii_signal_rules_1.loadPiiSignalRules)().find((rule) => rule.nameWords.join("_") === wanted)?.id;
|
|
83
|
+
}
|
|
@@ -11,13 +11,6 @@ const FLOW_PREFIX = "flow:";
|
|
|
11
11
|
function normalizeToken(token) {
|
|
12
12
|
return token.trim().toLowerCase();
|
|
13
13
|
}
|
|
14
|
-
function normalizeFlowDataCategoryToken(token) {
|
|
15
|
-
const normalized = normalizeToken(token);
|
|
16
|
-
if (normalized === "email") {
|
|
17
|
-
return "email_address";
|
|
18
|
-
}
|
|
19
|
-
return normalized;
|
|
20
|
-
}
|
|
21
14
|
/**
|
|
22
15
|
* Parse a single component endpoint key `type:name` (e.g. `asset:api`).
|
|
23
16
|
* Returns null for prose keys without a type prefix (e.g. `password`).
|
|
@@ -105,8 +98,8 @@ function flowEndpointsMatch(expected, actual) {
|
|
|
105
98
|
typedComponentEndpointsMatch(expected.target, actual.target));
|
|
106
99
|
}
|
|
107
100
|
function flowDataCategoriesMatch(expected, actual) {
|
|
108
|
-
const normalizedExpected = expected.map(
|
|
109
|
-
const normalizedActual = actual.map(
|
|
101
|
+
const normalizedExpected = expected.map(normalizeToken).sort();
|
|
102
|
+
const normalizedActual = actual.map(normalizeToken).sort();
|
|
110
103
|
if (normalizedExpected.length !== normalizedActual.length) {
|
|
111
104
|
return false;
|
|
112
105
|
}
|
|
@@ -13,13 +13,15 @@ const LAYER_BY_EVAL = {
|
|
|
13
13
|
};
|
|
14
14
|
const RULE_ID_PREFIXES = ["raw_hit:", "occurrence:", "data_item:"];
|
|
15
15
|
function extractPersonalDataRuleId(subjectKey) {
|
|
16
|
-
const
|
|
16
|
+
const trimmed = subjectKey.trim();
|
|
17
17
|
for (const prefix of RULE_ID_PREFIXES) {
|
|
18
|
-
if (
|
|
19
|
-
const rest =
|
|
18
|
+
if (trimmed.toLowerCase().startsWith(prefix)) {
|
|
19
|
+
const rest = trimmed.slice(prefix.length);
|
|
20
20
|
if (prefix === "occurrence:") {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// `occurrence:<prefix>:<Name>:<file>:<line>`: the rule id is a CURIE, so it ends at
|
|
22
|
+
// the second colon.
|
|
23
|
+
const rule = /^[^:]+:[^:]+/.exec(rest);
|
|
24
|
+
return rule ? rule[0] : rest;
|
|
23
25
|
}
|
|
24
26
|
return rest;
|
|
25
27
|
}
|
|
@@ -51,8 +53,9 @@ function labelObservedTokens(labels) {
|
|
|
51
53
|
}));
|
|
52
54
|
}
|
|
53
55
|
function adaptPersonalDataFinding(finding, layer, adapterMapVersion = (0, manifest_1.resolveScannerAdapterMapVersion)()) {
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
+
// The taxonomy's spelling of the rule's concept (`pd:EmailAddress`), whatever the key's case.
|
|
57
|
+
const ruleId = (0, concept_map_1.ruleIdToConceptLeaf)(extractPersonalDataRuleId(finding.subjectKey));
|
|
58
|
+
const conceptLeaf = ruleId;
|
|
56
59
|
const conceptAncestry = (0, concept_map_1.ruleIdToAncestry)(ruleId);
|
|
57
60
|
const observedTokenCandidates = labelObservedTokens(finding.labels);
|
|
58
61
|
return (0, record_factory_1.buildScannerFinding)({
|
|
@@ -42,8 +42,10 @@ const GROUP_BASIS_CONFIDENCE = {
|
|
|
42
42
|
"file-vote": ["INFERRED", 0.65],
|
|
43
43
|
};
|
|
44
44
|
const at = (line) => (line === undefined ? null : `L${line}`);
|
|
45
|
+
/** The concept CURIE of `occurrence:<prefix>:<Name>:<file>:<line>` (`pd:EmailAddress`). */
|
|
45
46
|
function conceptOf(occurrenceId) {
|
|
46
|
-
|
|
47
|
+
const [, prefix, name] = occurrenceId.split(":");
|
|
48
|
+
return prefix && name ? `${prefix}:${name}` : "";
|
|
47
49
|
}
|
|
48
50
|
function firstColumn(content, line) {
|
|
49
51
|
const text = content.split(/\r?\n/)[line - 1] ?? "";
|
|
@@ -33,3 +33,9 @@ export type { ServiceSection } from "./core/sectioning/discover-service-sections
|
|
|
33
33
|
export { discoverServiceSections, tagFindingsWithServiceSections, } from "./core/sectioning/discover-service-sections";
|
|
34
34
|
export { DATA_ACTIONS, DATA_ACTION_ALIASES, DATA_ACTION_FRAMEWORK_ANCHORS, DATA_ACTION_SET, isDataAction, normalizeDataAction, normalizeDataActionToken, deriveFromTopology, STORAGE_SUBTYPES, deriveFromPatterns, pathsReferToSameFile, deriveFromSubtypes, SUBTYPE_STORE_SUBTYPES, TERRAFORM_GATEWAY_SUBTYPES, loadDataActionRuleCatalog, loadDataActionRules, clearDataActionRulesCacheForTest, ruleAppliesToLanguage, DATA_ACTION_RULE_LANGUAGES, mergeAssignmentsOntoComponents, mergeOneAssignment, readDataActions, hasVerb, runDataActionPhase, } from "./data-actions";
|
|
35
35
|
export type { DataAction, DataActionFrameworkAnchor, DataActionPatternRule, DataActionRuleCatalog, DataActionRuleLanguage, DeriveFromPatternsOptions, RunDataActionPhaseOptions, } from "./data-actions";
|
|
36
|
+
export { annotateFlowAuthentication, flowAuthentication, loadFlowAuthenticationRules, } from "./data-flow/flow-authentication";
|
|
37
|
+
export type { FlowAuthenticationRules } from "./data-flow/flow-authentication";
|
|
38
|
+
export { annotateFlowControls, flowControls, loadFlowControlRules } from "./data-flow/flow-controls";
|
|
39
|
+
export type { FlowControlRules } from "./data-flow/flow-controls";
|
|
40
|
+
export { loadStrideRules, isStructuralFlowForStride, strideComponentKind, strideThreatsForComponent, strideThreatsForFlow, strideThreatsForKind, } from "./threats/stride";
|
|
41
|
+
export type { ElementThreat, StrideElementKind, StrideRules, ThreatEvidence, ThreatFlowInput, ThreatStatus, } from "./threats/stride";
|
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.frameworkDisplayName = exports.canonicalFrameworkId = exports.DETECTABLE_PROPERTY_KEYS = exports.normalizeOrganizationDomains = exports.hostMatchesOrganizationDomains = exports.loadClassifierConfig = exports.dedupeDataFlows = exports.appendTerraformBareProviderAttachmentFlows = exports.shouldSkipDirectoryName = exports.DEFAULT_EXCLUDED_FILE_GLOBS = exports.toPosixPath = exports.isPathIgnored = exports.gitignoreRulesForDir = exports.gitignorePatternToRegex = exports.isSensitiveEnvPath = exports.resolveScanFilesystemEntry = exports.ingestFileSystem = exports.sortDataFlowsDeterministically = exports.STABLE_FLOW_ID_PREFIX = exports.STABLE_FLOW_ID_PATTERN = exports.STABLE_COMPONENT_ID_PREFIX = exports.STABLE_COMPONENT_ID_PATTERN = exports.stableFlowKey = exports.stableFlowId = exports.stableComponentId = exports.resolvedStableComponentKey = exports.normalizeFlowEndpoint = exports.buildComponentKeyById = exports.assignStableEntityIdsWithMaps = exports.assignStableEntityIds = exports.assignStableComponentIds = exports.stableComponentKey = exports.PROJECT_NAME_KEY_TOKEN = exports.NAME_FROM_PROJECT_PROPERTY = exports.collectEvalFindings = exports.DATAPARADE_GRAPH_SCHEMA = exports.DATAPARADE_GRAPH_FILE = exports.writeKnowledgeGraph = exports.buildDataParadeGraph = exports.loadGraphifyGraph = exports.runGraphify = exports.selectPrimaryDataAction = exports.buildDiagramGraphFromScanResult = exports.buildScanPersonalDataLayers = exports.enrichOrchestratorResultWithPersonalDataLayers = exports.runDeterministicScanPhases = exports.finalizeDeterministicScanResult = exports.emitScanProgress = exports.scan = exports.createDefaultScanConfiguration = void 0;
|
|
18
|
-
exports.runDataActionPhase = exports.hasVerb = exports.readDataActions = exports.mergeOneAssignment = exports.mergeAssignmentsOntoComponents = exports.DATA_ACTION_RULE_LANGUAGES = exports.ruleAppliesToLanguage = exports.clearDataActionRulesCacheForTest = exports.loadDataActionRules = exports.loadDataActionRuleCatalog = exports.TERRAFORM_GATEWAY_SUBTYPES = exports.SUBTYPE_STORE_SUBTYPES = exports.deriveFromSubtypes = exports.pathsReferToSameFile = exports.deriveFromPatterns = exports.STORAGE_SUBTYPES = exports.deriveFromTopology = exports.normalizeDataActionToken = exports.normalizeDataAction = exports.isDataAction = exports.DATA_ACTION_SET = exports.DATA_ACTION_FRAMEWORK_ANCHORS = exports.DATA_ACTION_ALIASES = exports.DATA_ACTIONS = exports.tagFindingsWithServiceSections = exports.discoverServiceSections = exports.runAnalyzers = exports.toDisplayName = void 0;
|
|
18
|
+
exports.strideThreatsForKind = exports.strideThreatsForFlow = exports.strideThreatsForComponent = exports.strideComponentKind = exports.isStructuralFlowForStride = exports.loadStrideRules = exports.loadFlowControlRules = exports.flowControls = exports.annotateFlowControls = exports.loadFlowAuthenticationRules = exports.flowAuthentication = exports.annotateFlowAuthentication = exports.runDataActionPhase = exports.hasVerb = exports.readDataActions = exports.mergeOneAssignment = exports.mergeAssignmentsOntoComponents = exports.DATA_ACTION_RULE_LANGUAGES = exports.ruleAppliesToLanguage = exports.clearDataActionRulesCacheForTest = exports.loadDataActionRules = exports.loadDataActionRuleCatalog = exports.TERRAFORM_GATEWAY_SUBTYPES = exports.SUBTYPE_STORE_SUBTYPES = exports.deriveFromSubtypes = exports.pathsReferToSameFile = exports.deriveFromPatterns = exports.STORAGE_SUBTYPES = exports.deriveFromTopology = exports.normalizeDataActionToken = exports.normalizeDataAction = exports.isDataAction = exports.DATA_ACTION_SET = exports.DATA_ACTION_FRAMEWORK_ANCHORS = exports.DATA_ACTION_ALIASES = exports.DATA_ACTIONS = exports.tagFindingsWithServiceSections = exports.discoverServiceSections = exports.runAnalyzers = exports.toDisplayName = void 0;
|
|
19
19
|
var orchestrator_1 = require("./core/pipeline/orchestrator");
|
|
20
20
|
Object.defineProperty(exports, "createDefaultScanConfiguration", { enumerable: true, get: function () { return orchestrator_1.createDefaultScanConfiguration; } });
|
|
21
21
|
Object.defineProperty(exports, "scan", { enumerable: true, get: function () { return orchestrator_1.scan; } });
|
|
@@ -121,3 +121,18 @@ Object.defineProperty(exports, "mergeOneAssignment", { enumerable: true, get: fu
|
|
|
121
121
|
Object.defineProperty(exports, "readDataActions", { enumerable: true, get: function () { return data_actions_1.readDataActions; } });
|
|
122
122
|
Object.defineProperty(exports, "hasVerb", { enumerable: true, get: function () { return data_actions_1.hasVerb; } });
|
|
123
123
|
Object.defineProperty(exports, "runDataActionPhase", { enumerable: true, get: function () { return data_actions_1.runDataActionPhase; } });
|
|
124
|
+
var flow_authentication_1 = require("./data-flow/flow-authentication");
|
|
125
|
+
Object.defineProperty(exports, "annotateFlowAuthentication", { enumerable: true, get: function () { return flow_authentication_1.annotateFlowAuthentication; } });
|
|
126
|
+
Object.defineProperty(exports, "flowAuthentication", { enumerable: true, get: function () { return flow_authentication_1.flowAuthentication; } });
|
|
127
|
+
Object.defineProperty(exports, "loadFlowAuthenticationRules", { enumerable: true, get: function () { return flow_authentication_1.loadFlowAuthenticationRules; } });
|
|
128
|
+
var flow_controls_1 = require("./data-flow/flow-controls");
|
|
129
|
+
Object.defineProperty(exports, "annotateFlowControls", { enumerable: true, get: function () { return flow_controls_1.annotateFlowControls; } });
|
|
130
|
+
Object.defineProperty(exports, "flowControls", { enumerable: true, get: function () { return flow_controls_1.flowControls; } });
|
|
131
|
+
Object.defineProperty(exports, "loadFlowControlRules", { enumerable: true, get: function () { return flow_controls_1.loadFlowControlRules; } });
|
|
132
|
+
var stride_1 = require("./threats/stride");
|
|
133
|
+
Object.defineProperty(exports, "loadStrideRules", { enumerable: true, get: function () { return stride_1.loadStrideRules; } });
|
|
134
|
+
Object.defineProperty(exports, "isStructuralFlowForStride", { enumerable: true, get: function () { return stride_1.isStructuralFlowForStride; } });
|
|
135
|
+
Object.defineProperty(exports, "strideComponentKind", { enumerable: true, get: function () { return stride_1.strideComponentKind; } });
|
|
136
|
+
Object.defineProperty(exports, "strideThreatsForComponent", { enumerable: true, get: function () { return stride_1.strideThreatsForComponent; } });
|
|
137
|
+
Object.defineProperty(exports, "strideThreatsForFlow", { enumerable: true, get: function () { return stride_1.strideThreatsForFlow; } });
|
|
138
|
+
Object.defineProperty(exports, "strideThreatsForKind", { enumerable: true, get: function () { return stride_1.strideThreatsForKind; } });
|
|
@@ -19,7 +19,7 @@ export interface PiiSignalHit {
|
|
|
19
19
|
location?: "code" | "comment";
|
|
20
20
|
/** Comments immediately around a code match (KDATAP-b512a8). */
|
|
21
21
|
commentContext?: CommentContext;
|
|
22
|
-
/** Data item group of a code match, e.g. `
|
|
22
|
+
/** Data item group of a code match, e.g. `pd:EmailAddress:customer` (KDATAP-c8a46a). */
|
|
23
23
|
group?: string;
|
|
24
24
|
/**
|
|
25
25
|
* The evidence that named the group: `declaration`, `name` (a qualifier or defined
|
|
@@ -77,7 +77,7 @@ function matchAliasHitsOnLine(line, lineIndex, filePath, rulesById, matchedRuleI
|
|
|
77
77
|
hits.push({
|
|
78
78
|
id: rule.id,
|
|
79
79
|
category: rule.category,
|
|
80
|
-
labels: [
|
|
80
|
+
labels: [rule.id],
|
|
81
81
|
evidence: {
|
|
82
82
|
filePath,
|
|
83
83
|
startLine: lineIndex + 1,
|
|
@@ -153,7 +153,7 @@ function matchPiiSignalsInFile(input, rules = (0, pii_signal_rules_1.loadPiiSign
|
|
|
153
153
|
hits.push({
|
|
154
154
|
id: rule.id,
|
|
155
155
|
category: rule.category,
|
|
156
|
-
labels: [
|
|
156
|
+
labels: [rule.id],
|
|
157
157
|
evidence: {
|
|
158
158
|
filePath: input.filePath,
|
|
159
159
|
startLine: lineIndex + 1,
|
|
@@ -18,7 +18,7 @@ export declare function qualify(line: string, signalId: string): {
|
|
|
18
18
|
fromReceiver: boolean;
|
|
19
19
|
weak?: boolean;
|
|
20
20
|
} | undefined;
|
|
21
|
-
/** Group id for a code occurrence of a signal, e.g. `
|
|
21
|
+
/** Group id for a code occurrence of a signal, e.g. `pd:EmailAddress:customer`, or undefined. */
|
|
22
22
|
export declare function occurrenceGroup(signalId: string, line: string): string | undefined;
|
|
23
23
|
export declare function modelFileEntity(filePath: string): string | undefined;
|
|
24
24
|
/**
|
|
@@ -70,13 +70,13 @@ export declare function declarationNodeId(signalId: string, filePath: string, li
|
|
|
70
70
|
* joined set (KDATAP-c8a46a). A declaration never spans two data items in the labeled
|
|
71
71
|
* corpus, so it is a safe join. Occurrences joined through a declaration take the set's
|
|
72
72
|
* qualifier group; a set with no qualifier is named after its declaration, e.g.
|
|
73
|
-
* `
|
|
73
|
+
* `pd:EmailAddress@src/a.js:12`. Sets that share a qualifier are joined too, so the qualifier
|
|
74
74
|
* links declarations across files.
|
|
75
75
|
*/
|
|
76
76
|
export declare function assignDeclarationGroups<T extends GroupableHit>(hits: T[]): T[];
|
|
77
77
|
/**
|
|
78
78
|
* Merge groups by external data-item labels (KDATAP-c8a46a, DPKB-196f76). The labels
|
|
79
|
-
* map a deterministic group name (`
|
|
79
|
+
* map a deterministic group name (`pd:EmailAddress:member`, `pd:EmailAddress@src/a.js:12#email`) to a data-item
|
|
80
80
|
* key chosen by a classifier outside the scanner (`ghost:members.email`). Groups that
|
|
81
81
|
* share a key become one group, named by the key; groups without a label are unchanged.
|
|
82
82
|
* The scanner stays deterministic: the mapping is an input, not a model call.
|
|
@@ -11,10 +11,11 @@ exports.declarationNodeId = declarationNodeId;
|
|
|
11
11
|
exports.assignDeclarationGroups = assignDeclarationGroups;
|
|
12
12
|
exports.applyGroupLabels = applyGroupLabels;
|
|
13
13
|
const fs_1 = require("fs");
|
|
14
|
+
const pii_signal_rules_1 = require("./pii-signal-rules");
|
|
14
15
|
/**
|
|
15
16
|
* First-pass grouping of code occurrences into data items (KDATAP-c8a46a).
|
|
16
17
|
*
|
|
17
|
-
* One signal concept such as `
|
|
18
|
+
* One signal concept such as `pd:EmailAddress` usually covers several real data items: a
|
|
18
19
|
* member's account email, a staff user's email, a newsletter sender address. This
|
|
19
20
|
* grouper reads the qualifier on the matched line:
|
|
20
21
|
*
|
|
@@ -65,7 +66,7 @@ function occurrenceQualifier(line, signalId) {
|
|
|
65
66
|
* a receiver variable's name (`profile.email`), applied after stronger evidence.
|
|
66
67
|
*/
|
|
67
68
|
function qualify(line, signalId) {
|
|
68
|
-
const conceptWords =
|
|
69
|
+
const conceptWords = (0, pii_signal_rules_1.ruleNameWords)(signalId);
|
|
69
70
|
// The first qualified identifier wins, unless a later one on the line is a more
|
|
70
71
|
// specific form of it: `customer_email = get_customer_email_for_voucher_usage(...)`
|
|
71
72
|
// -> `customer_for_voucher_usage`, since the value comes from that source.
|
|
@@ -160,7 +161,7 @@ function qualify(line, signalId) {
|
|
|
160
161
|
}
|
|
161
162
|
return undefined;
|
|
162
163
|
}
|
|
163
|
-
/** Group id for a code occurrence of a signal, e.g. `
|
|
164
|
+
/** Group id for a code occurrence of a signal, e.g. `pd:EmailAddress:customer`, or undefined. */
|
|
164
165
|
function occurrenceGroup(signalId, line) {
|
|
165
166
|
const qualifier = occurrenceQualifier(line, signalId);
|
|
166
167
|
return qualifier ? `${signalId}:${qualifier}` : undefined;
|
|
@@ -205,8 +206,8 @@ function modelFileEntity(filePath) {
|
|
|
205
206
|
}
|
|
206
207
|
/**
|
|
207
208
|
* Group name of an entity field: the entity plus the field's own qualifier.
|
|
208
|
-
* `member.email` -> `
|
|
209
|
-
* `order.user_email` -> `
|
|
209
|
+
* `member.email` -> `pd:EmailAddress:member`, `newsletter.sender_email` -> `pd:EmailAddress:newsletter_sender`,
|
|
210
|
+
* `order.user_email` -> `pd:EmailAddress:order` (`user` is generic).
|
|
210
211
|
*/
|
|
211
212
|
function entityFieldName(signalId, fieldKey) {
|
|
212
213
|
const [entity, field] = [fieldKey.slice(0, fieldKey.indexOf(".")), fieldKey.slice(fieldKey.indexOf(".") + 1)];
|
|
@@ -215,7 +216,7 @@ function entityFieldName(signalId, fieldKey) {
|
|
|
215
216
|
}
|
|
216
217
|
/**
|
|
217
218
|
* The name a occurrence brings to grouping: the entity field it defines
|
|
218
|
-
* (`sender_email` under `newsletters:` -> `
|
|
219
|
+
* (`sender_email` under `newsletters:` -> `pd:EmailAddress:newsletter_sender`), else the line's
|
|
219
220
|
* qualifier. Reads keep the line's qualifier and reach the definition through field
|
|
220
221
|
* links, so `gift_card.assigned_to_email` and `assigned_to_email=` stay compatible.
|
|
221
222
|
*/
|
|
@@ -277,7 +278,7 @@ function declarationNodeId(signalId, filePath, line, name) {
|
|
|
277
278
|
* joined set (KDATAP-c8a46a). A declaration never spans two data items in the labeled
|
|
278
279
|
* corpus, so it is a safe join. Occurrences joined through a declaration take the set's
|
|
279
280
|
* qualifier group; a set with no qualifier is named after its declaration, e.g.
|
|
280
|
-
* `
|
|
281
|
+
* `pd:EmailAddress@src/a.js:12`. Sets that share a qualifier are joined too, so the qualifier
|
|
281
282
|
* links declarations across files.
|
|
282
283
|
*/
|
|
283
284
|
function assignDeclarationGroups(hits) {
|
|
@@ -308,7 +309,7 @@ function assignOnce(hits, contestedNames, newlyContested, log) {
|
|
|
308
309
|
};
|
|
309
310
|
// Each set carries at most one qualifier name. A join that would put two differently
|
|
310
311
|
// named sets together is refused (cannot-link), so one bridging line never merges
|
|
311
|
-
// `
|
|
312
|
+
// `pd:EmailAddress:member` with `pd:EmailAddress:customer`.
|
|
312
313
|
const nameOf = new Map();
|
|
313
314
|
// A set also carries the stored column its occurrences name; two different columns are
|
|
314
315
|
// never one data item (KDATAP-7a094c), so a join that would put them together is refused.
|
|
@@ -372,7 +373,7 @@ function assignOnce(hits, contestedNames, newlyContested, log) {
|
|
|
372
373
|
}
|
|
373
374
|
return node;
|
|
374
375
|
};
|
|
375
|
-
// A name carried by the declarations of two or more columns (`
|
|
376
|
+
// A name carried by the declarations of two or more columns (`pd:TelephoneNumber:address` over
|
|
376
377
|
// five tables' phone fields) names no one of them. Order must not decide who claims it:
|
|
377
378
|
// such a name is claimed by none, columned sets keep their own identity, and the
|
|
378
379
|
// occurrences with no column join each other under it (KDATAP-fb8019).
|
|
@@ -546,7 +547,7 @@ function assignOnce(hits, contestedNames, newlyContested, log) {
|
|
|
546
547
|
}
|
|
547
548
|
});
|
|
548
549
|
// A set with neither a name nor a declaration is named after its first member's
|
|
549
|
-
// location (`
|
|
550
|
+
// location (`pd:EmailAddress~src/a.js:12`). It creates no pairs by itself, but gives an external
|
|
550
551
|
// data-item label (applyGroupLabels) a name to attach to.
|
|
551
552
|
const locationNameByRoot = new Map();
|
|
552
553
|
hits.forEach((hit, index) => {
|
|
@@ -585,7 +586,7 @@ function assignOnce(hits, contestedNames, newlyContested, log) {
|
|
|
585
586
|
}
|
|
586
587
|
/**
|
|
587
588
|
* Merge groups by external data-item labels (KDATAP-c8a46a, DPKB-196f76). The labels
|
|
588
|
-
* map a deterministic group name (`
|
|
589
|
+
* map a deterministic group name (`pd:EmailAddress:member`, `pd:EmailAddress@src/a.js:12#email`) to a data-item
|
|
589
590
|
* key chosen by a classifier outside the scanner (`ghost:members.email`). Groups that
|
|
590
591
|
* share a key become one group, named by the key; groups without a label are unchanged.
|
|
591
592
|
* The scanner stays deterministic: the mapping is an input, not a model call.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scanner's personal-data taxonomy (DATAP-947): W3C DPV personal-data concepts at the
|
|
3
|
+
* top, our more specific types beneath them. Every personal-data type the scanner emits is a
|
|
4
|
+
* concept id here, written as a CURIE (`pd:EmailAddress`, `dpx:FirstName`). See
|
|
5
|
+
* patterns/personal-data-taxonomy.yaml and docs/dpv-taxonomy.md.
|
|
6
|
+
*/
|
|
7
|
+
/** The DPV root every top-level concept hangs from; not itself a concept in the file. */
|
|
8
|
+
export declare const PERSONAL_DATA_ROOT = "dpv:PersonalData";
|
|
9
|
+
export interface PersonalDataConcept {
|
|
10
|
+
/** CURIE, e.g. `pd:EmailAddress`. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Full IRI, e.g. `https://w3id.org/dpv/pd#EmailAddress`. */
|
|
13
|
+
iri: string;
|
|
14
|
+
/** Direct parent CURIE; `dpv:PersonalData` for a top-level DPV category. */
|
|
15
|
+
broader: string;
|
|
16
|
+
/** Present on our extension concepts, which DPV does not define. */
|
|
17
|
+
definition?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface PersonalDataTaxonomy {
|
|
20
|
+
version: string;
|
|
21
|
+
dpvVersion: string;
|
|
22
|
+
namespaces: Readonly<Record<string, string>>;
|
|
23
|
+
concepts: ReadonlyMap<string, PersonalDataConcept>;
|
|
24
|
+
}
|
|
25
|
+
/** Prefix of DPV's personal-data extension; its concepts are DPV's own terms. */
|
|
26
|
+
export declare const DPV_PD_PREFIX = "pd";
|
|
27
|
+
/** Prefix of our extension namespace; its concepts sit beneath a DPV concept. */
|
|
28
|
+
export declare const EXTENSION_PREFIX = "dpx";
|
|
29
|
+
/**
|
|
30
|
+
* Validate a parsed taxonomy document: known prefixes, unique ids, every `broader` a
|
|
31
|
+
* concept or the DPV root, no cycles, extension concepts defined and beneath DPV, and no
|
|
32
|
+
* extension local name that repeats a DPV term in the file.
|
|
33
|
+
*/
|
|
34
|
+
export declare function validatePersonalDataTaxonomyDocument(parsed: unknown): PersonalDataTaxonomy;
|
|
35
|
+
export declare function clearPersonalDataTaxonomyCacheForTest(): void;
|
|
36
|
+
export declare function loadPersonalDataTaxonomy(): PersonalDataTaxonomy;
|
|
37
|
+
export declare function isPersonalDataConcept(id: string): boolean;
|
|
38
|
+
/** The concept, or a thrown error naming the unknown id. */
|
|
39
|
+
export declare function requirePersonalDataConcept(id: string): PersonalDataConcept;
|
|
40
|
+
/**
|
|
41
|
+
* Ancestry of a concept from its top-level DPV category down to the concept itself, e.g.
|
|
42
|
+
* `["pd:External", "pd:Identifying", "pd:Name", "dpx:FirstName"]`. The DPV root is left out.
|
|
43
|
+
*/
|
|
44
|
+
export declare function personalDataAncestry(id: string): string[];
|