flare-redact 1.4.1 → 1.5.0
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/CHANGELOG.md +91 -0
- package/README.md +107 -0
- package/SECURITY.md +36 -0
- package/bin/flare-gateway.mjs +6 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -0
- package/dist/cli.js.map +1 -1
- package/dist/detectors.d.ts +17 -0
- package/dist/detectors.d.ts.map +1 -1
- package/dist/detectors.js.map +1 -1
- package/dist/engine.d.ts +5 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +50 -7
- package/dist/engine.js.map +1 -1
- package/dist/gateway/body.d.ts +90 -0
- package/dist/gateway/body.d.ts.map +1 -0
- package/dist/gateway/body.js +185 -0
- package/dist/gateway/body.js.map +1 -0
- package/dist/gateway/cli.d.ts +26 -0
- package/dist/gateway/cli.d.ts.map +1 -0
- package/dist/gateway/cli.js +230 -0
- package/dist/gateway/cli.js.map +1 -0
- package/dist/gateway/config.d.ts +110 -0
- package/dist/gateway/config.d.ts.map +1 -0
- package/dist/gateway/config.js +212 -0
- package/dist/gateway/config.js.map +1 -0
- package/dist/gateway/index.d.ts +21 -0
- package/dist/gateway/index.d.ts.map +1 -0
- package/dist/gateway/index.js +21 -0
- package/dist/gateway/index.js.map +1 -0
- package/dist/gateway/runtime.d.ts +80 -0
- package/dist/gateway/runtime.d.ts.map +1 -0
- package/dist/gateway/runtime.js +0 -0
- package/dist/gateway/runtime.js.map +1 -0
- package/dist/gateway/server.d.ts +37 -0
- package/dist/gateway/server.d.ts.map +1 -0
- package/dist/gateway/server.js +560 -0
- package/dist/gateway/server.js.map +1 -0
- package/dist/pack.d.ts +88 -0
- package/dist/pack.d.ts.map +1 -0
- package/dist/pack.js +350 -0
- package/dist/pack.js.map +1 -0
- package/docker/Dockerfile +47 -0
- package/docker/README.md +219 -0
- package/docker/docker-compose.yml +55 -0
- package/docker/flare-gateway.example.json +48 -0
- package/package.json +27 -4
- package/spec/SPEC.md +469 -0
- package/spec/conformance/README.md +60 -0
- package/spec/conformance/cases.json +149 -0
- package/spec/conformance/expected.json +1683 -0
- package/spec/detectors.json +1812 -0
- package/spec/detectors.schema.json +196 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://flare-collection.github.io/flare-redact/spec/detectors.schema.json",
|
|
4
|
+
"title": "FRS-1 detector pack",
|
|
5
|
+
"description": "A portable, language-neutral description of a set of secret and PII detectors. Any FRS-1 engine (JavaScript, Python, Go, Rust) loading the same pack must produce identical findings. The normative prose lives in spec/SPEC.md.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["spec", "id", "version", "detectors"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"$schema": { "type": "string" },
|
|
11
|
+
"spec": { "const": "FRS-1", "description": "Spec revision this pack conforms to." },
|
|
12
|
+
"id": { "type": "string", "minLength": 1, "description": "Stable identifier for the pack, e.g. \"acme/internal\"." },
|
|
13
|
+
"version": { "type": "string", "minLength": 1 },
|
|
14
|
+
"title": { "type": "string" },
|
|
15
|
+
"description": { "type": "string" },
|
|
16
|
+
"license": { "type": "string" },
|
|
17
|
+
"confidenceModel": { "$ref": "#/$defs/confidenceModel" },
|
|
18
|
+
"detectors": {
|
|
19
|
+
"type": "array",
|
|
20
|
+
"minItems": 1,
|
|
21
|
+
"items": { "$ref": "#/$defs/detector" }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"$defs": {
|
|
25
|
+
"confidenceModel": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"description": "Logistic-regression weights used when refineConfidence is enabled.",
|
|
28
|
+
"required": ["version", "features", "weights", "bias"],
|
|
29
|
+
"additionalProperties": false,
|
|
30
|
+
"properties": {
|
|
31
|
+
"version": { "type": "integer" },
|
|
32
|
+
"features": { "type": "array", "items": { "type": "string" } },
|
|
33
|
+
"weights": { "type": "array", "items": { "type": "number" } },
|
|
34
|
+
"bias": { "type": "number" }
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"detector": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"required": ["id", "label", "why", "pattern", "mask", "default", "risk", "confidence"],
|
|
40
|
+
"additionalProperties": false,
|
|
41
|
+
"properties": {
|
|
42
|
+
"id": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"pattern": "^[a-z][a-z0-9_]*$",
|
|
45
|
+
"description": "Unique within the pack. Appears in findings and in label mode."
|
|
46
|
+
},
|
|
47
|
+
"label": { "type": "string", "minLength": 1 },
|
|
48
|
+
"why": { "type": "string", "minLength": 1, "description": "One sentence a reader can act on: what an attacker gains." },
|
|
49
|
+
"pattern": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"minLength": 1,
|
|
52
|
+
"description": "A pattern in the FRS-1 regular-expression subset. No lookaround, no backreferences, no \\\\b \\\\d \\\\w \\\\s shorthands. Use {{ANY}} for any character and {{L}} for any Unicode letter."
|
|
53
|
+
},
|
|
54
|
+
"flags": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"enum": ["", "i"],
|
|
57
|
+
"default": "",
|
|
58
|
+
"description": "Only case-insensitive matching may be requested."
|
|
59
|
+
},
|
|
60
|
+
"capture": {
|
|
61
|
+
"type": "integer",
|
|
62
|
+
"minimum": 0,
|
|
63
|
+
"default": 0,
|
|
64
|
+
"description": "Capture group holding the sensitive value. 0 means the whole match."
|
|
65
|
+
},
|
|
66
|
+
"boundary": { "$ref": "#/$defs/boundary" },
|
|
67
|
+
"reject": {
|
|
68
|
+
"type": "array",
|
|
69
|
+
"items": { "type": "string" },
|
|
70
|
+
"description": "Drop the candidate when one of these patterns matches at the start of the captured value."
|
|
71
|
+
},
|
|
72
|
+
"validators": { "type": "array", "items": { "$ref": "#/$defs/validator" } },
|
|
73
|
+
"mask": { "$ref": "#/$defs/mask" },
|
|
74
|
+
"default": { "type": "boolean", "description": "Whether the detector runs unless disabled." },
|
|
75
|
+
"tags": { "type": "array", "items": { "type": "string" }, "description": "Selectable groups for enable/disable/only." },
|
|
76
|
+
"risk": { "enum": ["low", "medium", "high", "critical"] },
|
|
77
|
+
"priority": { "type": "integer", "default": 0, "description": "Tie-break weight when candidates overlap. Higher wins." },
|
|
78
|
+
"confidence": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
79
|
+
"refine": { "type": "boolean", "default": false, "description": "Allow the learned classifier to adjust this detector's confidence." },
|
|
80
|
+
"prefilter": {
|
|
81
|
+
"type": "array",
|
|
82
|
+
"items": { "type": "string", "minLength": 1 },
|
|
83
|
+
"description": "Case-insensitive literals; the pattern is skipped unless one occurs in the subject. Must be implied by every possible match."
|
|
84
|
+
},
|
|
85
|
+
"context": { "$ref": "#/$defs/context" }
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"boundary": {
|
|
89
|
+
"type": "object",
|
|
90
|
+
"description": "Character classes the neighbours of the captured span must NOT belong to. Start and end of input always satisfy a boundary.",
|
|
91
|
+
"additionalProperties": false,
|
|
92
|
+
"properties": {
|
|
93
|
+
"before": { "$ref": "#/$defs/boundaryClass" },
|
|
94
|
+
"after": { "$ref": "#/$defs/boundaryClass" }
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"boundaryClass": {
|
|
98
|
+
"enum": ["word", "alnum", "digit", "hex", "base64", "base64url", "word_dash"]
|
|
99
|
+
},
|
|
100
|
+
"validator": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"required": ["name"],
|
|
103
|
+
"oneOf": [
|
|
104
|
+
{
|
|
105
|
+
"properties": {
|
|
106
|
+
"name": { "const": "normalized_match" },
|
|
107
|
+
"strip": { "type": "string", "description": "Character class removed before matching." },
|
|
108
|
+
"pattern": { "type": "string" }
|
|
109
|
+
},
|
|
110
|
+
"required": ["name", "pattern"],
|
|
111
|
+
"additionalProperties": false
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"properties": {
|
|
115
|
+
"name": { "const": "luhn" },
|
|
116
|
+
"minDigits": { "type": "integer", "minimum": 2, "default": 2 },
|
|
117
|
+
"maxDigits": { "type": "integer", "minimum": 2 }
|
|
118
|
+
},
|
|
119
|
+
"required": ["name"],
|
|
120
|
+
"additionalProperties": false
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"properties": {
|
|
124
|
+
"name": { "const": "entropy" },
|
|
125
|
+
"min": { "type": "number" }
|
|
126
|
+
},
|
|
127
|
+
"required": ["name", "min"],
|
|
128
|
+
"additionalProperties": false
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"properties": {
|
|
132
|
+
"name": {
|
|
133
|
+
"enum": [
|
|
134
|
+
"phone", "iban", "tckn", "cpf", "dni", "bsn", "pesel", "de_tax_id",
|
|
135
|
+
"codice_fiscale", "fr_nir", "aadhaar", "tfn", "cn_resident_id",
|
|
136
|
+
"jp_my_number", "us_ssn", "aba", "nhs", "vin"
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"required": ["name"],
|
|
141
|
+
"additionalProperties": false
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"mask": {
|
|
146
|
+
"type": "object",
|
|
147
|
+
"required": ["type"],
|
|
148
|
+
"oneOf": [
|
|
149
|
+
{
|
|
150
|
+
"properties": { "type": { "const": "fixed" }, "text": { "type": "string" } },
|
|
151
|
+
"required": ["type", "text"],
|
|
152
|
+
"additionalProperties": false
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"properties": { "type": { "const": "keepPrefix" }, "n": { "type": "integer", "minimum": 1 } },
|
|
156
|
+
"required": ["type", "n"],
|
|
157
|
+
"additionalProperties": false
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"properties": { "type": { "const": "keepLast" }, "n": { "type": "integer", "minimum": 1 } },
|
|
161
|
+
"required": ["type", "n"],
|
|
162
|
+
"additionalProperties": false
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"properties": {
|
|
166
|
+
"type": { "const": "keepThroughSeparator" },
|
|
167
|
+
"separator": { "type": "string", "minLength": 1 },
|
|
168
|
+
"count": { "type": "integer", "minimum": 1 }
|
|
169
|
+
},
|
|
170
|
+
"required": ["type", "separator", "count"],
|
|
171
|
+
"additionalProperties": false
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"properties": {
|
|
175
|
+
"type": { "const": "replace" },
|
|
176
|
+
"pattern": { "type": "string", "description": "Full-match pattern; groups are referenced as $1..$9 in replacement." },
|
|
177
|
+
"replacement": { "type": "string" },
|
|
178
|
+
"flags": { "type": "string", "enum": ["", "i"] }
|
|
179
|
+
},
|
|
180
|
+
"required": ["type", "pattern", "replacement"],
|
|
181
|
+
"additionalProperties": false
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
"context": {
|
|
186
|
+
"type": "object",
|
|
187
|
+
"description": "Evidence near the match that nudges confidence. Matched case-insensitively with substring (search) semantics.",
|
|
188
|
+
"additionalProperties": false,
|
|
189
|
+
"properties": {
|
|
190
|
+
"positive": { "type": "string" },
|
|
191
|
+
"negative": { "type": "string" },
|
|
192
|
+
"window": { "type": "integer", "minimum": 1, "default": 80 }
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|