@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.ts CHANGED
@@ -1,167 +1,324 @@
1
1
  /**
2
- * Security level classification from NONE (lowest) to MALICIOUS (highest).
2
+ * Global investigation score.
3
+ */
4
+ type Score = number;
5
+ /**
6
+ * Security level classification for checks, observables, and threat intelligence.
7
+ *
8
+ * Levels are ordered from lowest (NONE) to highest (MALICIOUS) severity.
3
9
  */
4
10
  type Level = "NONE" | "TRUSTED" | "INFO" | "SAFE" | "NOTABLE" | "SUSPICIOUS" | "MALICIOUS";
5
11
  /**
6
- * Direction of a relationship between observables.
12
+ * Whether the investigation is whitelisted.
7
13
  */
8
- type RelationshipDirection = "outbound" | "inbound" | "bidirectional";
14
+ type Whitelisted = boolean;
15
+ type Identifier = string;
16
+ type Name = string;
17
+ type Justification = string | null;
9
18
  /**
10
- * Score computation policy: 'auto' calculates from level, 'manual' uses explicit score.
19
+ * List of whitelist entries applied to this investigation.
11
20
  */
12
- type ScorePolicy = "auto" | "manual";
21
+ type Whitelists = InvestigationWhitelist[];
22
+ type Type = string;
23
+ type Value = string;
24
+ type Internal = boolean;
25
+ type Whitelisted1 = boolean;
26
+ type Comment = string;
27
+ type Score1 = number;
28
+ type ThreatIntels = string[];
29
+ type TargetKey = string;
30
+ type RelationshipType = string;
13
31
  /**
14
- * Score aggregation mode: 'max' takes highest score, 'sum' adds all scores.
32
+ * Direction of a relationship between observables.
33
+ */
34
+ type RelationshipDirection = "outbound" | "inbound" | "bidirectional";
35
+ type Relationships = Relationship[];
36
+ type Key = string;
37
+ /**
38
+ * Checks that generated this observable.
39
+ */
40
+ type GeneratedByChecks = string[];
41
+ type CheckId = string;
42
+ type Scope = string;
43
+ type Description = string;
44
+ type Comment1 = string;
45
+ type Score2 = number;
46
+ type Observables1 = string[];
47
+ /**
48
+ * Controls how a check reacts to linked observables.
49
+ */
50
+ type CheckScorePolicy = "auto" | "manual";
51
+ type Key1 = string;
52
+ type Source = string;
53
+ type ObservableKey = string;
54
+ type Comment2 = string;
55
+ type Score3 = number;
56
+ type Taxonomies = {
57
+ [k: string]: unknown;
58
+ }[];
59
+ type Key2 = string;
60
+ type Name1 = string;
61
+ type Context = string;
62
+ type Key3 = string;
63
+ type Path = string;
64
+ type Description1 = string;
65
+ type Checks1 = string[];
66
+ type Key4 = string;
67
+ type AggregatedScore = number;
68
+ type TotalObservables = number;
69
+ type InternalObservables = number;
70
+ type ExternalObservables = number;
71
+ type WhitelistedObservables = number;
72
+ type TotalChecks = number;
73
+ type AppliedChecks = number;
74
+ type TotalThreatIntel = number;
75
+ type TotalContainers = number;
76
+ type Checks2 = number;
77
+ type Applied = number;
78
+ /**
79
+ * Root observable type used during data extraction.
80
+ */
81
+ type RootType = string | null;
82
+ /**
83
+ * Score calculation mode for observables.
15
84
  */
16
85
  type ScoreMode = "max" | "sum";
86
+ /**
87
+ * Schema for a complete serialized investigation.
88
+ *
89
+ * This model describes the output of `serialize_investigation()` from
90
+ * `cyvest.io_serialization`. It is the top-level schema for exported investigations.
91
+ *
92
+ * Entity types reference the runtime models directly. When generating schemas with
93
+ * `mode='serialization'`, Pydantic respects field_serializer decorators and produces
94
+ * schemas matching the actual model_dump() output.
95
+ */
17
96
  interface CyvestInvestigation {
18
- score: number;
97
+ score: Score;
19
98
  level: Level;
20
- whitelisted: boolean;
21
- whitelists: Whitelist[];
22
- observables: {
23
- [k: string]: Observable;
24
- };
25
- checks: {
26
- [k: string]: Check[];
27
- };
28
- checks_by_level: {
29
- [k: string]: string[];
30
- };
31
- threat_intels: {
32
- [k: string]: ThreatIntel;
33
- };
34
- enrichments: {
35
- [k: string]: Enrichment;
36
- };
37
- containers: {
38
- [k: string]: Container;
39
- };
40
- stats: Statistics;
41
- stats_checks: StatsChecks;
42
- data_extraction: DataExtraction;
99
+ whitelisted: Whitelisted;
100
+ whitelists: Whitelists;
101
+ observables: Observables;
102
+ checks: Checks;
103
+ checks_by_level: ChecksByLevel;
104
+ threat_intels: ThreatIntels1;
105
+ enrichments: Enrichments;
106
+ containers: Containers;
107
+ stats: StatisticsSchema;
108
+ stats_checks: StatsChecksSchema;
109
+ data_extraction: DataExtractionSchema;
110
+ }
111
+ /**
112
+ * Represents a whitelist entry on an investigation.
113
+ */
114
+ interface InvestigationWhitelist {
115
+ identifier: Identifier;
116
+ name: Name;
117
+ justification?: Justification;
118
+ [k: string]: unknown;
43
119
  }
44
- interface Whitelist {
45
- identifier: string;
46
- name: string;
47
- justification?: string | null;
120
+ /**
121
+ * Observables keyed by their unique key.
122
+ */
123
+ interface Observables {
124
+ [k: string]: Observable;
48
125
  }
126
+ /**
127
+ * Represents a cyber observable (IP, URL, domain, hash, etc.).
128
+ *
129
+ * Observables can be linked to threat intelligence, checks, and other observables
130
+ * through relationships.
131
+ */
49
132
  interface Observable {
50
- key: string;
51
- /**
52
- * Observable type (e.g., ipv4-addr, url). Custom values are allowed.
53
- */
54
- type: string;
55
- value: string;
56
- internal: boolean;
57
- whitelisted: boolean;
58
- comment: string;
59
- extra: {
60
- [k: string]: unknown;
61
- } | null;
62
- score: number;
133
+ type: Type;
134
+ value: Value;
135
+ internal: Internal;
136
+ whitelisted: Whitelisted1;
137
+ comment: Comment;
138
+ extra: Extra;
139
+ score: Score1;
63
140
  level: Level;
64
- relationships: Relationship[];
65
- threat_intels: string[];
66
- generated_by_checks: string[];
141
+ threat_intels: ThreatIntels;
142
+ relationships: Relationships;
143
+ key: Key;
144
+ generated_by_checks: GeneratedByChecks;
145
+ [k: string]: unknown;
146
+ }
147
+ interface Extra {
148
+ [k: string]: unknown;
67
149
  }
150
+ /**
151
+ * Represents a relationship between observables.
152
+ */
68
153
  interface Relationship {
69
- target_key: string;
70
- /**
71
- * Relationship label; defaults to related-to.
72
- */
73
- relationship_type: string;
154
+ target_key: TargetKey;
155
+ relationship_type: RelationshipType;
74
156
  direction: RelationshipDirection;
157
+ [k: string]: unknown;
158
+ }
159
+ /**
160
+ * Checks organized by scope.
161
+ */
162
+ interface Checks {
163
+ [k: string]: Check[];
75
164
  }
165
+ /**
166
+ * Represents a verification step in the investigation.
167
+ *
168
+ * A check validates a specific aspect of the data under investigation
169
+ * and contributes to the overall investigation score.
170
+ */
76
171
  interface Check {
77
- key: string;
78
- check_id: string;
79
- scope: string;
80
- description: string;
81
- comment: string;
82
- extra: {
83
- [k: string]: unknown;
84
- } | null;
85
- score: number;
172
+ check_id: CheckId;
173
+ scope: Scope;
174
+ description: Description;
175
+ comment: Comment1;
176
+ extra: Extra1;
177
+ score: Score2;
86
178
  level: Level;
87
- score_policy: ScorePolicy;
88
- observables: string[];
179
+ observables: Observables1;
180
+ score_policy?: CheckScorePolicy;
181
+ key: Key1;
182
+ [k: string]: unknown;
183
+ }
184
+ interface Extra1 {
185
+ [k: string]: unknown;
186
+ }
187
+ /**
188
+ * Check keys organized by level name.
189
+ */
190
+ interface ChecksByLevel {
191
+ [k: string]: string[];
89
192
  }
193
+ /**
194
+ * Threat intelligence entries keyed by their unique key.
195
+ */
196
+ interface ThreatIntels1 {
197
+ [k: string]: ThreatIntel;
198
+ }
199
+ /**
200
+ * Represents threat intelligence from an external source.
201
+ *
202
+ * Threat intelligence provides verdicts about observables from sources
203
+ * like VirusTotal, URLScan.io, etc.
204
+ */
90
205
  interface ThreatIntel {
91
- key: string;
92
- source: string;
93
- observable_key: string;
94
- comment: string;
95
- extra: {
96
- [k: string]: unknown;
97
- } | null;
98
- score: number;
206
+ source: Source;
207
+ observable_key: ObservableKey;
208
+ comment: Comment2;
209
+ extra: Extra2;
210
+ score: Score3;
99
211
  level: Level;
100
- taxonomies: {
101
- [k: string]: unknown;
102
- }[];
212
+ taxonomies: Taxonomies;
213
+ key: Key2;
214
+ [k: string]: unknown;
215
+ }
216
+ interface Extra2 {
217
+ [k: string]: unknown;
218
+ }
219
+ /**
220
+ * Enrichment entries keyed by their unique key.
221
+ */
222
+ interface Enrichments {
223
+ [k: string]: Enrichment;
103
224
  }
225
+ /**
226
+ * Represents structured data enrichment for the investigation.
227
+ *
228
+ * Enrichments store arbitrary structured data that provides additional
229
+ * context but doesn't directly contribute to scoring.
230
+ */
104
231
  interface Enrichment {
105
- key: string;
106
- name: string;
107
- data: {
108
- [k: string]: unknown;
109
- };
110
- context: string;
232
+ name: Name1;
233
+ data: Data;
234
+ context: Context;
235
+ key: Key3;
236
+ [k: string]: unknown;
237
+ }
238
+ interface Data {
239
+ [k: string]: unknown;
240
+ }
241
+ /**
242
+ * Containers keyed by their unique key.
243
+ */
244
+ interface Containers {
245
+ [k: string]: Container;
111
246
  }
247
+ /**
248
+ * Groups checks and sub-containers for hierarchical organization.
249
+ *
250
+ * Containers allow structuring the investigation into logical sections
251
+ * with aggregated scores and levels.
252
+ */
112
253
  interface Container {
113
- key: string;
114
- path: string;
115
- description: string;
116
- checks: string[];
117
- sub_containers: {
118
- [k: string]: Container;
119
- };
120
- aggregated_score: number;
254
+ path: Path;
255
+ description?: Description1;
256
+ checks: Checks1;
257
+ sub_containers: SubContainers;
258
+ key: Key4;
259
+ aggregated_score: AggregatedScore;
121
260
  aggregated_level: Level;
122
261
  }
123
- interface Statistics {
124
- total_observables: number;
125
- internal_observables: number;
126
- external_observables: number;
127
- whitelisted_observables: number;
128
- observables_by_type: {
129
- [k: string]: number;
130
- };
131
- observables_by_level: {
132
- [k: string]: number;
133
- };
134
- observables_by_type_and_level: {
135
- [k: string]: {
136
- [k: string]: number;
137
- };
138
- };
139
- total_checks: number;
140
- applied_checks: number;
141
- checks_by_scope: {
142
- [k: string]: number;
143
- };
144
- checks_by_level: {
145
- [k: string]: number;
146
- };
147
- total_threat_intel: number;
148
- threat_intel_by_source: {
149
- [k: string]: number;
150
- };
151
- threat_intel_by_level: {
262
+ interface SubContainers {
263
+ [k: string]: Container;
264
+ }
265
+ /**
266
+ * Schema for investigation statistics.
267
+ *
268
+ * Mirrors the output of `InvestigationStats.get_summary()`.
269
+ */
270
+ interface StatisticsSchema {
271
+ total_observables: TotalObservables;
272
+ internal_observables: InternalObservables;
273
+ external_observables: ExternalObservables;
274
+ whitelisted_observables: WhitelistedObservables;
275
+ observables_by_type?: ObservablesByType;
276
+ observables_by_level?: ObservablesByLevel;
277
+ observables_by_type_and_level?: ObservablesByTypeAndLevel;
278
+ total_checks: TotalChecks;
279
+ applied_checks: AppliedChecks;
280
+ checks_by_scope?: ChecksByScope;
281
+ checks_by_level?: ChecksByLevel1;
282
+ total_threat_intel: TotalThreatIntel;
283
+ threat_intel_by_source?: ThreatIntelBySource;
284
+ threat_intel_by_level?: ThreatIntelByLevel;
285
+ total_containers: TotalContainers;
286
+ }
287
+ interface ObservablesByType {
288
+ [k: string]: number;
289
+ }
290
+ interface ObservablesByLevel {
291
+ [k: string]: number;
292
+ }
293
+ interface ObservablesByTypeAndLevel {
294
+ [k: string]: {
152
295
  [k: string]: number;
153
296
  };
154
- total_containers: number;
155
297
  }
156
- interface StatsChecks {
157
- checks: number;
158
- applied: number;
298
+ interface ChecksByScope {
299
+ [k: string]: number;
300
+ }
301
+ interface ChecksByLevel1 {
302
+ [k: string]: number;
303
+ }
304
+ interface ThreatIntelBySource {
305
+ [k: string]: number;
159
306
  }
160
- interface DataExtraction {
161
- /**
162
- * Root observable type used during data extraction.
163
- */
164
- root_type: string | null;
307
+ interface ThreatIntelByLevel {
308
+ [k: string]: number;
309
+ }
310
+ /**
311
+ * Schema for check statistics summary.
312
+ */
313
+ interface StatsChecksSchema {
314
+ checks: Checks2;
315
+ applied: Applied;
316
+ }
317
+ /**
318
+ * Schema for data extraction metadata.
319
+ */
320
+ interface DataExtractionSchema {
321
+ root_type?: RootType;
165
322
  score_mode: ScoreMode;
166
323
  }
167
324
 
@@ -647,28 +804,28 @@ declare function getAllObservables(inv: CyvestInvestigation): Observable[];
647
804
  * @param inv - The investigation
648
805
  * @returns Array of all whitelists
649
806
  */
650
- declare function getWhitelists(inv: CyvestInvestigation): Whitelist[];
807
+ declare function getWhitelists(inv: CyvestInvestigation): Whitelists;
651
808
  /**
652
809
  * Get the investigation statistics.
653
810
  *
654
811
  * @param inv - The investigation
655
812
  * @returns Statistics object
656
813
  */
657
- declare function getStats(inv: CyvestInvestigation): Statistics;
814
+ declare function getStats(inv: CyvestInvestigation): StatisticsSchema;
658
815
  /**
659
816
  * Get the investigation check statistics.
660
817
  *
661
818
  * @param inv - The investigation
662
819
  * @returns Check statistics object
663
820
  */
664
- declare function getStatsChecks(inv: CyvestInvestigation): StatsChecks;
821
+ declare function getStatsChecks(inv: CyvestInvestigation): StatsChecksSchema;
665
822
  /**
666
823
  * Get the data extraction configuration.
667
824
  *
668
825
  * @param inv - The investigation
669
826
  * @returns Data extraction config
670
827
  */
671
- declare function getDataExtraction(inv: CyvestInvestigation): DataExtraction;
828
+ declare function getDataExtraction(inv: CyvestInvestigation): DataExtractionSchema;
672
829
  /**
673
830
  * Count entities in the investigation.
674
831
  */
@@ -1207,4 +1364,4 @@ declare function getRelationshipsForObservable(inv: CyvestInvestigation, observa
1207
1364
  }>;
1208
1365
  };
1209
1366
 
1210
- export { type Check, type Container, type CyvestInvestigation, type DataExtraction, type Enrichment, type GraphEdge, type GraphNode, type InvestigationCounts, type InvestigationGraph, type KeyType, LEVEL_COLORS, LEVEL_ORDER, LEVEL_VALUES, type Level, type Observable, type Relationship, type RelationshipDirection, type ScoreMode, type ScorePolicy, type Statistics, type StatsChecks, type ThreatIntel, type Whitelist, areConnected, compareLevels, countRelationshipsByType, findChecksAtLeast, findChecksByCheckId, findChecksByLevel, findChecksByScope, findContainersAtLeast, findContainersByLevel, findExternalObservables, findInternalObservables, findLeafObservables, findManuallyScored, findObservablesAtLeast, findObservablesByLevel, findObservablesByType, findObservablesByValue, findObservablesContaining, findObservablesMatching, findObservablesWithThreatIntel, findOrphanObservables, findPath, findRootObservables, findThreatIntelAtLeast, findThreatIntelByLevel, findThreatIntelBySource, findWhitelistedObservables, generateCheckKey, generateContainerKey, generateEnrichmentKey, generateObservableKey, generateThreatIntelKey, getAllChecks, getAllContainers, getAllEnrichments, getAllObservableTypes, getAllObservables, getAllRelationshipTypes, getAllScopes, getAllThreatIntelSources, getAllThreatIntels, getCheck, getCheckByIdScope, getChecksForContainer, getChecksForObservable, getColorForLevel, getColorForScore, getContainer, getContainerByPath, getCounts, getDataExtraction, getEnrichment, getEnrichmentByName, getEntityLevel, getHighestScoringChecks, getHighestScoringObservables, getLevelFromScore, getMaliciousChecks, getMaliciousObservables, getObservable, getObservableByTypeValue, getObservableChildren, getObservableGraph, getObservableParents, getObservablesForCheck, getReachableObservables, getRelatedObservables, getRelatedObservablesByDirection, getRelatedObservablesByType, getRelationshipsForObservable, getStats, getStatsChecks, getSuspiciousChecks, getSuspiciousObservables, getThreatIntel, getThreatIntelBySourceObservable, getThreatIntelsForObservable, getWhitelists, hasLevel, isCyvest, isLevelAtLeast, isLevelHigherThan, isLevelLowerThan, isValidLevel, maxLevel, minLevel, normalizeLevel, parseCheckKey, parseCyvest, parseKeyType, parseObservableKey, parseThreatIntelKey, sortChecksByLevel, sortChecksByScore, sortObservablesByLevel, sortObservablesByScore, validateKey };
1367
+ export { type AggregatedScore, type Applied, type AppliedChecks, type Check, type CheckId, type CheckScorePolicy, type Checks, type Checks1, type Checks2, type ChecksByLevel, type ChecksByLevel1, type ChecksByScope, type Comment, type Comment1, type Comment2, type Container, type Containers, type Context, type CyvestInvestigation, type Data, type DataExtractionSchema, type Description, type Description1, type Enrichment, type Enrichments, type ExternalObservables, type Extra, type Extra1, type Extra2, type GeneratedByChecks, type GraphEdge, type GraphNode, type Identifier, type Internal, type InternalObservables, type InvestigationCounts, type InvestigationGraph, type InvestigationWhitelist, type Justification, type Key, type Key1, type Key2, type Key3, type Key4, type KeyType, LEVEL_COLORS, LEVEL_ORDER, LEVEL_VALUES, type Level, type Name, type Name1, type Observable, type ObservableKey, type Observables, type Observables1, type ObservablesByLevel, type ObservablesByType, type ObservablesByTypeAndLevel, type Path, type Relationship, type RelationshipDirection, type RelationshipType, type Relationships, type RootType, type Scope, type Score, type Score1, type Score2, type Score3, type ScoreMode, type Source, type StatisticsSchema, type StatsChecksSchema, type SubContainers, type TargetKey, type Taxonomies, type ThreatIntel, type ThreatIntelByLevel, type ThreatIntelBySource, type ThreatIntels, type ThreatIntels1, type TotalChecks, type TotalContainers, type TotalObservables, type TotalThreatIntel, type Type, type Value, type Whitelisted, type Whitelisted1, type WhitelistedObservables, type Whitelists, areConnected, compareLevels, countRelationshipsByType, findChecksAtLeast, findChecksByCheckId, findChecksByLevel, findChecksByScope, findContainersAtLeast, findContainersByLevel, findExternalObservables, findInternalObservables, findLeafObservables, findManuallyScored, findObservablesAtLeast, findObservablesByLevel, findObservablesByType, findObservablesByValue, findObservablesContaining, findObservablesMatching, findObservablesWithThreatIntel, findOrphanObservables, findPath, findRootObservables, findThreatIntelAtLeast, findThreatIntelByLevel, findThreatIntelBySource, findWhitelistedObservables, generateCheckKey, generateContainerKey, generateEnrichmentKey, generateObservableKey, generateThreatIntelKey, getAllChecks, getAllContainers, getAllEnrichments, getAllObservableTypes, getAllObservables, getAllRelationshipTypes, getAllScopes, getAllThreatIntelSources, getAllThreatIntels, getCheck, getCheckByIdScope, getChecksForContainer, getChecksForObservable, getColorForLevel, getColorForScore, getContainer, getContainerByPath, getCounts, getDataExtraction, getEnrichment, getEnrichmentByName, getEntityLevel, getHighestScoringChecks, getHighestScoringObservables, getLevelFromScore, getMaliciousChecks, getMaliciousObservables, getObservable, getObservableByTypeValue, getObservableChildren, getObservableGraph, getObservableParents, getObservablesForCheck, getReachableObservables, getRelatedObservables, getRelatedObservablesByDirection, getRelatedObservablesByType, getRelationshipsForObservable, getStats, getStatsChecks, getSuspiciousChecks, getSuspiciousObservables, getThreatIntel, getThreatIntelBySourceObservable, getThreatIntelsForObservable, getWhitelists, hasLevel, isCyvest, isLevelAtLeast, isLevelHigherThan, isLevelLowerThan, isValidLevel, maxLevel, minLevel, normalizeLevel, parseCheckKey, parseCyvest, parseKeyType, parseObservableKey, parseThreatIntelKey, sortChecksByLevel, sortChecksByScore, sortObservablesByLevel, sortObservablesByScore, validateKey };