@adversarylabs/sdk 0.1.3 → 0.1.4

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.
@@ -0,0 +1,275 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ node_modules
2
+ dist
3
+ coverage
4
+ .git
5
+ *.log
@@ -1,9 +1,16 @@
1
- FROM node:22-slim
1
+ FROM node:22-slim AS build
2
2
 
3
3
  WORKDIR /app
4
- COPY package*.json ./
5
- RUN npm install
4
+ COPY package.json npm-shrinkwrap.json ./
5
+ RUN npm ci
6
6
  COPY . .
7
7
  RUN npm run build
8
8
 
9
- CMD ["npm", "start"]
9
+ FROM node:22-slim AS runtime
10
+ ENV NODE_ENV=production
11
+ WORKDIR /app
12
+ COPY package.json npm-shrinkwrap.json ./
13
+ RUN npm ci --omit=dev && npm cache clean --force
14
+ COPY --from=build /app/dist ./dist
15
+ USER node
16
+ CMD ["node", "dist/index.js"]
@@ -3,10 +3,12 @@
3
3
  Minimal TypeScript Adversary built with `@adversarylabs/sdk`.
4
4
 
5
5
  ```bash
6
- npm install
6
+ npm ci
7
7
  npm test
8
8
  npm run build
9
9
  npm start
10
10
  ```
11
11
 
12
12
  At runtime the adversary reads `/adversary/input.json` and writes `/adversary/output.json`.
13
+ The included informational finding is intentionally visible so a clean run demonstrates the full
14
+ SDK path; replace it with your own rules before publishing.
@@ -24,4 +24,4 @@ permissions:
24
24
  env: []
25
25
 
26
26
  findings:
27
- format: adversary.findings.v1
27
+ format: adversary.run.v1