@adversarylabs/sdk 0.1.4 → 0.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adversarylabs/sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Small TypeScript SDK for authoring Adversaries.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  "import": "./dist/index.js"
24
24
  },
25
25
  "./schemas/adversary.input.v1": "./schemas/adversary.input.v1.schema.json",
26
- "./schemas/adversary.run.v1": "./schemas/adversary.run.v1.schema.json"
26
+ "./schemas/adversary.review.v1": "./schemas/adversary.review.v1.schema.json"
27
27
  },
28
28
  "files": ["dist", "schemas", "templates", "README.md"],
29
29
  "engines": {
@@ -40,8 +40,10 @@
40
40
  "devDependencies": {
41
41
  "@biomejs/biome": "^1.9.4",
42
42
  "@types/node": "^22.20.1",
43
- "ajv": "^8.17.1",
44
43
  "typescript": "^5.9.3",
45
44
  "vitest": "^4.1.10"
45
+ },
46
+ "dependencies": {
47
+ "ajv": "^8.20.0"
46
48
  }
47
49
  }
@@ -0,0 +1,136 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://adversary.dev/schemas/adversary.review.v1.schema.json",
4
+ "title": "Adversary review envelope v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["protocolVersion", "result"],
8
+ "properties": {
9
+ "protocolVersion": { "const": 1 },
10
+ "result": { "$ref": "#/$defs/reviewResult" }
11
+ },
12
+ "$defs": {
13
+ "metadata": { "type": "object" },
14
+ "adversary": {
15
+ "type": "object",
16
+ "additionalProperties": false,
17
+ "required": ["name"],
18
+ "properties": {
19
+ "name": { "type": "string", "minLength": 1, "pattern": "\\S" },
20
+ "version": { "type": "string" }
21
+ }
22
+ },
23
+ "target": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "properties": {
27
+ "repository": { "type": "string" },
28
+ "filesScanned": { "type": "integer", "minimum": 0 }
29
+ }
30
+ },
31
+ "evidence": {
32
+ "type": "object",
33
+ "additionalProperties": false,
34
+ "properties": {
35
+ "file": { "type": "string" },
36
+ "line": { "type": "integer", "minimum": 1 },
37
+ "endLine": { "type": "integer", "minimum": 1 },
38
+ "message": { "type": "string" },
39
+ "snippet": { "type": "string" },
40
+ "metadata": { "$ref": "#/$defs/metadata" }
41
+ },
42
+ "dependentRequired": { "endLine": ["line"] }
43
+ },
44
+ "note": {
45
+ "type": "object",
46
+ "additionalProperties": false,
47
+ "required": ["key", "summary"],
48
+ "properties": {
49
+ "key": { "type": "string", "minLength": 1, "pattern": "\\S" },
50
+ "summary": { "type": "string", "minLength": 1, "pattern": "\\S" },
51
+ "evidence": { "type": "array", "items": { "$ref": "#/$defs/evidence" } },
52
+ "metadata": { "$ref": "#/$defs/metadata" }
53
+ }
54
+ },
55
+ "finding": {
56
+ "type": "object",
57
+ "additionalProperties": false,
58
+ "required": ["id", "title", "category", "severity", "confidence", "summary", "evidence"],
59
+ "properties": {
60
+ "id": { "type": "string", "minLength": 1, "pattern": "\\S" },
61
+ "ruleId": { "type": "string" },
62
+ "groupKey": { "type": "string" },
63
+ "title": { "type": "string", "minLength": 1, "pattern": "\\S" },
64
+ "category": { "type": "string", "minLength": 1, "pattern": "\\S" },
65
+ "severity": { "enum": ["info", "low", "medium", "high", "critical"] },
66
+ "confidence": { "enum": ["low", "medium", "high"] },
67
+ "summary": { "type": "string", "minLength": 1, "pattern": "\\S" },
68
+ "whyItMatters": { "type": "string" },
69
+ "impact": { "type": "string" },
70
+ "evidence": { "type": "array", "items": { "$ref": "#/$defs/evidence" } },
71
+ "recommendation": { "type": "string" },
72
+ "remediation": {
73
+ "type": "object",
74
+ "additionalProperties": false,
75
+ "properties": {
76
+ "estimate": { "type": "string" },
77
+ "complexity": { "type": "string" }
78
+ }
79
+ },
80
+ "tags": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
81
+ "metadata": { "$ref": "#/$defs/metadata" }
82
+ }
83
+ },
84
+ "reviewResult": {
85
+ "type": "object",
86
+ "additionalProperties": false,
87
+ "required": ["adversary", "target", "positives", "observations", "findings", "suppressed"],
88
+ "properties": {
89
+ "adversary": { "$ref": "#/$defs/adversary" },
90
+ "target": { "$ref": "#/$defs/target" },
91
+ "assessment": {
92
+ "type": "object",
93
+ "additionalProperties": false,
94
+ "required": ["risk"],
95
+ "properties": {
96
+ "risk": { "enum": ["none", "low", "medium", "high", "critical"] },
97
+ "summary": { "type": "string" }
98
+ }
99
+ },
100
+ "positives": { "type": "array", "items": { "$ref": "#/$defs/note" } },
101
+ "observations": { "type": "array", "items": { "$ref": "#/$defs/note" } },
102
+ "findings": { "type": "array", "items": { "$ref": "#/$defs/finding" } },
103
+ "opinion": {
104
+ "type": "object",
105
+ "additionalProperties": false,
106
+ "required": ["summary"],
107
+ "properties": {
108
+ "ship": { "type": "boolean" },
109
+ "summary": { "type": "string", "minLength": 1, "pattern": "\\S" }
110
+ }
111
+ },
112
+ "suppressed": {
113
+ "type": "object",
114
+ "additionalProperties": false,
115
+ "required": ["observations", "findings"],
116
+ "properties": {
117
+ "observations": { "type": "integer", "minimum": 0 },
118
+ "findings": { "type": "integer", "minimum": 0 }
119
+ }
120
+ },
121
+ "timing": {
122
+ "type": "object",
123
+ "additionalProperties": false,
124
+ "properties": {
125
+ "buildMs": { "type": "integer", "minimum": 0 },
126
+ "startupMs": { "type": "integer", "minimum": 0 },
127
+ "scanMs": { "type": "integer", "minimum": 0 },
128
+ "totalMs": { "type": "integer", "minimum": 0 }
129
+ }
130
+ },
131
+ "suppressedFindings": { "type": "array", "items": { "$ref": "#/$defs/finding" } },
132
+ "rawObservations": {}
133
+ }
134
+ }
135
+ }
136
+ }
@@ -24,4 +24,4 @@ permissions:
24
24
  env: []
25
25
 
26
26
  findings:
27
- format: adversary.run.v1
27
+ format: adversary.review.v1
@@ -8,7 +8,7 @@
8
8
  "name": "basic-adversary",
9
9
  "version": "0.1.0",
10
10
  "dependencies": {
11
- "@adversarylabs/sdk": "^0.1.3"
11
+ "@adversarylabs/sdk": "^0.1.5"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@types/node": "^22.20.1",
@@ -17,14 +17,69 @@
17
17
  }
18
18
  },
19
19
  "node_modules/@adversarylabs/sdk": {
20
- "version": "0.1.3",
21
- "resolved": "https://registry.npmjs.org/@adversarylabs/sdk/-/sdk-0.1.3.tgz",
22
- "integrity": "sha512-U81OxcUfquqAwMcJHll5wUNV/gz/BfeMNrqTnYfcwLAFLkZLxk8VSBMi3KxHEhWWRSo9rZ17kGIbUoxJd/36uQ==",
20
+ "version": "0.1.5",
21
+ "resolved": "https://registry.npmjs.org/@adversarylabs/sdk/-/sdk-0.1.5.tgz",
23
22
  "license": "MIT",
23
+ "dependencies": {
24
+ "ajv": "^8.20.0"
25
+ },
24
26
  "engines": {
25
27
  "node": ">=22"
26
28
  }
27
29
  },
30
+ "node_modules/ajv": {
31
+ "version": "8.20.0",
32
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
33
+ "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
34
+ "license": "MIT",
35
+ "dependencies": {
36
+ "fast-deep-equal": "^3.1.3",
37
+ "fast-uri": "^3.0.1",
38
+ "json-schema-traverse": "^1.0.0",
39
+ "require-from-string": "^2.0.2"
40
+ },
41
+ "funding": {
42
+ "type": "github",
43
+ "url": "https://github.com/sponsors/epoberezkin"
44
+ }
45
+ },
46
+ "node_modules/fast-deep-equal": {
47
+ "version": "3.1.3",
48
+ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
49
+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
50
+ "license": "MIT"
51
+ },
52
+ "node_modules/fast-uri": {
53
+ "version": "3.1.3",
54
+ "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.3.tgz",
55
+ "integrity": "sha512-i70LwGWUduXqzicKXWshooq+sWL1K3WUU5rKZNG/0i3a1OSoX3HqhH5WbWwTmqWfor4urUakGPiRQcleRZTwOg==",
56
+ "funding": [
57
+ {
58
+ "type": "github",
59
+ "url": "https://github.com/sponsors/fastify"
60
+ },
61
+ {
62
+ "type": "opencollective",
63
+ "url": "https://opencollective.com/fastify"
64
+ }
65
+ ],
66
+ "license": "BSD-3-Clause"
67
+ },
68
+ "node_modules/json-schema-traverse": {
69
+ "version": "1.0.0",
70
+ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
71
+ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
72
+ "license": "MIT"
73
+ },
74
+ "node_modules/require-from-string": {
75
+ "version": "2.0.2",
76
+ "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
77
+ "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
78
+ "license": "MIT",
79
+ "engines": {
80
+ "node": ">=0.10.0"
81
+ }
82
+ },
28
83
  "node_modules/@emnapi/core": {
29
84
  "version": "1.11.1",
30
85
  "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.1.tgz",
@@ -9,7 +9,7 @@
9
9
  "test": "vitest run"
10
10
  },
11
11
  "dependencies": {
12
- "@adversarylabs/sdk": "^0.1.3"
12
+ "@adversarylabs/sdk": "^0.1.5"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/node": "^22.20.1",
@@ -22,11 +22,5 @@ adversary.rule("basic.ran", (ctx) => {
22
22
  export default adversary;
23
23
 
24
24
  if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href) {
25
- // Keep the published starter runnable with the bootstrap SDK pinned in its shrinkwrap.
26
- // New projects use the explicit runtime adapter; older 0.x SDKs retain run() as that adapter.
27
- if ("runFromEnvironment" in adversary) {
28
- await adversary.runFromEnvironment();
29
- } else {
30
- await (adversary.run as unknown as () => Promise<unknown>)();
31
- }
25
+ await adversary.runFromEnvironment();
32
26
  }
@@ -1,275 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.adversarylabs.com/adversary.run.v1.schema.json",
4
- "title": "Adversary Run Envelope",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "required": ["protocolVersion", "result"],
8
- "properties": {
9
- "protocolVersion": { "const": 1 },
10
- "result": { "$ref": "#/$defs/reviewResult" }
11
- },
12
- "$defs": {
13
- "severity": {
14
- "enum": ["info", "low", "medium", "high", "critical"]
15
- },
16
- "confidence": {
17
- "enum": ["low", "medium", "high"]
18
- },
19
- "location": {
20
- "type": "object",
21
- "additionalProperties": false,
22
- "properties": {
23
- "file": { "type": "string" },
24
- "line": { "type": "integer", "minimum": 1 },
25
- "endLine": { "type": "integer", "minimum": 1 }
26
- }
27
- },
28
- "evidence": {
29
- "type": "object",
30
- "additionalProperties": false,
31
- "properties": {
32
- "location": { "$ref": "#/$defs/location" },
33
- "label": { "type": "string" },
34
- "message": { "type": "string" },
35
- "snippet": { "type": "string" },
36
- "data": { "type": "object", "additionalProperties": true }
37
- }
38
- },
39
- "evidenceInput": {
40
- "type": "object",
41
- "additionalProperties": false,
42
- "properties": {
43
- "location": { "$ref": "#/$defs/location" },
44
- "file": { "type": "string" },
45
- "line": { "type": "integer", "minimum": 1 },
46
- "endLine": { "type": "integer", "minimum": 1 },
47
- "label": { "type": "string" },
48
- "message": { "type": "string" },
49
- "snippet": { "type": "string" },
50
- "data": { "type": "object", "additionalProperties": true },
51
- "metadata": { "type": "object", "additionalProperties": true }
52
- }
53
- },
54
- "remediation": {
55
- "type": "object",
56
- "additionalProperties": false,
57
- "properties": {
58
- "complexity": {
59
- "enum": ["trivial", "small", "medium", "large", "architectural"]
60
- }
61
- }
62
- },
63
- "finding": {
64
- "type": "object",
65
- "additionalProperties": false,
66
- "required": ["id", "title", "category", "severity", "confidence", "summary", "evidence"],
67
- "properties": {
68
- "id": { "type": "string", "minLength": 1 },
69
- "ruleId": { "type": "string", "minLength": 1 },
70
- "groupKey": { "type": "string", "minLength": 1 },
71
- "title": { "type": "string", "minLength": 1 },
72
- "category": { "type": "string", "minLength": 1 },
73
- "severity": { "$ref": "#/$defs/severity" },
74
- "confidence": { "$ref": "#/$defs/confidence" },
75
- "summary": { "type": "string", "minLength": 1 },
76
- "whyItMatters": { "type": "string" },
77
- "impact": { "type": "string" },
78
- "evidence": {
79
- "type": "array",
80
- "items": { "$ref": "#/$defs/evidence" }
81
- },
82
- "recommendation": { "type": "string" },
83
- "remediation": { "$ref": "#/$defs/remediation" },
84
- "synthesisSource": { "enum": ["rule", "generic"] },
85
- "tags": {
86
- "type": "array",
87
- "items": { "type": "string" }
88
- },
89
- "metadata": { "type": "object", "additionalProperties": true }
90
- }
91
- },
92
- "reviewNote": {
93
- "type": "object",
94
- "additionalProperties": false,
95
- "required": ["key", "summary"],
96
- "properties": {
97
- "key": { "type": "string", "minLength": 1 },
98
- "summary": { "type": "string", "minLength": 1 },
99
- "evidence": {
100
- "type": "array",
101
- "items": { "$ref": "#/$defs/evidence" }
102
- },
103
- "metadata": { "type": "object", "additionalProperties": true }
104
- }
105
- },
106
- "assessment": {
107
- "type": "object",
108
- "additionalProperties": false,
109
- "required": ["risk"],
110
- "properties": {
111
- "risk": { "enum": ["none", "low", "medium", "high", "critical"] },
112
- "summary": { "type": "string" }
113
- }
114
- },
115
- "opinion": {
116
- "type": "object",
117
- "additionalProperties": false,
118
- "required": ["summary"],
119
- "properties": {
120
- "ship": { "type": "boolean" },
121
- "summary": { "type": "string", "minLength": 1 }
122
- }
123
- },
124
- "score": {
125
- "type": "object",
126
- "additionalProperties": false,
127
- "required": ["key", "score"],
128
- "properties": {
129
- "key": { "type": "string", "minLength": 1 },
130
- "label": { "type": "string" },
131
- "score": { "type": "number" },
132
- "max": { "type": "number" },
133
- "summary": { "type": "string" }
134
- }
135
- },
136
- "observationTitle": {
137
- "oneOf": [
138
- { "type": "string", "minLength": 1 },
139
- {
140
- "type": "object",
141
- "additionalProperties": false,
142
- "required": ["singular", "plural"],
143
- "properties": {
144
- "singular": { "type": "string", "minLength": 1 },
145
- "plural": { "type": "string", "minLength": 1 }
146
- }
147
- }
148
- ]
149
- },
150
- "observationSummary": {
151
- "oneOf": [
152
- { "type": "string" },
153
- {
154
- "type": "object",
155
- "additionalProperties": false,
156
- "properties": {
157
- "singular": { "type": "string" },
158
- "grouped": { "type": "string" }
159
- }
160
- }
161
- ]
162
- },
163
- "recommendationInput": {
164
- "type": "object",
165
- "additionalProperties": false,
166
- "required": ["summary"],
167
- "properties": {
168
- "summary": { "type": "string", "minLength": 1 },
169
- "details": { "type": "string" }
170
- }
171
- },
172
- "observation": {
173
- "type": "object",
174
- "additionalProperties": false,
175
- "required": ["ruleId", "subject", "title"],
176
- "properties": {
177
- "ruleId": { "type": "string", "minLength": 1 },
178
- "subject": { "type": "string", "minLength": 1 },
179
- "groupKey": { "type": "string" },
180
- "groupBy": { "type": "array", "items": { "type": "string" } },
181
- "groupedTitle": { "type": "string" },
182
- "deduplicate": { "type": "boolean" },
183
- "category": { "type": "string" },
184
- "severity": { "$ref": "#/$defs/severity" },
185
- "confidence": {
186
- "oneOf": [
187
- { "$ref": "#/$defs/confidence" },
188
- { "type": "number", "minimum": 0, "maximum": 1 }
189
- ]
190
- },
191
- "confidenceAggregation": { "enum": ["maximum", "minimum", "average"] },
192
- "severityAggregation": { "enum": ["highest", "lowest"] },
193
- "title": { "$ref": "#/$defs/observationTitle" },
194
- "summary": { "$ref": "#/$defs/observationSummary" },
195
- "whyItMatters": { "type": "string" },
196
- "impact": { "type": "string" },
197
- "location": { "$ref": "#/$defs/evidenceInput" },
198
- "evidence": {
199
- "oneOf": [{ "type": "string" }, { "type": "object", "additionalProperties": true }]
200
- },
201
- "recommendation": {
202
- "oneOf": [{ "type": "string" }, { "$ref": "#/$defs/recommendationInput" }]
203
- },
204
- "remediation": { "$ref": "#/$defs/remediation" },
205
- "tags": { "type": "array", "items": { "type": "string" } },
206
- "metadata": { "type": "object", "additionalProperties": true }
207
- }
208
- },
209
- "reviewResult": {
210
- "type": "object",
211
- "additionalProperties": false,
212
- "required": [
213
- "schemaVersion",
214
- "adversary",
215
- "target",
216
- "positives",
217
- "observations",
218
- "findings",
219
- "suppressed"
220
- ],
221
- "properties": {
222
- "schemaVersion": { "const": "adversary.review.v1" },
223
- "adversary": {
224
- "type": "object",
225
- "additionalProperties": false,
226
- "required": ["name"],
227
- "properties": {
228
- "name": { "type": "string", "minLength": 1 },
229
- "version": { "type": "string" }
230
- }
231
- },
232
- "target": {
233
- "type": "object",
234
- "additionalProperties": false,
235
- "properties": {
236
- "repository": { "type": "string" },
237
- "filesScanned": { "type": "number" }
238
- }
239
- },
240
- "assessment": { "$ref": "#/$defs/assessment" },
241
- "positives": { "type": "array", "items": { "$ref": "#/$defs/reviewNote" } },
242
- "observations": { "type": "array", "items": { "$ref": "#/$defs/reviewNote" } },
243
- "scores": { "type": "array", "items": { "$ref": "#/$defs/score" } },
244
- "findings": { "type": "array", "items": { "$ref": "#/$defs/finding" } },
245
- "opinion": { "$ref": "#/$defs/opinion" },
246
- "suppressed": {
247
- "type": "object",
248
- "additionalProperties": false,
249
- "required": ["findings"],
250
- "properties": {
251
- "findings": { "type": "integer", "minimum": 0 }
252
- }
253
- },
254
- "timing": {
255
- "type": "object",
256
- "additionalProperties": false,
257
- "properties": {
258
- "buildMs": { "type": "number", "minimum": 0 },
259
- "startupMs": { "type": "number", "minimum": 0 },
260
- "scanMs": { "type": "number", "minimum": 0 },
261
- "totalMs": { "type": "number", "minimum": 0 }
262
- }
263
- },
264
- "suppressedFindings": {
265
- "type": "array",
266
- "items": { "$ref": "#/$defs/finding" }
267
- },
268
- "rawObservations": {
269
- "type": "array",
270
- "items": { "$ref": "#/$defs/observation" }
271
- }
272
- }
273
- }
274
- }
275
- }