playwright-security-scan 0.0.0 → 0.1.0-beta.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/dist/rules.cjs ADDED
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var chunkBBF7BGCZ_cjs = require('./chunk-BBF7BGCZ.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "VERSION", {
8
+ enumerable: true,
9
+ get: function () { return chunkBBF7BGCZ_cjs.VERSION; }
10
+ });
@@ -0,0 +1,4 @@
1
+ /** The package version, read from package.json at build time. */
2
+ declare const VERSION: string;
3
+
4
+ export { VERSION };
@@ -0,0 +1,4 @@
1
+ /** The package version, read from package.json at build time. */
2
+ declare const VERSION: string;
3
+
4
+ export { VERSION };
package/dist/rules.js ADDED
@@ -0,0 +1 @@
1
+ export { VERSION } from './chunk-SFWIEETP.js';
package/package.json CHANGED
@@ -1,9 +1,92 @@
1
1
  {
2
2
  "name": "playwright-security-scan",
3
- "version": "0.0.0",
4
- "description": "Reserved name. Passive security scan (DAST) for Playwright tests, under development.",
3
+ "version": "0.1.0-beta.0",
4
+ "description": "Passive security scan (DAST) of the HTTP traffic of your existing Playwright e2e and API tests, with a committed baseline that fails the run only on new findings.",
5
+ "keywords": [
6
+ "playwright",
7
+ "security",
8
+ "dast",
9
+ "passive-scan",
10
+ "e2e",
11
+ "api-testing",
12
+ "sarif",
13
+ "owasp"
14
+ ],
5
15
  "license": "MIT",
6
16
  "author": "Jakub Kaczmarczyk",
7
- "repository": { "type": "git", "url": "git+https://github.com/Meser6/playwright-security-scan.git" },
8
- "files": ["README.md"]
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/Meser6/playwright-security-scan.git"
20
+ },
21
+ "homepage": "https://github.com/Meser6/playwright-security-scan#readme",
22
+ "bugs": "https://github.com/Meser6/playwright-security-scan/issues",
23
+ "type": "module",
24
+ "sideEffects": false,
25
+ "exports": {
26
+ "./config": {
27
+ "import": "./dist/config.js",
28
+ "require": "./dist/config.cjs"
29
+ },
30
+ "./fixture": {
31
+ "import": "./dist/fixture.js",
32
+ "require": "./dist/fixture.cjs"
33
+ },
34
+ "./reporter": {
35
+ "import": "./dist/reporter.js",
36
+ "require": "./dist/reporter.cjs"
37
+ },
38
+ "./rules": {
39
+ "import": "./dist/rules.js",
40
+ "require": "./dist/rules.cjs"
41
+ },
42
+ "./schemas/*": "./schemas/*",
43
+ "./package.json": "./package.json"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "schemas",
48
+ "CHANGELOG.md"
49
+ ],
50
+ "engines": {
51
+ "node": ">=22.18.0"
52
+ },
53
+ "peerDependencies": {
54
+ "@playwright/test": ">=1.57.0"
55
+ },
56
+ "packageManager": "pnpm@10.16.1",
57
+ "scripts": {
58
+ "build": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\" && tsup",
59
+ "typecheck": "tsc --noEmit",
60
+ "lint": "eslint .",
61
+ "format": "prettier --write .",
62
+ "format:check": "prettier --check .",
63
+ "test": "vitest run",
64
+ "test:watch": "vitest",
65
+ "check:ac": "node scripts/check-ac-coverage.mjs",
66
+ "check:pr-title": "node scripts/check-pr-title.mjs",
67
+ "publint": "publint --strict",
68
+ "attw": "attw --pack . --profile node16",
69
+ "gen:types": "node scripts/generate-types.mjs",
70
+ "check:types-generated": "node scripts/generate-types.mjs --check",
71
+ "check:rule-fixtures": "node scripts/check-rule-fixtures.mjs",
72
+ "gen:docs": "node scripts/generate-docs.mjs",
73
+ "check:docs-generated": "node scripts/generate-docs.mjs --check"
74
+ },
75
+ "devDependencies": {
76
+ "@arethetypeswrong/cli": "0.18.5",
77
+ "@eslint/js": "^10.0.1",
78
+ "@playwright/test": "1.57.0",
79
+ "@types/node": "^22.20.5",
80
+ "ajv": "8.20.0",
81
+ "eslint": "10.15.0",
82
+ "globals": "^17.14.0",
83
+ "json-schema-to-typescript": "16.0.0",
84
+ "playwright-performance-regression": "1.0.0",
85
+ "prettier": "3.10.1",
86
+ "publint": "0.3.25",
87
+ "tsup": "9.0.0",
88
+ "typescript": "6.0.3",
89
+ "typescript-eslint": "8.73.0",
90
+ "vitest": "5.1.1"
91
+ }
9
92
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://pkg.invalid/schemas/attachment.schema.json",
4
+ "title": "Test attachment",
5
+ "description": "Attachment 'pw-sec-findings' of one test (02-REQ-05): findings deduplicated within the test, its coverage and diagnostics. At most 256 KB.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["schemaVersion", "findings", "coverage", "diagnostics"],
9
+ "properties": {
10
+ "schemaVersion": { "const": 1 },
11
+ "findings": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/finding" } },
12
+ "coverage": { "$ref": "common.schema.json#/$defs/coverage" },
13
+ "diagnostics": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/diagnostic" } }
14
+ }
15
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://pkg.invalid/schemas/baseline.schema.json",
4
+ "title": "Baseline file",
5
+ "description": "security-baseline.json, committed (02, chapter 5; 08). Only fingerprints, rule ids, subjects, names and notes; never evidence, URLs with values, tests or counters (02-REQ-04).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["schemaVersion", "findings"],
9
+ "properties": {
10
+ "$schema": { "type": "string" },
11
+ "schemaVersion": { "const": 1 },
12
+ "generatedBy": {
13
+ "description": "Package and version that last wrote the file.",
14
+ "type": "string"
15
+ },
16
+ "findings": {
17
+ "description": "Fingerprint to baseline entry, sorted by fingerprint (02-REQ-01).",
18
+ "type": "object",
19
+ "propertyNames": { "maxLength": 512 },
20
+ "additionalProperties": { "$ref": "#/$defs/entry" }
21
+ }
22
+ },
23
+ "$defs": {
24
+ "entry": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "required": ["ruleId", "subject", "severity", "status", "addedAt"],
28
+ "properties": {
29
+ "ruleId": { "$ref": "common.schema.json#/$defs/ruleId" },
30
+ "subject": { "type": "string" },
31
+ "severity": { "$ref": "common.schema.json#/$defs/severity" },
32
+ "status": {
33
+ "description": "accepted: risk accepted; false-positive: not a problem, never expires; wontfix: knowingly not fixed, needs a note (02-REQ-02).",
34
+ "enum": ["accepted", "false-positive", "wontfix"]
35
+ },
36
+ "note": { "type": "string" },
37
+ "until": {
38
+ "description": "After this date the entry no longer protects the finding (02-REQ-03).",
39
+ "$ref": "common.schema.json#/$defs/isoDate"
40
+ },
41
+ "addedAt": { "$ref": "common.schema.json#/$defs/isoDate" }
42
+ },
43
+ "if": { "properties": { "status": { "const": "wontfix" } } },
44
+ "then": { "required": ["note"] }
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,307 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://pkg.invalid/schemas/common.schema.json",
4
+ "title": "Common definitions",
5
+ "description": "Definitions shared by the file formats of playwright-security-scan (02).",
6
+ "$defs": {
7
+ "severity": {
8
+ "description": "Severity of a finding.",
9
+ "enum": ["info", "low", "medium", "high", "critical"]
10
+ },
11
+ "confidence": {
12
+ "description": "How sure a rule is that the finding is a real problem.",
13
+ "enum": ["low", "medium", "high"]
14
+ },
15
+ "findingScope": {
16
+ "description": "What the subject of a finding is (07, chapter 3).",
17
+ "enum": ["origin", "endpoint", "cookie", "storage-key", "asset"]
18
+ },
19
+ "source": {
20
+ "description": "Where the traffic came from: a browser context or an APIRequestContext (15).",
21
+ "enum": ["browser", "api"]
22
+ },
23
+ "ruleId": {
24
+ "description": "Stable rule id, '<group>.<name>'.",
25
+ "type": "string",
26
+ "pattern": "^[a-z]+\\.[a-z0-9-]+$"
27
+ },
28
+ "isoDate": {
29
+ "description": "Calendar date, YYYY-MM-DD.",
30
+ "type": "string",
31
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
32
+ },
33
+ "count": {
34
+ "type": "integer",
35
+ "minimum": 0
36
+ },
37
+ "testContextRef": {
38
+ "description": "The test (and step) a record or finding comes from.",
39
+ "type": "object",
40
+ "additionalProperties": false,
41
+ "required": ["testId", "titlePath", "file", "line", "project"],
42
+ "properties": {
43
+ "testId": {
44
+ "type": "string"
45
+ },
46
+ "titlePath": {
47
+ "description": "Titles from the outermost describe to the test.",
48
+ "type": "array",
49
+ "items": {
50
+ "type": "string"
51
+ }
52
+ },
53
+ "file": {
54
+ "description": "Test file path relative to the Playwright config directory, with forward slashes.",
55
+ "type": "string"
56
+ },
57
+ "line": {
58
+ "type": "integer",
59
+ "minimum": 0
60
+ },
61
+ "project": {
62
+ "type": "string"
63
+ },
64
+ "step": {
65
+ "description": "Title of the innermost running test.step, best effort.",
66
+ "type": "string"
67
+ }
68
+ }
69
+ },
70
+ "evidence": {
71
+ "description": "One piece of evidence, already redacted (07, chapter 5).",
72
+ "type": "object",
73
+ "additionalProperties": false,
74
+ "required": ["kind", "snippet"],
75
+ "properties": {
76
+ "kind": {
77
+ "enum": ["header", "cookie", "body", "url", "storage", "event"]
78
+ },
79
+ "name": {
80
+ "description": "Header, cookie, parameter or storage key name.",
81
+ "type": "string"
82
+ },
83
+ "snippet": {
84
+ "type": "string",
85
+ "maxLength": 200
86
+ }
87
+ }
88
+ },
89
+ "location": {
90
+ "type": "object",
91
+ "additionalProperties": false,
92
+ "required": ["origin"],
93
+ "properties": {
94
+ "origin": {
95
+ "type": "string"
96
+ },
97
+ "endpointKey": {
98
+ "type": "string"
99
+ },
100
+ "param": {
101
+ "type": "string"
102
+ },
103
+ "header": {
104
+ "type": "string"
105
+ }
106
+ }
107
+ },
108
+ "finding": {
109
+ "description": "A deduplicated finding (02, chapter 4).",
110
+ "$ref": "#/$defs/findingFields",
111
+ "unevaluatedProperties": false,
112
+ "title": "Finding",
113
+ "type": "object"
114
+ },
115
+ "diagnostic": {
116
+ "type": "object",
117
+ "additionalProperties": false,
118
+ "required": ["code", "level", "message"],
119
+ "properties": {
120
+ "code": {
121
+ "type": "string",
122
+ "pattern": "^[A-Z][A-Z0-9_]*$"
123
+ },
124
+ "level": {
125
+ "enum": ["info", "warn", "error"]
126
+ },
127
+ "message": {
128
+ "type": "string"
129
+ },
130
+ "testId": {
131
+ "type": "string"
132
+ }
133
+ }
134
+ },
135
+ "counts": {
136
+ "type": "object",
137
+ "additionalProperties": {
138
+ "$ref": "#/$defs/count"
139
+ }
140
+ },
141
+ "coverage": {
142
+ "description": "What the scan saw (02, chapter 6; 09-REQ-04).",
143
+ "type": "object",
144
+ "additionalProperties": false,
145
+ "required": [
146
+ "responses",
147
+ "apiResponses",
148
+ "outOfScope",
149
+ "documents",
150
+ "bodiesAnalyzed",
151
+ "bodiesSkipped",
152
+ "endpoints",
153
+ "origins",
154
+ "assets",
155
+ "storageOrigins",
156
+ "rulesRun"
157
+ ],
158
+ "properties": {
159
+ "responses": {
160
+ "description": "Records in scope, both sources.",
161
+ "$ref": "#/$defs/count"
162
+ },
163
+ "apiResponses": {
164
+ "description": "Of these, records of the api source.",
165
+ "$ref": "#/$defs/count"
166
+ },
167
+ "outOfScope": {
168
+ "description": "Responses of origins outside the scope.",
169
+ "$ref": "#/$defs/count"
170
+ },
171
+ "documents": {
172
+ "description": "In-scope responses of resource type document.",
173
+ "$ref": "#/$defs/count"
174
+ },
175
+ "bodiesAnalyzed": {
176
+ "$ref": "#/$defs/count"
177
+ },
178
+ "bodiesSkipped": {
179
+ "description": "Bodies not read, by reason.",
180
+ "$ref": "#/$defs/counts"
181
+ },
182
+ "endpoints": {
183
+ "description": "Endpoint key to number of responses.",
184
+ "$ref": "#/$defs/counts"
185
+ },
186
+ "origins": {
187
+ "description": "Origin in scope to its numbers of responses and documents.",
188
+ "type": "object",
189
+ "additionalProperties": {
190
+ "type": "object",
191
+ "additionalProperties": false,
192
+ "required": ["responses", "documents"],
193
+ "properties": {
194
+ "responses": {
195
+ "$ref": "#/$defs/count"
196
+ },
197
+ "documents": {
198
+ "$ref": "#/$defs/count"
199
+ }
200
+ }
201
+ }
202
+ },
203
+ "assets": {
204
+ "description": "Normalized URLs of in-scope scripts and stylesheets, sorted.",
205
+ "type": "array",
206
+ "items": {
207
+ "type": "string"
208
+ }
209
+ },
210
+ "storageOrigins": {
211
+ "description": "Origins whose Web Storage was scanned, sorted.",
212
+ "type": "array",
213
+ "items": {
214
+ "type": "string"
215
+ }
216
+ },
217
+ "rulesRun": {
218
+ "description": "Rule id to number of evaluations.",
219
+ "$ref": "#/$defs/counts"
220
+ }
221
+ }
222
+ },
223
+ "findingFields": {
224
+ "description": "A deduplicated finding (02, chapter 4).",
225
+ "type": "object",
226
+ "required": [
227
+ "ruleId",
228
+ "severity",
229
+ "confidence",
230
+ "scope",
231
+ "subject",
232
+ "location",
233
+ "evidence",
234
+ "message",
235
+ "fingerprint",
236
+ "occurrences",
237
+ "firstSeen",
238
+ "tests",
239
+ "sources"
240
+ ],
241
+ "properties": {
242
+ "ruleId": {
243
+ "$ref": "#/$defs/ruleId"
244
+ },
245
+ "severity": {
246
+ "$ref": "#/$defs/severity"
247
+ },
248
+ "confidence": {
249
+ "$ref": "#/$defs/confidence"
250
+ },
251
+ "scope": {
252
+ "$ref": "#/$defs/findingScope"
253
+ },
254
+ "subject": {
255
+ "description": "Origin, endpoint key, name@domain, storage key or normalized asset URL.",
256
+ "type": "string"
257
+ },
258
+ "discriminator": {
259
+ "description": "Tells apart findings of one rule on one subject (07-REQ-06); never a value.",
260
+ "type": "string"
261
+ },
262
+ "location": {
263
+ "$ref": "#/$defs/location"
264
+ },
265
+ "evidence": {
266
+ "type": "array",
267
+ "maxItems": 3,
268
+ "items": {
269
+ "$ref": "#/$defs/evidence"
270
+ }
271
+ },
272
+ "message": {
273
+ "type": "string"
274
+ },
275
+ "fingerprint": {
276
+ "type": "string",
277
+ "maxLength": 512
278
+ },
279
+ "occurrences": {
280
+ "type": "integer",
281
+ "minimum": 1
282
+ },
283
+ "firstSeen": {
284
+ "$ref": "#/$defs/testContextRef"
285
+ },
286
+ "tests": {
287
+ "description": "testId of every test the finding occurred in, at most 50.",
288
+ "type": "array",
289
+ "maxItems": 50,
290
+ "items": {
291
+ "type": "string"
292
+ }
293
+ },
294
+ "sources": {
295
+ "description": "Traffic sources the finding was seen in (15-REQ-09).",
296
+ "type": "array",
297
+ "minItems": 1,
298
+ "uniqueItems": true,
299
+ "items": {
300
+ "$ref": "#/$defs/source"
301
+ }
302
+ }
303
+ },
304
+ "title": "FindingFields"
305
+ }
306
+ }
307
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://pkg.invalid/schemas/outcome.schema.json",
4
+ "title": "Outcome file",
5
+ "description": "reports/pw-sec/outcome.json (02, chapter 7): the result code of the scan for CI, separate from the result of the functional tests (P-08).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "schemaVersion",
10
+ "code",
11
+ "name",
12
+ "testsPassed",
13
+ "newBlocking",
14
+ "newNonBlocking",
15
+ "expired",
16
+ "resolved"
17
+ ],
18
+ "properties": {
19
+ "schemaVersion": { "const": 1 },
20
+ "code": { "description": "00, chapter 11.", "enum": [0, 1, 2, 3, 4] },
21
+ "name": { "enum": ["OK", "NEW_FINDINGS", "BASELINE_EXPIRED", "TOOL_ERROR", "NO_TRAFFIC"] },
22
+ "testsPassed": { "description": "True when the functional tests passed.", "type": "boolean" },
23
+ "newBlocking": { "$ref": "common.schema.json#/$defs/count" },
24
+ "newNonBlocking": { "$ref": "common.schema.json#/$defs/count" },
25
+ "expired": { "$ref": "common.schema.json#/$defs/count" },
26
+ "resolved": { "$ref": "common.schema.json#/$defs/count" }
27
+ }
28
+ }