@cyvest/cyvest-js 2.0.1 → 3.0.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/dist/index.d.mts +291 -134
- package/dist/index.d.ts +291 -134
- package/dist/index.js +507 -471
- package/dist/index.mjs +507 -471
- package/package.json +1 -1
- package/src/levels.ts +16 -6
- package/src/types.generated.ts +285 -135
package/package.json
CHANGED
package/src/levels.ts
CHANGED
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
* for determining levels from scores.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
Observable,
|
|
10
|
+
Check,
|
|
11
|
+
ThreatIntel,
|
|
12
|
+
Container,
|
|
13
|
+
Level,
|
|
14
|
+
} from "./types.generated";
|
|
9
15
|
|
|
10
16
|
// Re-export Level type from types.generated for convenience
|
|
11
17
|
export type { Level } from "./types.generated";
|
|
@@ -237,9 +243,7 @@ export function getColorForScore(score: number): string {
|
|
|
237
243
|
/**
|
|
238
244
|
* Type guard to check if an object has a level property.
|
|
239
245
|
*/
|
|
240
|
-
export function hasLevel(
|
|
241
|
-
obj: unknown
|
|
242
|
-
): obj is { level: Level } {
|
|
246
|
+
export function hasLevel(obj: unknown): obj is { level: Level } {
|
|
243
247
|
return (
|
|
244
248
|
typeof obj === "object" &&
|
|
245
249
|
obj !== null &&
|
|
@@ -256,7 +260,13 @@ export function getEntityLevel(
|
|
|
256
260
|
entity: Observable | Check | ThreatIntel | Container
|
|
257
261
|
): Level {
|
|
258
262
|
if ("aggregated_level" in entity) {
|
|
259
|
-
|
|
263
|
+
const aggregatedLevel = entity.aggregated_level;
|
|
264
|
+
if (typeof aggregatedLevel === "string" && isValidLevel(aggregatedLevel)) {
|
|
265
|
+
return aggregatedLevel;
|
|
266
|
+
}
|
|
260
267
|
}
|
|
261
|
-
|
|
268
|
+
if ("level" in entity && isValidLevel(entity.level)) {
|
|
269
|
+
return entity.level;
|
|
270
|
+
}
|
|
271
|
+
throw new Error("Entity does not have a valid level.");
|
|
262
272
|
}
|
package/src/types.generated.ts
CHANGED
|
@@ -1,176 +1,326 @@
|
|
|
1
1
|
// AUTO-GENERATED FROM cyvest.schema.json — DO NOT EDIT
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Global investigation score.
|
|
5
5
|
*/
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
export type Score = number;
|
|
7
|
+
/**
|
|
8
|
+
* Security level classification for checks, observables, and threat intelligence.
|
|
9
|
+
*
|
|
10
|
+
* Levels are ordered from lowest (NONE) to highest (MALICIOUS) severity.
|
|
11
|
+
*/
|
|
12
|
+
export type Level = "NONE" | "TRUSTED" | "INFO" | "SAFE" | "NOTABLE" | "SUSPICIOUS" | "MALICIOUS";
|
|
13
|
+
/**
|
|
14
|
+
* Whether the investigation is whitelisted.
|
|
15
|
+
*/
|
|
16
|
+
export type Whitelisted = boolean;
|
|
17
|
+
export type Identifier = string;
|
|
18
|
+
export type Name = string;
|
|
19
|
+
export type Justification = string | null;
|
|
20
|
+
/**
|
|
21
|
+
* List of whitelist entries applied to this investigation.
|
|
22
|
+
*/
|
|
23
|
+
export type Whitelists = InvestigationWhitelist[];
|
|
24
|
+
export type Type = string;
|
|
25
|
+
export type Value = string;
|
|
26
|
+
export type Internal = boolean;
|
|
27
|
+
export type Whitelisted1 = boolean;
|
|
28
|
+
export type Comment = string;
|
|
29
|
+
export type Score1 = number;
|
|
30
|
+
export type ThreatIntels = string[];
|
|
31
|
+
export type TargetKey = string;
|
|
32
|
+
export type RelationshipType = string;
|
|
14
33
|
/**
|
|
15
34
|
* Direction of a relationship between observables.
|
|
16
35
|
*/
|
|
17
36
|
export type RelationshipDirection = "outbound" | "inbound" | "bidirectional";
|
|
37
|
+
export type Relationships = Relationship[];
|
|
38
|
+
export type Key = string;
|
|
18
39
|
/**
|
|
19
|
-
*
|
|
40
|
+
* Checks that generated this observable.
|
|
20
41
|
*/
|
|
21
|
-
export type
|
|
42
|
+
export type GeneratedByChecks = string[];
|
|
43
|
+
export type CheckId = string;
|
|
44
|
+
export type Scope = string;
|
|
45
|
+
export type Description = string;
|
|
46
|
+
export type Comment1 = string;
|
|
47
|
+
export type Score2 = number;
|
|
48
|
+
export type Observables1 = string[];
|
|
22
49
|
/**
|
|
23
|
-
*
|
|
50
|
+
* Controls how a check reacts to linked observables.
|
|
51
|
+
*/
|
|
52
|
+
export type CheckScorePolicy = "auto" | "manual";
|
|
53
|
+
export type Key1 = string;
|
|
54
|
+
export type Source = string;
|
|
55
|
+
export type ObservableKey = string;
|
|
56
|
+
export type Comment2 = string;
|
|
57
|
+
export type Score3 = number;
|
|
58
|
+
export type Taxonomies = {
|
|
59
|
+
[k: string]: unknown;
|
|
60
|
+
}[];
|
|
61
|
+
export type Key2 = string;
|
|
62
|
+
export type Name1 = string;
|
|
63
|
+
export type Context = string;
|
|
64
|
+
export type Key3 = string;
|
|
65
|
+
export type Path = string;
|
|
66
|
+
export type Description1 = string;
|
|
67
|
+
export type Checks1 = string[];
|
|
68
|
+
export type Key4 = string;
|
|
69
|
+
export type AggregatedScore = number;
|
|
70
|
+
export type TotalObservables = number;
|
|
71
|
+
export type InternalObservables = number;
|
|
72
|
+
export type ExternalObservables = number;
|
|
73
|
+
export type WhitelistedObservables = number;
|
|
74
|
+
export type TotalChecks = number;
|
|
75
|
+
export type AppliedChecks = number;
|
|
76
|
+
export type TotalThreatIntel = number;
|
|
77
|
+
export type TotalContainers = number;
|
|
78
|
+
export type Checks2 = number;
|
|
79
|
+
export type Applied = number;
|
|
80
|
+
/**
|
|
81
|
+
* Root observable type used during data extraction.
|
|
82
|
+
*/
|
|
83
|
+
export type RootType = string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Score calculation mode for observables.
|
|
24
86
|
*/
|
|
25
87
|
export type ScoreMode = "max" | "sum";
|
|
26
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Schema for a complete serialized investigation.
|
|
91
|
+
*
|
|
92
|
+
* This model describes the output of `serialize_investigation()` from
|
|
93
|
+
* `cyvest.io_serialization`. It is the top-level schema for exported investigations.
|
|
94
|
+
*
|
|
95
|
+
* Entity types reference the runtime models directly. When generating schemas with
|
|
96
|
+
* `mode='serialization'`, Pydantic respects field_serializer decorators and produces
|
|
97
|
+
* schemas matching the actual model_dump() output.
|
|
98
|
+
*/
|
|
27
99
|
export interface CyvestInvestigation {
|
|
28
|
-
score:
|
|
100
|
+
score: Score;
|
|
29
101
|
level: Level;
|
|
30
|
-
whitelisted:
|
|
31
|
-
whitelists:
|
|
32
|
-
observables:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
threat_intels: {
|
|
42
|
-
[k: string]: ThreatIntel;
|
|
43
|
-
};
|
|
44
|
-
enrichments: {
|
|
45
|
-
[k: string]: Enrichment;
|
|
46
|
-
};
|
|
47
|
-
containers: {
|
|
48
|
-
[k: string]: Container;
|
|
49
|
-
};
|
|
50
|
-
stats: Statistics;
|
|
51
|
-
stats_checks: StatsChecks;
|
|
52
|
-
data_extraction: DataExtraction;
|
|
102
|
+
whitelisted: Whitelisted;
|
|
103
|
+
whitelists: Whitelists;
|
|
104
|
+
observables: Observables;
|
|
105
|
+
checks: Checks;
|
|
106
|
+
checks_by_level: ChecksByLevel;
|
|
107
|
+
threat_intels: ThreatIntels1;
|
|
108
|
+
enrichments: Enrichments;
|
|
109
|
+
containers: Containers;
|
|
110
|
+
stats: StatisticsSchema;
|
|
111
|
+
stats_checks: StatsChecksSchema;
|
|
112
|
+
data_extraction: DataExtractionSchema;
|
|
53
113
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Represents a whitelist entry on an investigation.
|
|
116
|
+
*/
|
|
117
|
+
export interface InvestigationWhitelist {
|
|
118
|
+
identifier: Identifier;
|
|
119
|
+
name: Name;
|
|
120
|
+
justification?: Justification;
|
|
121
|
+
[k: string]: unknown;
|
|
58
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Observables keyed by their unique key.
|
|
125
|
+
*/
|
|
126
|
+
export interface Observables {
|
|
127
|
+
[k: string]: Observable;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Represents a cyber observable (IP, URL, domain, hash, etc.).
|
|
131
|
+
*
|
|
132
|
+
* Observables can be linked to threat intelligence, checks, and other observables
|
|
133
|
+
* through relationships.
|
|
134
|
+
*/
|
|
59
135
|
export interface Observable {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
whitelisted: boolean;
|
|
68
|
-
comment: string;
|
|
69
|
-
extra: {
|
|
70
|
-
[k: string]: unknown;
|
|
71
|
-
} | null;
|
|
72
|
-
score: number;
|
|
136
|
+
type: Type;
|
|
137
|
+
value: Value;
|
|
138
|
+
internal: Internal;
|
|
139
|
+
whitelisted: Whitelisted1;
|
|
140
|
+
comment: Comment;
|
|
141
|
+
extra: Extra;
|
|
142
|
+
score: Score1;
|
|
73
143
|
level: Level;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
144
|
+
threat_intels: ThreatIntels;
|
|
145
|
+
relationships: Relationships;
|
|
146
|
+
key: Key;
|
|
147
|
+
generated_by_checks: GeneratedByChecks;
|
|
148
|
+
[k: string]: unknown;
|
|
149
|
+
}
|
|
150
|
+
export interface Extra {
|
|
151
|
+
[k: string]: unknown;
|
|
77
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Represents a relationship between observables.
|
|
155
|
+
*/
|
|
78
156
|
export interface Relationship {
|
|
79
|
-
target_key:
|
|
80
|
-
|
|
81
|
-
* Relationship label; defaults to related-to.
|
|
82
|
-
*/
|
|
83
|
-
relationship_type: string;
|
|
157
|
+
target_key: TargetKey;
|
|
158
|
+
relationship_type: RelationshipType;
|
|
84
159
|
direction: RelationshipDirection;
|
|
160
|
+
[k: string]: unknown;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Checks organized by scope.
|
|
164
|
+
*/
|
|
165
|
+
export interface Checks {
|
|
166
|
+
[k: string]: Check[];
|
|
85
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Represents a verification step in the investigation.
|
|
170
|
+
*
|
|
171
|
+
* A check validates a specific aspect of the data under investigation
|
|
172
|
+
* and contributes to the overall investigation score.
|
|
173
|
+
*/
|
|
86
174
|
export interface Check {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
[k: string]: unknown;
|
|
94
|
-
} | null;
|
|
95
|
-
score: number;
|
|
175
|
+
check_id: CheckId;
|
|
176
|
+
scope: Scope;
|
|
177
|
+
description: Description;
|
|
178
|
+
comment: Comment1;
|
|
179
|
+
extra: Extra1;
|
|
180
|
+
score: Score2;
|
|
96
181
|
level: Level;
|
|
97
|
-
|
|
98
|
-
|
|
182
|
+
observables: Observables1;
|
|
183
|
+
score_policy?: CheckScorePolicy;
|
|
184
|
+
key: Key1;
|
|
185
|
+
[k: string]: unknown;
|
|
186
|
+
}
|
|
187
|
+
export interface Extra1 {
|
|
188
|
+
[k: string]: unknown;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Check keys organized by level name.
|
|
192
|
+
*/
|
|
193
|
+
export interface ChecksByLevel {
|
|
194
|
+
[k: string]: string[];
|
|
99
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Threat intelligence entries keyed by their unique key.
|
|
198
|
+
*/
|
|
199
|
+
export interface ThreatIntels1 {
|
|
200
|
+
[k: string]: ThreatIntel;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Represents threat intelligence from an external source.
|
|
204
|
+
*
|
|
205
|
+
* Threat intelligence provides verdicts about observables from sources
|
|
206
|
+
* like VirusTotal, URLScan.io, etc.
|
|
207
|
+
*/
|
|
100
208
|
export interface ThreatIntel {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
[k: string]: unknown;
|
|
107
|
-
} | null;
|
|
108
|
-
score: number;
|
|
209
|
+
source: Source;
|
|
210
|
+
observable_key: ObservableKey;
|
|
211
|
+
comment: Comment2;
|
|
212
|
+
extra: Extra2;
|
|
213
|
+
score: Score3;
|
|
109
214
|
level: Level;
|
|
110
|
-
taxonomies:
|
|
111
|
-
|
|
112
|
-
|
|
215
|
+
taxonomies: Taxonomies;
|
|
216
|
+
key: Key2;
|
|
217
|
+
[k: string]: unknown;
|
|
218
|
+
}
|
|
219
|
+
export interface Extra2 {
|
|
220
|
+
[k: string]: unknown;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Enrichment entries keyed by their unique key.
|
|
224
|
+
*/
|
|
225
|
+
export interface Enrichments {
|
|
226
|
+
[k: string]: Enrichment;
|
|
113
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Represents structured data enrichment for the investigation.
|
|
230
|
+
*
|
|
231
|
+
* Enrichments store arbitrary structured data that provides additional
|
|
232
|
+
* context but doesn't directly contribute to scoring.
|
|
233
|
+
*/
|
|
114
234
|
export interface Enrichment {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
235
|
+
name: Name1;
|
|
236
|
+
data: Data;
|
|
237
|
+
context: Context;
|
|
238
|
+
key: Key3;
|
|
239
|
+
[k: string]: unknown;
|
|
240
|
+
}
|
|
241
|
+
export interface Data {
|
|
242
|
+
[k: string]: unknown;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Containers keyed by their unique key.
|
|
246
|
+
*/
|
|
247
|
+
export interface Containers {
|
|
248
|
+
[k: string]: Container;
|
|
121
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Groups checks and sub-containers for hierarchical organization.
|
|
252
|
+
*
|
|
253
|
+
* Containers allow structuring the investigation into logical sections
|
|
254
|
+
* with aggregated scores and levels.
|
|
255
|
+
*/
|
|
122
256
|
export interface Container {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
130
|
-
aggregated_score: number;
|
|
257
|
+
path: Path;
|
|
258
|
+
description?: Description1;
|
|
259
|
+
checks: Checks1;
|
|
260
|
+
sub_containers: SubContainers;
|
|
261
|
+
key: Key4;
|
|
262
|
+
aggregated_score: AggregatedScore;
|
|
131
263
|
aggregated_level: Level;
|
|
132
264
|
}
|
|
133
|
-
export interface
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
total_checks:
|
|
150
|
-
applied_checks:
|
|
151
|
-
checks_by_scope
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
265
|
+
export interface SubContainers {
|
|
266
|
+
[k: string]: Container;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Schema for investigation statistics.
|
|
270
|
+
*
|
|
271
|
+
* Mirrors the output of `InvestigationStats.get_summary()`.
|
|
272
|
+
*/
|
|
273
|
+
export interface StatisticsSchema {
|
|
274
|
+
total_observables: TotalObservables;
|
|
275
|
+
internal_observables: InternalObservables;
|
|
276
|
+
external_observables: ExternalObservables;
|
|
277
|
+
whitelisted_observables: WhitelistedObservables;
|
|
278
|
+
observables_by_type?: ObservablesByType;
|
|
279
|
+
observables_by_level?: ObservablesByLevel;
|
|
280
|
+
observables_by_type_and_level?: ObservablesByTypeAndLevel;
|
|
281
|
+
total_checks: TotalChecks;
|
|
282
|
+
applied_checks: AppliedChecks;
|
|
283
|
+
checks_by_scope?: ChecksByScope;
|
|
284
|
+
checks_by_level?: ChecksByLevel1;
|
|
285
|
+
total_threat_intel: TotalThreatIntel;
|
|
286
|
+
threat_intel_by_source?: ThreatIntelBySource;
|
|
287
|
+
threat_intel_by_level?: ThreatIntelByLevel;
|
|
288
|
+
total_containers: TotalContainers;
|
|
289
|
+
}
|
|
290
|
+
export interface ObservablesByType {
|
|
291
|
+
[k: string]: number;
|
|
292
|
+
}
|
|
293
|
+
export interface ObservablesByLevel {
|
|
294
|
+
[k: string]: number;
|
|
295
|
+
}
|
|
296
|
+
export interface ObservablesByTypeAndLevel {
|
|
297
|
+
[k: string]: {
|
|
162
298
|
[k: string]: number;
|
|
163
299
|
};
|
|
164
|
-
total_containers: number;
|
|
165
300
|
}
|
|
166
|
-
export interface
|
|
167
|
-
|
|
168
|
-
|
|
301
|
+
export interface ChecksByScope {
|
|
302
|
+
[k: string]: number;
|
|
303
|
+
}
|
|
304
|
+
export interface ChecksByLevel1 {
|
|
305
|
+
[k: string]: number;
|
|
306
|
+
}
|
|
307
|
+
export interface ThreatIntelBySource {
|
|
308
|
+
[k: string]: number;
|
|
309
|
+
}
|
|
310
|
+
export interface ThreatIntelByLevel {
|
|
311
|
+
[k: string]: number;
|
|
169
312
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Schema for check statistics summary.
|
|
315
|
+
*/
|
|
316
|
+
export interface StatsChecksSchema {
|
|
317
|
+
checks: Checks2;
|
|
318
|
+
applied: Applied;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Schema for data extraction metadata.
|
|
322
|
+
*/
|
|
323
|
+
export interface DataExtractionSchema {
|
|
324
|
+
root_type?: RootType;
|
|
175
325
|
score_mode: ScoreMode;
|
|
176
326
|
}
|