@cyvest/cyvest-js 4.3.0 → 4.4.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.
@@ -1,6 +1,140 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ LEVEL_COLORS: () => LEVEL_COLORS,
34
+ LEVEL_ORDER: () => LEVEL_ORDER,
35
+ LEVEL_VALUES: () => LEVEL_VALUES,
36
+ areConnected: () => areConnected,
37
+ compareLevels: () => compareLevels,
38
+ countRelationshipsByType: () => countRelationshipsByType,
39
+ findChecksAtLeast: () => findChecksAtLeast,
40
+ findChecksByCheckId: () => findChecksByCheckId,
41
+ findChecksByLevel: () => findChecksByLevel,
42
+ findChecksByScope: () => findChecksByScope,
43
+ findContainersAtLeast: () => findContainersAtLeast,
44
+ findContainersByLevel: () => findContainersByLevel,
45
+ findExternalObservables: () => findExternalObservables,
46
+ findInternalObservables: () => findInternalObservables,
47
+ findLeafObservables: () => findLeafObservables,
48
+ findObservablesAtLeast: () => findObservablesAtLeast,
49
+ findObservablesByLevel: () => findObservablesByLevel,
50
+ findObservablesByType: () => findObservablesByType,
51
+ findObservablesByValue: () => findObservablesByValue,
52
+ findObservablesContaining: () => findObservablesContaining,
53
+ findObservablesMatching: () => findObservablesMatching,
54
+ findObservablesWithThreatIntel: () => findObservablesWithThreatIntel,
55
+ findOrphanObservables: () => findOrphanObservables,
56
+ findPath: () => findPath,
57
+ findRootObservables: () => findRootObservables,
58
+ findThreatIntelAtLeast: () => findThreatIntelAtLeast,
59
+ findThreatIntelByLevel: () => findThreatIntelByLevel,
60
+ findThreatIntelBySource: () => findThreatIntelBySource,
61
+ findWhitelistedObservables: () => findWhitelistedObservables,
62
+ generateCheckKey: () => generateCheckKey,
63
+ generateContainerKey: () => generateContainerKey,
64
+ generateEnrichmentKey: () => generateEnrichmentKey,
65
+ generateObservableKey: () => generateObservableKey,
66
+ generateThreatIntelKey: () => generateThreatIntelKey,
67
+ getAllChecks: () => getAllChecks,
68
+ getAllContainers: () => getAllContainers,
69
+ getAllEnrichments: () => getAllEnrichments,
70
+ getAllObservableTypes: () => getAllObservableTypes,
71
+ getAllObservables: () => getAllObservables,
72
+ getAllRelationshipTypes: () => getAllRelationshipTypes,
73
+ getAllScopes: () => getAllScopes,
74
+ getAllThreatIntelSources: () => getAllThreatIntelSources,
75
+ getAllThreatIntels: () => getAllThreatIntels,
76
+ getCheck: () => getCheck,
77
+ getCheckByIdScope: () => getCheckByIdScope,
78
+ getChecksForContainer: () => getChecksForContainer,
79
+ getChecksForObservable: () => getChecksForObservable,
80
+ getColorForLevel: () => getColorForLevel,
81
+ getColorForScore: () => getColorForScore,
82
+ getContainer: () => getContainer,
83
+ getContainerByPath: () => getContainerByPath,
84
+ getCounts: () => getCounts,
85
+ getDataExtraction: () => getDataExtraction,
86
+ getEnrichment: () => getEnrichment,
87
+ getEnrichmentByName: () => getEnrichmentByName,
88
+ getEntityLevel: () => getEntityLevel,
89
+ getHighestScoringChecks: () => getHighestScoringChecks,
90
+ getHighestScoringObservables: () => getHighestScoringObservables,
91
+ getLevelFromScore: () => getLevelFromScore,
92
+ getMaliciousChecks: () => getMaliciousChecks,
93
+ getMaliciousObservables: () => getMaliciousObservables,
94
+ getObservable: () => getObservable,
95
+ getObservableByTypeValue: () => getObservableByTypeValue,
96
+ getObservableChildren: () => getObservableChildren,
97
+ getObservableGraph: () => getObservableGraph,
98
+ getObservableParents: () => getObservableParents,
99
+ getObservablesForCheck: () => getObservablesForCheck,
100
+ getReachableObservables: () => getReachableObservables,
101
+ getRelatedObservables: () => getRelatedObservables,
102
+ getRelatedObservablesByDirection: () => getRelatedObservablesByDirection,
103
+ getRelatedObservablesByType: () => getRelatedObservablesByType,
104
+ getRelationshipsForObservable: () => getRelationshipsForObservable,
105
+ getStartedAt: () => getStartedAt,
106
+ getStats: () => getStats,
107
+ getSuspiciousChecks: () => getSuspiciousChecks,
108
+ getSuspiciousObservables: () => getSuspiciousObservables,
109
+ getThreatIntel: () => getThreatIntel,
110
+ getThreatIntelBySourceObservable: () => getThreatIntelBySourceObservable,
111
+ getThreatIntelsForObservable: () => getThreatIntelsForObservable,
112
+ getWhitelists: () => getWhitelists,
113
+ hasLevel: () => hasLevel,
114
+ isCyvest: () => isCyvest,
115
+ isLevelAtLeast: () => isLevelAtLeast,
116
+ isLevelHigherThan: () => isLevelHigherThan,
117
+ isLevelLowerThan: () => isLevelLowerThan,
118
+ isValidLevel: () => isValidLevel,
119
+ maxLevel: () => maxLevel,
120
+ minLevel: () => minLevel,
121
+ normalizeLevel: () => normalizeLevel,
122
+ parseCheckKey: () => parseCheckKey,
123
+ parseCyvest: () => parseCyvest,
124
+ parseKeyType: () => parseKeyType,
125
+ parseObservableKey: () => parseObservableKey,
126
+ parseThreatIntelKey: () => parseThreatIntelKey,
127
+ sortChecksByLevel: () => sortChecksByLevel,
128
+ sortChecksByScore: () => sortChecksByScore,
129
+ sortObservablesByLevel: () => sortObservablesByLevel,
130
+ sortObservablesByScore: () => sortObservablesByScore,
131
+ validateKey: () => validateKey
132
+ });
133
+ module.exports = __toCommonJS(index_exports);
134
+
1
135
  // src/helpers.ts
2
- import Ajv2020 from "ajv/dist/2020";
3
- import addFormats from "ajv-formats";
136
+ var import__ = __toESM(require("ajv/dist/2020"), 1);
137
+ var import_ajv_formats = __toESM(require("ajv-formats"), 1);
4
138
 
5
139
  // ../../../schema/cyvest.schema.json
6
140
  var cyvest_schema_default = {
@@ -707,12 +841,6 @@ var cyvest_schema_default = {
707
841
  description: "Optional human-readable investigation name.",
708
842
  title: "Investigation Name"
709
843
  },
710
- started_at: {
711
- description: "Investigation start time (UTC).",
712
- format: "date-time",
713
- title: "Started At",
714
- type: "string"
715
- },
716
844
  score: {
717
845
  description: "Global investigation score.",
718
846
  title: "Score",
@@ -735,13 +863,20 @@ var cyvest_schema_default = {
735
863
  title: "Whitelists",
736
864
  type: "array"
737
865
  },
738
- event_log: {
739
- description: "Append-only investigation audit log.",
740
- items: {
741
- $ref: "#/$defs/AuditEvent"
742
- },
743
- title: "Event Log",
744
- type: "array"
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"
745
880
  },
746
881
  observables: {
747
882
  additionalProperties: {
@@ -803,7 +938,6 @@ var cyvest_schema_default = {
803
938
  },
804
939
  required: [
805
940
  "investigation_id",
806
- "started_at",
807
941
  "score",
808
942
  "level",
809
943
  "whitelisted",
@@ -822,8 +956,8 @@ var cyvest_schema_default = {
822
956
  };
823
957
 
824
958
  // src/helpers.ts
825
- var ajv = new Ajv2020({ allErrors: true });
826
- addFormats(ajv);
959
+ var ajv = new import__.default({ allErrors: true });
960
+ (0, import_ajv_formats.default)(ajv);
827
961
  var validateFn = null;
828
962
  function getValidator() {
829
963
  if (!validateFn) {
@@ -1199,6 +1333,12 @@ function getCounts(inv) {
1199
1333
  whitelists: inv.whitelists.length
1200
1334
  };
1201
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
+ }
1202
1342
 
1203
1343
  // src/finders.ts
1204
1344
  function findObservablesByType(inv, type) {
@@ -1735,7 +1875,8 @@ function getRelationshipsForObservable(inv, observableKey) {
1735
1875
  ]
1736
1876
  };
1737
1877
  }
1738
- export {
1878
+ // Annotate the CommonJS export names for ESM import in node:
1879
+ 0 && (module.exports = {
1739
1880
  LEVEL_COLORS,
1740
1881
  LEVEL_ORDER,
1741
1882
  LEVEL_VALUES,
@@ -1808,6 +1949,7 @@ export {
1808
1949
  getRelatedObservablesByDirection,
1809
1950
  getRelatedObservablesByType,
1810
1951
  getRelationshipsForObservable,
1952
+ getStartedAt,
1811
1953
  getStats,
1812
1954
  getSuspiciousChecks,
1813
1955
  getSuspiciousObservables,
@@ -1834,4 +1976,4 @@ export {
1834
1976
  sortObservablesByLevel,
1835
1977
  sortObservablesByScore,
1836
1978
  validateKey
1837
- };
1979
+ });
@@ -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,7 +73,7 @@ interface CyvestInvestigation {
77
73
  */
78
74
  whitelisted: boolean;
79
75
  whitelists: Whitelists;
80
- event_log?: EventLog;
76
+ audit_log?: AuditLog;
81
77
  observables: Observables;
82
78
  checks: Checks;
83
79
  threat_intels: ThreatIntels1;
@@ -842,6 +838,23 @@ interface InvestigationCounts {
842
838
  * @returns Object with counts for each entity type
843
839
  */
844
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;
845
858
 
846
859
  /**
847
860
  * Finder utilities for querying and filtering Cyvest Investigation data.
@@ -1355,4 +1368,4 @@ declare function getRelationshipsForObservable(inv: CyvestInvestigation, observa
1355
1368
  }>;
1356
1369
  };
1357
1370
 
1358
- export { type Actor, type AuditEvent, 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 EventLog, 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, 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 };
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,7 +73,7 @@ interface CyvestInvestigation {
77
73
  */
78
74
  whitelisted: boolean;
79
75
  whitelists: Whitelists;
80
- event_log?: EventLog;
76
+ audit_log?: AuditLog;
81
77
  observables: Observables;
82
78
  checks: Checks;
83
79
  threat_intels: ThreatIntels1;
@@ -842,6 +838,23 @@ interface InvestigationCounts {
842
838
  * @returns Object with counts for each entity type
843
839
  */
844
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;
845
858
 
846
859
  /**
847
860
  * Finder utilities for querying and filtering Cyvest Investigation data.
@@ -1355,4 +1368,4 @@ declare function getRelationshipsForObservable(inv: CyvestInvestigation, observa
1355
1368
  }>;
1356
1369
  };
1357
1370
 
1358
- export { type Actor, type AuditEvent, 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 EventLog, 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, 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 };
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
@@ -1,139 +1,6 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- LEVEL_COLORS: () => LEVEL_COLORS,
34
- LEVEL_ORDER: () => LEVEL_ORDER,
35
- LEVEL_VALUES: () => LEVEL_VALUES,
36
- areConnected: () => areConnected,
37
- compareLevels: () => compareLevels,
38
- countRelationshipsByType: () => countRelationshipsByType,
39
- findChecksAtLeast: () => findChecksAtLeast,
40
- findChecksByCheckId: () => findChecksByCheckId,
41
- findChecksByLevel: () => findChecksByLevel,
42
- findChecksByScope: () => findChecksByScope,
43
- findContainersAtLeast: () => findContainersAtLeast,
44
- findContainersByLevel: () => findContainersByLevel,
45
- findExternalObservables: () => findExternalObservables,
46
- findInternalObservables: () => findInternalObservables,
47
- findLeafObservables: () => findLeafObservables,
48
- findObservablesAtLeast: () => findObservablesAtLeast,
49
- findObservablesByLevel: () => findObservablesByLevel,
50
- findObservablesByType: () => findObservablesByType,
51
- findObservablesByValue: () => findObservablesByValue,
52
- findObservablesContaining: () => findObservablesContaining,
53
- findObservablesMatching: () => findObservablesMatching,
54
- findObservablesWithThreatIntel: () => findObservablesWithThreatIntel,
55
- findOrphanObservables: () => findOrphanObservables,
56
- findPath: () => findPath,
57
- findRootObservables: () => findRootObservables,
58
- findThreatIntelAtLeast: () => findThreatIntelAtLeast,
59
- findThreatIntelByLevel: () => findThreatIntelByLevel,
60
- findThreatIntelBySource: () => findThreatIntelBySource,
61
- findWhitelistedObservables: () => findWhitelistedObservables,
62
- generateCheckKey: () => generateCheckKey,
63
- generateContainerKey: () => generateContainerKey,
64
- generateEnrichmentKey: () => generateEnrichmentKey,
65
- generateObservableKey: () => generateObservableKey,
66
- generateThreatIntelKey: () => generateThreatIntelKey,
67
- getAllChecks: () => getAllChecks,
68
- getAllContainers: () => getAllContainers,
69
- getAllEnrichments: () => getAllEnrichments,
70
- getAllObservableTypes: () => getAllObservableTypes,
71
- getAllObservables: () => getAllObservables,
72
- getAllRelationshipTypes: () => getAllRelationshipTypes,
73
- getAllScopes: () => getAllScopes,
74
- getAllThreatIntelSources: () => getAllThreatIntelSources,
75
- getAllThreatIntels: () => getAllThreatIntels,
76
- getCheck: () => getCheck,
77
- getCheckByIdScope: () => getCheckByIdScope,
78
- getChecksForContainer: () => getChecksForContainer,
79
- getChecksForObservable: () => getChecksForObservable,
80
- getColorForLevel: () => getColorForLevel,
81
- getColorForScore: () => getColorForScore,
82
- getContainer: () => getContainer,
83
- getContainerByPath: () => getContainerByPath,
84
- getCounts: () => getCounts,
85
- getDataExtraction: () => getDataExtraction,
86
- getEnrichment: () => getEnrichment,
87
- getEnrichmentByName: () => getEnrichmentByName,
88
- getEntityLevel: () => getEntityLevel,
89
- getHighestScoringChecks: () => getHighestScoringChecks,
90
- getHighestScoringObservables: () => getHighestScoringObservables,
91
- getLevelFromScore: () => getLevelFromScore,
92
- getMaliciousChecks: () => getMaliciousChecks,
93
- getMaliciousObservables: () => getMaliciousObservables,
94
- getObservable: () => getObservable,
95
- getObservableByTypeValue: () => getObservableByTypeValue,
96
- getObservableChildren: () => getObservableChildren,
97
- getObservableGraph: () => getObservableGraph,
98
- getObservableParents: () => getObservableParents,
99
- getObservablesForCheck: () => getObservablesForCheck,
100
- getReachableObservables: () => getReachableObservables,
101
- getRelatedObservables: () => getRelatedObservables,
102
- getRelatedObservablesByDirection: () => getRelatedObservablesByDirection,
103
- getRelatedObservablesByType: () => getRelatedObservablesByType,
104
- getRelationshipsForObservable: () => getRelationshipsForObservable,
105
- getStats: () => getStats,
106
- getSuspiciousChecks: () => getSuspiciousChecks,
107
- getSuspiciousObservables: () => getSuspiciousObservables,
108
- getThreatIntel: () => getThreatIntel,
109
- getThreatIntelBySourceObservable: () => getThreatIntelBySourceObservable,
110
- getThreatIntelsForObservable: () => getThreatIntelsForObservable,
111
- getWhitelists: () => getWhitelists,
112
- hasLevel: () => hasLevel,
113
- isCyvest: () => isCyvest,
114
- isLevelAtLeast: () => isLevelAtLeast,
115
- isLevelHigherThan: () => isLevelHigherThan,
116
- isLevelLowerThan: () => isLevelLowerThan,
117
- isValidLevel: () => isValidLevel,
118
- maxLevel: () => maxLevel,
119
- minLevel: () => minLevel,
120
- normalizeLevel: () => normalizeLevel,
121
- parseCheckKey: () => parseCheckKey,
122
- parseCyvest: () => parseCyvest,
123
- parseKeyType: () => parseKeyType,
124
- parseObservableKey: () => parseObservableKey,
125
- parseThreatIntelKey: () => parseThreatIntelKey,
126
- sortChecksByLevel: () => sortChecksByLevel,
127
- sortChecksByScore: () => sortChecksByScore,
128
- sortObservablesByLevel: () => sortObservablesByLevel,
129
- sortObservablesByScore: () => sortObservablesByScore,
130
- validateKey: () => validateKey
131
- });
132
- module.exports = __toCommonJS(index_exports);
133
-
134
1
  // src/helpers.ts
135
- var import__ = __toESM(require("ajv/dist/2020"));
136
- var import_ajv_formats = __toESM(require("ajv-formats"));
2
+ import Ajv2020 from "ajv/dist/2020";
3
+ import addFormats from "ajv-formats";
137
4
 
138
5
  // ../../../schema/cyvest.schema.json
139
6
  var cyvest_schema_default = {
@@ -840,12 +707,6 @@ var cyvest_schema_default = {
840
707
  description: "Optional human-readable investigation name.",
841
708
  title: "Investigation Name"
842
709
  },
843
- started_at: {
844
- description: "Investigation start time (UTC).",
845
- format: "date-time",
846
- title: "Started At",
847
- type: "string"
848
- },
849
710
  score: {
850
711
  description: "Global investigation score.",
851
712
  title: "Score",
@@ -868,13 +729,20 @@ var cyvest_schema_default = {
868
729
  title: "Whitelists",
869
730
  type: "array"
870
731
  },
871
- event_log: {
872
- description: "Append-only investigation audit log.",
873
- items: {
874
- $ref: "#/$defs/AuditEvent"
875
- },
876
- title: "Event Log",
877
- type: "array"
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"
878
746
  },
879
747
  observables: {
880
748
  additionalProperties: {
@@ -936,7 +804,6 @@ var cyvest_schema_default = {
936
804
  },
937
805
  required: [
938
806
  "investigation_id",
939
- "started_at",
940
807
  "score",
941
808
  "level",
942
809
  "whitelisted",
@@ -955,8 +822,8 @@ var cyvest_schema_default = {
955
822
  };
956
823
 
957
824
  // src/helpers.ts
958
- var ajv = new import__.default({ allErrors: true });
959
- (0, import_ajv_formats.default)(ajv);
825
+ var ajv = new Ajv2020({ allErrors: true });
826
+ addFormats(ajv);
960
827
  var validateFn = null;
961
828
  function getValidator() {
962
829
  if (!validateFn) {
@@ -1332,6 +1199,12 @@ function getCounts(inv) {
1332
1199
  whitelists: inv.whitelists.length
1333
1200
  };
1334
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
+ }
1335
1208
 
1336
1209
  // src/finders.ts
1337
1210
  function findObservablesByType(inv, type) {
@@ -1868,8 +1741,7 @@ function getRelationshipsForObservable(inv, observableKey) {
1868
1741
  ]
1869
1742
  };
1870
1743
  }
1871
- // Annotate the CommonJS export names for ESM import in node:
1872
- 0 && (module.exports = {
1744
+ export {
1873
1745
  LEVEL_COLORS,
1874
1746
  LEVEL_ORDER,
1875
1747
  LEVEL_VALUES,
@@ -1942,6 +1814,7 @@ function getRelationshipsForObservable(inv, observableKey) {
1942
1814
  getRelatedObservablesByDirection,
1943
1815
  getRelatedObservablesByType,
1944
1816
  getRelationshipsForObservable,
1817
+ getStartedAt,
1945
1818
  getStats,
1946
1819
  getSuspiciousChecks,
1947
1820
  getSuspiciousObservables,
@@ -1968,4 +1841,4 @@ function getRelationshipsForObservable(inv, observableKey) {
1968
1841
  sortObservablesByLevel,
1969
1842
  sortObservablesByScore,
1970
1843
  validateKey
1971
- });
1844
+ };
package/package.json CHANGED
@@ -1,9 +1,22 @@
1
1
  {
2
2
  "name": "@cyvest/cyvest-js",
3
- "version": "4.3.0",
3
+ "version": "4.4.1",
4
+ "type": "module",
4
5
  "main": "dist/index.cjs",
5
- "module": "dist/index.mjs",
6
+ "module": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.cts",
16
+ "default": "./dist/index.cjs"
17
+ }
18
+ }
19
+ },
7
20
  "sideEffects": false,
8
21
  "dependencies": {
9
22
  "ajv": "^8.17.1",
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
+ }
@@ -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,7 +76,7 @@ export interface CyvestInvestigation {
80
76
  */
81
77
  whitelisted: boolean;
82
78
  whitelists: Whitelists;
83
- event_log?: EventLog;
79
+ audit_log?: AuditLog;
84
80
  observables: Observables;
85
81
  checks: Checks;
86
82
  threat_intels: ThreatIntels1;
@@ -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",
@@ -340,6 +349,25 @@ describe("Getters", () => {
340
349
  expect(counts.whitelists).toBe(1);
341
350
  });
342
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
+ });
343
371
  });
344
372
 
345
373
  describe("Finders", () => {
@@ -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": {