@cyvest/cyvest-js 4.2.0 → 4.4.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/index.d.mts +27 -21
- package/dist/index.d.ts +27 -21
- package/dist/index.js +30 -30
- package/dist/index.mjs +29 -30
- package/package.json +1 -1
- package/src/getters.ts +23 -0
- package/src/types.generated.ts +9 -20
- package/tests/getters-finders.test.ts +31 -7
- package/tests/graph.test.ts +9 -2
package/dist/index.d.mts
CHANGED
|
@@ -13,15 +13,15 @@ type Justification = string | null;
|
|
|
13
13
|
* List of whitelist entries applied to this investigation.
|
|
14
14
|
*/
|
|
15
15
|
type Whitelists = InvestigationWhitelist[];
|
|
16
|
+
/**
|
|
17
|
+
* Append-only investigation audit log. Null when serialization disabled audit.
|
|
18
|
+
*/
|
|
19
|
+
type AuditLog = AuditEvent[] | null;
|
|
16
20
|
type Actor = string | null;
|
|
17
21
|
type Reason = string | null;
|
|
18
22
|
type Tool = string | null;
|
|
19
23
|
type ObjectType = string | null;
|
|
20
24
|
type ObjectKey = string | null;
|
|
21
|
-
/**
|
|
22
|
-
* Append-only investigation audit log.
|
|
23
|
-
*/
|
|
24
|
-
type EventLog = AuditEvent[];
|
|
25
25
|
type ThreatIntels = string[];
|
|
26
26
|
/**
|
|
27
27
|
* Direction of a relationship between observables.
|
|
@@ -63,10 +63,6 @@ interface CyvestInvestigation {
|
|
|
63
63
|
*/
|
|
64
64
|
investigation_id: string;
|
|
65
65
|
investigation_name?: InvestigationName;
|
|
66
|
-
/**
|
|
67
|
-
* Investigation start time (UTC).
|
|
68
|
-
*/
|
|
69
|
-
started_at: string;
|
|
70
66
|
/**
|
|
71
67
|
* Global investigation score.
|
|
72
68
|
*/
|
|
@@ -77,10 +73,9 @@ interface CyvestInvestigation {
|
|
|
77
73
|
*/
|
|
78
74
|
whitelisted: boolean;
|
|
79
75
|
whitelists: Whitelists;
|
|
80
|
-
|
|
76
|
+
audit_log?: AuditLog;
|
|
81
77
|
observables: Observables;
|
|
82
78
|
checks: Checks;
|
|
83
|
-
checks_by_level: ChecksByLevel;
|
|
84
79
|
threat_intels: ThreatIntels1;
|
|
85
80
|
enrichments: Enrichments;
|
|
86
81
|
containers: Containers;
|
|
@@ -194,12 +189,6 @@ interface ObservableLink {
|
|
|
194
189
|
observable_key: string;
|
|
195
190
|
propagation_mode?: PropagationMode;
|
|
196
191
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Check keys organized by level name.
|
|
199
|
-
*/
|
|
200
|
-
interface ChecksByLevel {
|
|
201
|
-
[k: string]: string[];
|
|
202
|
-
}
|
|
203
192
|
/**
|
|
204
193
|
* Threat intelligence entries keyed by their unique key.
|
|
205
194
|
*/
|
|
@@ -297,7 +286,7 @@ interface StatisticsSchema {
|
|
|
297
286
|
total_checks: number;
|
|
298
287
|
applied_checks: number;
|
|
299
288
|
checks_by_scope?: ChecksByScope;
|
|
300
|
-
checks_by_level?:
|
|
289
|
+
checks_by_level?: ChecksByLevel;
|
|
301
290
|
total_threat_intel: number;
|
|
302
291
|
threat_intel_by_source?: ThreatIntelBySource;
|
|
303
292
|
threat_intel_by_level?: ThreatIntelByLevel;
|
|
@@ -315,10 +304,10 @@ interface ObservablesByTypeAndLevel {
|
|
|
315
304
|
};
|
|
316
305
|
}
|
|
317
306
|
interface ChecksByScope {
|
|
318
|
-
[k: string]:
|
|
307
|
+
[k: string]: string[];
|
|
319
308
|
}
|
|
320
|
-
interface
|
|
321
|
-
[k: string]:
|
|
309
|
+
interface ChecksByLevel {
|
|
310
|
+
[k: string]: string[];
|
|
322
311
|
}
|
|
323
312
|
interface ThreatIntelBySource {
|
|
324
313
|
[k: string]: number;
|
|
@@ -849,6 +838,23 @@ interface InvestigationCounts {
|
|
|
849
838
|
* @returns Object with counts for each entity type
|
|
850
839
|
*/
|
|
851
840
|
declare function getCounts(inv: CyvestInvestigation): InvestigationCounts;
|
|
841
|
+
/**
|
|
842
|
+
* Get the investigation start time from the event log.
|
|
843
|
+
*
|
|
844
|
+
* Looks for the INVESTIGATION_STARTED event and returns its timestamp.
|
|
845
|
+
*
|
|
846
|
+
* @param inv - The investigation
|
|
847
|
+
* @returns The start timestamp string or undefined if not found
|
|
848
|
+
*
|
|
849
|
+
* @example
|
|
850
|
+
* ```ts
|
|
851
|
+
* const startedAt = getStartedAt(investigation);
|
|
852
|
+
* if (startedAt) {
|
|
853
|
+
* console.log(`Started: ${startedAt}`);
|
|
854
|
+
* }
|
|
855
|
+
* ```
|
|
856
|
+
*/
|
|
857
|
+
declare function getStartedAt(inv: CyvestInvestigation): string | undefined;
|
|
852
858
|
|
|
853
859
|
/**
|
|
854
860
|
* Finder utilities for querying and filtering Cyvest Investigation data.
|
|
@@ -1362,4 +1368,4 @@ declare function getRelationshipsForObservable(inv: CyvestInvestigation, observa
|
|
|
1362
1368
|
}>;
|
|
1363
1369
|
};
|
|
1364
1370
|
|
|
1365
|
-
export { type Actor, type AuditEvent, type Check, type CheckLinks, type Checks, type Checks1, type ChecksByLevel, type
|
|
1371
|
+
export { type Actor, type AuditEvent, type AuditLog, type Check, type CheckLinks, type Checks, type Checks1, type ChecksByLevel, type ChecksByScope, type Container, type Containers, type CyvestInvestigation, type Data, type DataExtractionSchema, type Details, type Enrichment, type Enrichments, type Extra, type Extra1, type Extra2, type GraphEdge, type GraphNode, type InvestigationCounts, type InvestigationGraph, type InvestigationName, type InvestigationWhitelist, type Justification, type KeyType, LEVEL_COLORS, LEVEL_ORDER, LEVEL_VALUES, type Level, type ObjectKey, type ObjectType, type Observable, type ObservableLink, type ObservableLinks, type Observables, type ObservablesByLevel, type ObservablesByType, type ObservablesByTypeAndLevel, type PropagationMode, type Reason, type Relationship, type RelationshipDirection, type Relationships, type RootType, type ScoreMode, type StatisticsSchema, type SubContainers, type Taxonomies, type Taxonomy, type ThreatIntel, type ThreatIntelByLevel, type ThreatIntelBySource, type ThreatIntels, type ThreatIntels1, type Tool, type Whitelists, areConnected, compareLevels, countRelationshipsByType, findChecksAtLeast, findChecksByCheckId, findChecksByLevel, findChecksByScope, findContainersAtLeast, findContainersByLevel, findExternalObservables, findInternalObservables, findLeafObservables, 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, getStartedAt, getStats, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,15 +13,15 @@ type Justification = string | null;
|
|
|
13
13
|
* List of whitelist entries applied to this investigation.
|
|
14
14
|
*/
|
|
15
15
|
type Whitelists = InvestigationWhitelist[];
|
|
16
|
+
/**
|
|
17
|
+
* Append-only investigation audit log. Null when serialization disabled audit.
|
|
18
|
+
*/
|
|
19
|
+
type AuditLog = AuditEvent[] | null;
|
|
16
20
|
type Actor = string | null;
|
|
17
21
|
type Reason = string | null;
|
|
18
22
|
type Tool = string | null;
|
|
19
23
|
type ObjectType = string | null;
|
|
20
24
|
type ObjectKey = string | null;
|
|
21
|
-
/**
|
|
22
|
-
* Append-only investigation audit log.
|
|
23
|
-
*/
|
|
24
|
-
type EventLog = AuditEvent[];
|
|
25
25
|
type ThreatIntels = string[];
|
|
26
26
|
/**
|
|
27
27
|
* Direction of a relationship between observables.
|
|
@@ -63,10 +63,6 @@ interface CyvestInvestigation {
|
|
|
63
63
|
*/
|
|
64
64
|
investigation_id: string;
|
|
65
65
|
investigation_name?: InvestigationName;
|
|
66
|
-
/**
|
|
67
|
-
* Investigation start time (UTC).
|
|
68
|
-
*/
|
|
69
|
-
started_at: string;
|
|
70
66
|
/**
|
|
71
67
|
* Global investigation score.
|
|
72
68
|
*/
|
|
@@ -77,10 +73,9 @@ interface CyvestInvestigation {
|
|
|
77
73
|
*/
|
|
78
74
|
whitelisted: boolean;
|
|
79
75
|
whitelists: Whitelists;
|
|
80
|
-
|
|
76
|
+
audit_log?: AuditLog;
|
|
81
77
|
observables: Observables;
|
|
82
78
|
checks: Checks;
|
|
83
|
-
checks_by_level: ChecksByLevel;
|
|
84
79
|
threat_intels: ThreatIntels1;
|
|
85
80
|
enrichments: Enrichments;
|
|
86
81
|
containers: Containers;
|
|
@@ -194,12 +189,6 @@ interface ObservableLink {
|
|
|
194
189
|
observable_key: string;
|
|
195
190
|
propagation_mode?: PropagationMode;
|
|
196
191
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Check keys organized by level name.
|
|
199
|
-
*/
|
|
200
|
-
interface ChecksByLevel {
|
|
201
|
-
[k: string]: string[];
|
|
202
|
-
}
|
|
203
192
|
/**
|
|
204
193
|
* Threat intelligence entries keyed by their unique key.
|
|
205
194
|
*/
|
|
@@ -297,7 +286,7 @@ interface StatisticsSchema {
|
|
|
297
286
|
total_checks: number;
|
|
298
287
|
applied_checks: number;
|
|
299
288
|
checks_by_scope?: ChecksByScope;
|
|
300
|
-
checks_by_level?:
|
|
289
|
+
checks_by_level?: ChecksByLevel;
|
|
301
290
|
total_threat_intel: number;
|
|
302
291
|
threat_intel_by_source?: ThreatIntelBySource;
|
|
303
292
|
threat_intel_by_level?: ThreatIntelByLevel;
|
|
@@ -315,10 +304,10 @@ interface ObservablesByTypeAndLevel {
|
|
|
315
304
|
};
|
|
316
305
|
}
|
|
317
306
|
interface ChecksByScope {
|
|
318
|
-
[k: string]:
|
|
307
|
+
[k: string]: string[];
|
|
319
308
|
}
|
|
320
|
-
interface
|
|
321
|
-
[k: string]:
|
|
309
|
+
interface ChecksByLevel {
|
|
310
|
+
[k: string]: string[];
|
|
322
311
|
}
|
|
323
312
|
interface ThreatIntelBySource {
|
|
324
313
|
[k: string]: number;
|
|
@@ -849,6 +838,23 @@ interface InvestigationCounts {
|
|
|
849
838
|
* @returns Object with counts for each entity type
|
|
850
839
|
*/
|
|
851
840
|
declare function getCounts(inv: CyvestInvestigation): InvestigationCounts;
|
|
841
|
+
/**
|
|
842
|
+
* Get the investigation start time from the event log.
|
|
843
|
+
*
|
|
844
|
+
* Looks for the INVESTIGATION_STARTED event and returns its timestamp.
|
|
845
|
+
*
|
|
846
|
+
* @param inv - The investigation
|
|
847
|
+
* @returns The start timestamp string or undefined if not found
|
|
848
|
+
*
|
|
849
|
+
* @example
|
|
850
|
+
* ```ts
|
|
851
|
+
* const startedAt = getStartedAt(investigation);
|
|
852
|
+
* if (startedAt) {
|
|
853
|
+
* console.log(`Started: ${startedAt}`);
|
|
854
|
+
* }
|
|
855
|
+
* ```
|
|
856
|
+
*/
|
|
857
|
+
declare function getStartedAt(inv: CyvestInvestigation): string | undefined;
|
|
852
858
|
|
|
853
859
|
/**
|
|
854
860
|
* Finder utilities for querying and filtering Cyvest Investigation data.
|
|
@@ -1362,4 +1368,4 @@ declare function getRelationshipsForObservable(inv: CyvestInvestigation, observa
|
|
|
1362
1368
|
}>;
|
|
1363
1369
|
};
|
|
1364
1370
|
|
|
1365
|
-
export { type Actor, type AuditEvent, type Check, type CheckLinks, type Checks, type Checks1, type ChecksByLevel, type
|
|
1371
|
+
export { type Actor, type AuditEvent, type AuditLog, type Check, type CheckLinks, type Checks, type Checks1, type ChecksByLevel, type ChecksByScope, type Container, type Containers, type CyvestInvestigation, type Data, type DataExtractionSchema, type Details, type Enrichment, type Enrichments, type Extra, type Extra1, type Extra2, type GraphEdge, type GraphNode, type InvestigationCounts, type InvestigationGraph, type InvestigationName, type InvestigationWhitelist, type Justification, type KeyType, LEVEL_COLORS, LEVEL_ORDER, LEVEL_VALUES, type Level, type ObjectKey, type ObjectType, type Observable, type ObservableLink, type ObservableLinks, type Observables, type ObservablesByLevel, type ObservablesByType, type ObservablesByTypeAndLevel, type PropagationMode, type Reason, type Relationship, type RelationshipDirection, type Relationships, type RootType, type ScoreMode, type StatisticsSchema, type SubContainers, type Taxonomies, type Taxonomy, type ThreatIntel, type ThreatIntelByLevel, type ThreatIntelBySource, type ThreatIntels, type ThreatIntels1, type Tool, type Whitelists, areConnected, compareLevels, countRelationshipsByType, findChecksAtLeast, findChecksByCheckId, findChecksByLevel, findChecksByScope, findContainersAtLeast, findContainersByLevel, findExternalObservables, findInternalObservables, findLeafObservables, 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, getStartedAt, getStats, 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 };
|
package/dist/index.js
CHANGED
|
@@ -102,6 +102,7 @@ __export(index_exports, {
|
|
|
102
102
|
getRelatedObservablesByDirection: () => getRelatedObservablesByDirection,
|
|
103
103
|
getRelatedObservablesByType: () => getRelatedObservablesByType,
|
|
104
104
|
getRelationshipsForObservable: () => getRelationshipsForObservable,
|
|
105
|
+
getStartedAt: () => getStartedAt,
|
|
105
106
|
getStats: () => getStats,
|
|
106
107
|
getSuspiciousChecks: () => getSuspiciousChecks,
|
|
107
108
|
getSuspiciousObservables: () => getSuspiciousObservables,
|
|
@@ -676,16 +677,20 @@ var cyvest_schema_default = {
|
|
|
676
677
|
},
|
|
677
678
|
checks_by_scope: {
|
|
678
679
|
additionalProperties: {
|
|
679
|
-
|
|
680
|
-
|
|
680
|
+
items: {
|
|
681
|
+
type: "string"
|
|
682
|
+
},
|
|
683
|
+
type: "array"
|
|
681
684
|
},
|
|
682
685
|
title: "Checks By Scope",
|
|
683
686
|
type: "object"
|
|
684
687
|
},
|
|
685
688
|
checks_by_level: {
|
|
686
689
|
additionalProperties: {
|
|
687
|
-
|
|
688
|
-
|
|
690
|
+
items: {
|
|
691
|
+
type: "string"
|
|
692
|
+
},
|
|
693
|
+
type: "array"
|
|
689
694
|
},
|
|
690
695
|
title: "Checks By Level",
|
|
691
696
|
type: "object"
|
|
@@ -836,12 +841,6 @@ var cyvest_schema_default = {
|
|
|
836
841
|
description: "Optional human-readable investigation name.",
|
|
837
842
|
title: "Investigation Name"
|
|
838
843
|
},
|
|
839
|
-
started_at: {
|
|
840
|
-
description: "Investigation start time (UTC).",
|
|
841
|
-
format: "date-time",
|
|
842
|
-
title: "Started At",
|
|
843
|
-
type: "string"
|
|
844
|
-
},
|
|
845
844
|
score: {
|
|
846
845
|
description: "Global investigation score.",
|
|
847
846
|
title: "Score",
|
|
@@ -864,13 +863,20 @@ var cyvest_schema_default = {
|
|
|
864
863
|
title: "Whitelists",
|
|
865
864
|
type: "array"
|
|
866
865
|
},
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
866
|
+
audit_log: {
|
|
867
|
+
anyOf: [
|
|
868
|
+
{
|
|
869
|
+
items: {
|
|
870
|
+
$ref: "#/$defs/AuditEvent"
|
|
871
|
+
},
|
|
872
|
+
type: "array"
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
type: "null"
|
|
876
|
+
}
|
|
877
|
+
],
|
|
878
|
+
description: "Append-only investigation audit log. Null when serialization disabled audit.",
|
|
879
|
+
title: "Audit Log"
|
|
874
880
|
},
|
|
875
881
|
observables: {
|
|
876
882
|
additionalProperties: {
|
|
@@ -891,17 +897,6 @@ var cyvest_schema_default = {
|
|
|
891
897
|
title: "Checks",
|
|
892
898
|
type: "object"
|
|
893
899
|
},
|
|
894
|
-
checks_by_level: {
|
|
895
|
-
additionalProperties: {
|
|
896
|
-
items: {
|
|
897
|
-
type: "string"
|
|
898
|
-
},
|
|
899
|
-
type: "array"
|
|
900
|
-
},
|
|
901
|
-
description: "Check keys organized by level name.",
|
|
902
|
-
title: "Checks By Level",
|
|
903
|
-
type: "object"
|
|
904
|
-
},
|
|
905
900
|
threat_intels: {
|
|
906
901
|
additionalProperties: {
|
|
907
902
|
$ref: "#/$defs/ThreatIntel"
|
|
@@ -943,14 +938,12 @@ var cyvest_schema_default = {
|
|
|
943
938
|
},
|
|
944
939
|
required: [
|
|
945
940
|
"investigation_id",
|
|
946
|
-
"started_at",
|
|
947
941
|
"score",
|
|
948
942
|
"level",
|
|
949
943
|
"whitelisted",
|
|
950
944
|
"whitelists",
|
|
951
945
|
"observables",
|
|
952
946
|
"checks",
|
|
953
|
-
"checks_by_level",
|
|
954
947
|
"threat_intels",
|
|
955
948
|
"enrichments",
|
|
956
949
|
"containers",
|
|
@@ -1340,6 +1333,12 @@ function getCounts(inv) {
|
|
|
1340
1333
|
whitelists: inv.whitelists.length
|
|
1341
1334
|
};
|
|
1342
1335
|
}
|
|
1336
|
+
function getStartedAt(inv) {
|
|
1337
|
+
const event = inv.audit_log?.find(
|
|
1338
|
+
(e) => e.event_type === "INVESTIGATION_STARTED"
|
|
1339
|
+
);
|
|
1340
|
+
return event?.timestamp;
|
|
1341
|
+
}
|
|
1343
1342
|
|
|
1344
1343
|
// src/finders.ts
|
|
1345
1344
|
function findObservablesByType(inv, type) {
|
|
@@ -1950,6 +1949,7 @@ function getRelationshipsForObservable(inv, observableKey) {
|
|
|
1950
1949
|
getRelatedObservablesByDirection,
|
|
1951
1950
|
getRelatedObservablesByType,
|
|
1952
1951
|
getRelationshipsForObservable,
|
|
1952
|
+
getStartedAt,
|
|
1953
1953
|
getStats,
|
|
1954
1954
|
getSuspiciousChecks,
|
|
1955
1955
|
getSuspiciousObservables,
|
package/dist/index.mjs
CHANGED
|
@@ -543,16 +543,20 @@ var cyvest_schema_default = {
|
|
|
543
543
|
},
|
|
544
544
|
checks_by_scope: {
|
|
545
545
|
additionalProperties: {
|
|
546
|
-
|
|
547
|
-
|
|
546
|
+
items: {
|
|
547
|
+
type: "string"
|
|
548
|
+
},
|
|
549
|
+
type: "array"
|
|
548
550
|
},
|
|
549
551
|
title: "Checks By Scope",
|
|
550
552
|
type: "object"
|
|
551
553
|
},
|
|
552
554
|
checks_by_level: {
|
|
553
555
|
additionalProperties: {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
+
items: {
|
|
557
|
+
type: "string"
|
|
558
|
+
},
|
|
559
|
+
type: "array"
|
|
556
560
|
},
|
|
557
561
|
title: "Checks By Level",
|
|
558
562
|
type: "object"
|
|
@@ -703,12 +707,6 @@ var cyvest_schema_default = {
|
|
|
703
707
|
description: "Optional human-readable investigation name.",
|
|
704
708
|
title: "Investigation Name"
|
|
705
709
|
},
|
|
706
|
-
started_at: {
|
|
707
|
-
description: "Investigation start time (UTC).",
|
|
708
|
-
format: "date-time",
|
|
709
|
-
title: "Started At",
|
|
710
|
-
type: "string"
|
|
711
|
-
},
|
|
712
710
|
score: {
|
|
713
711
|
description: "Global investigation score.",
|
|
714
712
|
title: "Score",
|
|
@@ -731,13 +729,20 @@ var cyvest_schema_default = {
|
|
|
731
729
|
title: "Whitelists",
|
|
732
730
|
type: "array"
|
|
733
731
|
},
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
732
|
+
audit_log: {
|
|
733
|
+
anyOf: [
|
|
734
|
+
{
|
|
735
|
+
items: {
|
|
736
|
+
$ref: "#/$defs/AuditEvent"
|
|
737
|
+
},
|
|
738
|
+
type: "array"
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
type: "null"
|
|
742
|
+
}
|
|
743
|
+
],
|
|
744
|
+
description: "Append-only investigation audit log. Null when serialization disabled audit.",
|
|
745
|
+
title: "Audit Log"
|
|
741
746
|
},
|
|
742
747
|
observables: {
|
|
743
748
|
additionalProperties: {
|
|
@@ -758,17 +763,6 @@ var cyvest_schema_default = {
|
|
|
758
763
|
title: "Checks",
|
|
759
764
|
type: "object"
|
|
760
765
|
},
|
|
761
|
-
checks_by_level: {
|
|
762
|
-
additionalProperties: {
|
|
763
|
-
items: {
|
|
764
|
-
type: "string"
|
|
765
|
-
},
|
|
766
|
-
type: "array"
|
|
767
|
-
},
|
|
768
|
-
description: "Check keys organized by level name.",
|
|
769
|
-
title: "Checks By Level",
|
|
770
|
-
type: "object"
|
|
771
|
-
},
|
|
772
766
|
threat_intels: {
|
|
773
767
|
additionalProperties: {
|
|
774
768
|
$ref: "#/$defs/ThreatIntel"
|
|
@@ -810,14 +804,12 @@ var cyvest_schema_default = {
|
|
|
810
804
|
},
|
|
811
805
|
required: [
|
|
812
806
|
"investigation_id",
|
|
813
|
-
"started_at",
|
|
814
807
|
"score",
|
|
815
808
|
"level",
|
|
816
809
|
"whitelisted",
|
|
817
810
|
"whitelists",
|
|
818
811
|
"observables",
|
|
819
812
|
"checks",
|
|
820
|
-
"checks_by_level",
|
|
821
813
|
"threat_intels",
|
|
822
814
|
"enrichments",
|
|
823
815
|
"containers",
|
|
@@ -1207,6 +1199,12 @@ function getCounts(inv) {
|
|
|
1207
1199
|
whitelists: inv.whitelists.length
|
|
1208
1200
|
};
|
|
1209
1201
|
}
|
|
1202
|
+
function getStartedAt(inv) {
|
|
1203
|
+
const event = inv.audit_log?.find(
|
|
1204
|
+
(e) => e.event_type === "INVESTIGATION_STARTED"
|
|
1205
|
+
);
|
|
1206
|
+
return event?.timestamp;
|
|
1207
|
+
}
|
|
1210
1208
|
|
|
1211
1209
|
// src/finders.ts
|
|
1212
1210
|
function findObservablesByType(inv, type) {
|
|
@@ -1816,6 +1814,7 @@ export {
|
|
|
1816
1814
|
getRelatedObservablesByDirection,
|
|
1817
1815
|
getRelatedObservablesByType,
|
|
1818
1816
|
getRelationshipsForObservable,
|
|
1817
|
+
getStartedAt,
|
|
1819
1818
|
getStats,
|
|
1820
1819
|
getSuspiciousChecks,
|
|
1821
1820
|
getSuspiciousObservables,
|
package/package.json
CHANGED
package/src/getters.ts
CHANGED
|
@@ -397,3 +397,26 @@ export function getCounts(inv: CyvestInvestigation): InvestigationCounts {
|
|
|
397
397
|
whitelists: inv.whitelists.length,
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Get the investigation start time from the event log.
|
|
403
|
+
*
|
|
404
|
+
* Looks for the INVESTIGATION_STARTED event and returns its timestamp.
|
|
405
|
+
*
|
|
406
|
+
* @param inv - The investigation
|
|
407
|
+
* @returns The start timestamp string or undefined if not found
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```ts
|
|
411
|
+
* const startedAt = getStartedAt(investigation);
|
|
412
|
+
* if (startedAt) {
|
|
413
|
+
* console.log(`Started: ${startedAt}`);
|
|
414
|
+
* }
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
export function getStartedAt(inv: CyvestInvestigation): string | undefined {
|
|
418
|
+
const event = inv.audit_log?.find(
|
|
419
|
+
(e) => e.event_type === "INVESTIGATION_STARTED"
|
|
420
|
+
);
|
|
421
|
+
return event?.timestamp;
|
|
422
|
+
}
|
package/src/types.generated.ts
CHANGED
|
@@ -15,15 +15,15 @@ export type Justification = string | null;
|
|
|
15
15
|
* List of whitelist entries applied to this investigation.
|
|
16
16
|
*/
|
|
17
17
|
export type Whitelists = InvestigationWhitelist[];
|
|
18
|
+
/**
|
|
19
|
+
* Append-only investigation audit log. Null when serialization disabled audit.
|
|
20
|
+
*/
|
|
21
|
+
export type AuditLog = AuditEvent[] | null;
|
|
18
22
|
export type Actor = string | null;
|
|
19
23
|
export type Reason = string | null;
|
|
20
24
|
export type Tool = string | null;
|
|
21
25
|
export type ObjectType = string | null;
|
|
22
26
|
export type ObjectKey = string | null;
|
|
23
|
-
/**
|
|
24
|
-
* Append-only investigation audit log.
|
|
25
|
-
*/
|
|
26
|
-
export type EventLog = AuditEvent[];
|
|
27
27
|
export type ThreatIntels = string[];
|
|
28
28
|
/**
|
|
29
29
|
* Direction of a relationship between observables.
|
|
@@ -66,10 +66,6 @@ export interface CyvestInvestigation {
|
|
|
66
66
|
*/
|
|
67
67
|
investigation_id: string;
|
|
68
68
|
investigation_name?: InvestigationName;
|
|
69
|
-
/**
|
|
70
|
-
* Investigation start time (UTC).
|
|
71
|
-
*/
|
|
72
|
-
started_at: string;
|
|
73
69
|
/**
|
|
74
70
|
* Global investigation score.
|
|
75
71
|
*/
|
|
@@ -80,10 +76,9 @@ export interface CyvestInvestigation {
|
|
|
80
76
|
*/
|
|
81
77
|
whitelisted: boolean;
|
|
82
78
|
whitelists: Whitelists;
|
|
83
|
-
|
|
79
|
+
audit_log?: AuditLog;
|
|
84
80
|
observables: Observables;
|
|
85
81
|
checks: Checks;
|
|
86
|
-
checks_by_level: ChecksByLevel;
|
|
87
82
|
threat_intels: ThreatIntels1;
|
|
88
83
|
enrichments: Enrichments;
|
|
89
84
|
containers: Containers;
|
|
@@ -197,12 +192,6 @@ export interface ObservableLink {
|
|
|
197
192
|
observable_key: string;
|
|
198
193
|
propagation_mode?: PropagationMode;
|
|
199
194
|
}
|
|
200
|
-
/**
|
|
201
|
-
* Check keys organized by level name.
|
|
202
|
-
*/
|
|
203
|
-
export interface ChecksByLevel {
|
|
204
|
-
[k: string]: string[];
|
|
205
|
-
}
|
|
206
195
|
/**
|
|
207
196
|
* Threat intelligence entries keyed by their unique key.
|
|
208
197
|
*/
|
|
@@ -300,7 +289,7 @@ export interface StatisticsSchema {
|
|
|
300
289
|
total_checks: number;
|
|
301
290
|
applied_checks: number;
|
|
302
291
|
checks_by_scope?: ChecksByScope;
|
|
303
|
-
checks_by_level?:
|
|
292
|
+
checks_by_level?: ChecksByLevel;
|
|
304
293
|
total_threat_intel: number;
|
|
305
294
|
threat_intel_by_source?: ThreatIntelBySource;
|
|
306
295
|
threat_intel_by_level?: ThreatIntelByLevel;
|
|
@@ -318,10 +307,10 @@ export interface ObservablesByTypeAndLevel {
|
|
|
318
307
|
};
|
|
319
308
|
}
|
|
320
309
|
export interface ChecksByScope {
|
|
321
|
-
[k: string]:
|
|
310
|
+
[k: string]: string[];
|
|
322
311
|
}
|
|
323
|
-
export interface
|
|
324
|
-
[k: string]:
|
|
312
|
+
export interface ChecksByLevel {
|
|
313
|
+
[k: string]: string[];
|
|
325
314
|
}
|
|
326
315
|
export interface ThreatIntelBySource {
|
|
327
316
|
[k: string]: number;
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
getAllContainers,
|
|
19
19
|
getAllObservables,
|
|
20
20
|
getCounts,
|
|
21
|
+
getStartedAt,
|
|
21
22
|
// Finders
|
|
22
23
|
findObservablesByType,
|
|
23
24
|
findObservablesByLevel,
|
|
@@ -43,11 +44,19 @@ function createTestInvestigation(): CyvestInvestigation {
|
|
|
43
44
|
return {
|
|
44
45
|
investigation_id: "01HXYZTESTINVESTIGATION",
|
|
45
46
|
investigation_name: "Test Investigation",
|
|
46
|
-
started_at: "2024-01-01T00:00:00Z",
|
|
47
47
|
score: 7.5,
|
|
48
48
|
score_display: "7.50",
|
|
49
49
|
level: "MALICIOUS",
|
|
50
50
|
whitelisted: false,
|
|
51
|
+
audit_log: [
|
|
52
|
+
{
|
|
53
|
+
event_id: "01HXYZTESTEVENT001",
|
|
54
|
+
timestamp: "2024-01-01T00:00:00Z",
|
|
55
|
+
event_type: "INVESTIGATION_STARTED",
|
|
56
|
+
object_type: "investigation",
|
|
57
|
+
object_key: "01HXYZTESTINVESTIGATION",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
51
60
|
whitelists: [
|
|
52
61
|
{
|
|
53
62
|
identifier: "wl-1",
|
|
@@ -176,10 +185,6 @@ function createTestInvestigation(): CyvestInvestigation {
|
|
|
176
185
|
},
|
|
177
186
|
],
|
|
178
187
|
},
|
|
179
|
-
checks_by_level: {
|
|
180
|
-
INFO: ["chk:ip_check:network", "chk:dns_lookup:dns"],
|
|
181
|
-
MALICIOUS: ["chk:domain_check:dns"],
|
|
182
|
-
},
|
|
183
188
|
threat_intels: {
|
|
184
189
|
"ti:virustotal:obs:domain-name:example.com": {
|
|
185
190
|
key: "ti:virustotal:obs:domain-name:example.com",
|
|
@@ -232,8 +237,8 @@ function createTestInvestigation(): CyvestInvestigation {
|
|
|
232
237
|
observables_by_type_and_level: {},
|
|
233
238
|
total_checks: 3,
|
|
234
239
|
applied_checks: 2,
|
|
235
|
-
checks_by_scope: { network:
|
|
236
|
-
checks_by_level: { INFO:
|
|
240
|
+
checks_by_scope: { network: ["chk:ip_check:network"], dns: ["chk:domain_check:dns", "chk:dns_lookup:dns"] },
|
|
241
|
+
checks_by_level: { INFO: ["chk:ip_check:network", "chk:dns_lookup:dns"], MALICIOUS: ["chk:domain_check:dns"] },
|
|
237
242
|
total_threat_intel: 1,
|
|
238
243
|
threat_intel_by_source: { virustotal: 1 },
|
|
239
244
|
threat_intel_by_level: { MALICIOUS: 1 },
|
|
@@ -344,6 +349,25 @@ describe("Getters", () => {
|
|
|
344
349
|
expect(counts.whitelists).toBe(1);
|
|
345
350
|
});
|
|
346
351
|
});
|
|
352
|
+
|
|
353
|
+
describe("getStartedAt", () => {
|
|
354
|
+
it("returns timestamp from INVESTIGATION_STARTED event", () => {
|
|
355
|
+
const startedAt = getStartedAt(inv);
|
|
356
|
+
expect(startedAt).toBe("2024-01-01T00:00:00Z");
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it("returns undefined when no audit_log", () => {
|
|
360
|
+
const invWithoutAuditLog = { ...inv, audit_log: undefined };
|
|
361
|
+
const startedAt = getStartedAt(invWithoutAuditLog);
|
|
362
|
+
expect(startedAt).toBeUndefined();
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it("returns undefined when no INVESTIGATION_STARTED event", () => {
|
|
366
|
+
const invWithEmptyLog = { ...inv, audit_log: [] };
|
|
367
|
+
const startedAt = getStartedAt(invWithEmptyLog);
|
|
368
|
+
expect(startedAt).toBeUndefined();
|
|
369
|
+
});
|
|
370
|
+
});
|
|
347
371
|
});
|
|
348
372
|
|
|
349
373
|
describe("Finders", () => {
|
package/tests/graph.test.ts
CHANGED
|
@@ -22,11 +22,19 @@ function createGraphTestInvestigation(): CyvestInvestigation {
|
|
|
22
22
|
return {
|
|
23
23
|
investigation_id: "01HXYZGRAPHINVESTIGATION",
|
|
24
24
|
investigation_name: "Graph Test Investigation",
|
|
25
|
-
started_at: "2024-01-01T00:00:00Z",
|
|
26
25
|
score: 5,
|
|
27
26
|
score_display: "5.00",
|
|
28
27
|
level: "MALICIOUS",
|
|
29
28
|
whitelisted: false,
|
|
29
|
+
audit_log: [
|
|
30
|
+
{
|
|
31
|
+
event_id: "01HXYZTESTEVENT001",
|
|
32
|
+
timestamp: "2024-01-01T00:00:00Z",
|
|
33
|
+
event_type: "INVESTIGATION_STARTED",
|
|
34
|
+
object_type: "investigation",
|
|
35
|
+
object_key: "01HXYZGRAPHINVESTIGATION",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
30
38
|
whitelists: [],
|
|
31
39
|
observables: {
|
|
32
40
|
"obs:email-message:msg1": {
|
|
@@ -123,7 +131,6 @@ function createGraphTestInvestigation(): CyvestInvestigation {
|
|
|
123
131
|
},
|
|
124
132
|
},
|
|
125
133
|
checks: {},
|
|
126
|
-
checks_by_level: {},
|
|
127
134
|
threat_intels: {},
|
|
128
135
|
enrichments: {},
|
|
129
136
|
containers: {},
|