@oneuptime/common 14.0.96 → 14.0.97

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.
Files changed (215) hide show
  1. package/Models/AnalyticsModels/NetworkFlow.d.mts +4 -0
  2. package/Models/AnalyticsModels/NetworkFlow.d.ts +4 -0
  3. package/Models/AnalyticsModels/NetworkFlow.js +50 -0
  4. package/Models/DatabaseModels/Alert.d.mts +2 -0
  5. package/Models/DatabaseModels/Alert.d.ts +2 -0
  6. package/Models/DatabaseModels/Alert.js +63 -0
  7. package/Models/DatabaseModels/Incident.d.mts +2 -0
  8. package/Models/DatabaseModels/Incident.d.ts +2 -0
  9. package/Models/DatabaseModels/Incident.js +63 -0
  10. package/Models/DatabaseModels/Index.js +10 -0
  11. package/Models/DatabaseModels/NetworkAddressName.d.mts +14 -0
  12. package/Models/DatabaseModels/NetworkAddressName.d.ts +14 -0
  13. package/Models/DatabaseModels/NetworkAddressName.js +300 -0
  14. package/Models/DatabaseModels/NetworkAddressName.mjs +2 -0
  15. package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
  16. package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
  17. package/Models/DatabaseModels/NetworkDevice.js +38 -0
  18. package/Models/DatabaseModels/SecurityCase.d.mts +8 -0
  19. package/Models/DatabaseModels/SecurityCase.d.ts +8 -0
  20. package/Models/DatabaseModels/SecurityCase.js +145 -0
  21. package/Models/DatabaseModels/SecurityCaseEvidence.d.mts +28 -0
  22. package/Models/DatabaseModels/SecurityCaseEvidence.d.ts +28 -0
  23. package/Models/DatabaseModels/SecurityCaseEvidence.js +489 -0
  24. package/Models/DatabaseModels/SecurityCaseEvidence.mjs +2 -0
  25. package/Models/DatabaseModels/SecurityCaseFeed.d.mts +4 -1
  26. package/Models/DatabaseModels/SecurityCaseFeed.d.ts +4 -1
  27. package/Models/DatabaseModels/SecurityCaseFeed.js +6 -0
  28. package/Models/DatabaseModels/SecurityCasePriority.d.mts +2 -0
  29. package/Models/DatabaseModels/SecurityCasePriority.d.ts +2 -0
  30. package/Models/DatabaseModels/SecurityCasePriority.js +44 -0
  31. package/Models/DatabaseModels/SecurityCaseTask.d.mts +22 -0
  32. package/Models/DatabaseModels/SecurityCaseTask.d.ts +22 -0
  33. package/Models/DatabaseModels/SecurityCaseTask.js +467 -0
  34. package/Models/DatabaseModels/SecurityCaseTask.mjs +2 -0
  35. package/Models/DatabaseModels/SecurityWatchlist.d.mts +22 -0
  36. package/Models/DatabaseModels/SecurityWatchlist.d.ts +22 -0
  37. package/Models/DatabaseModels/SecurityWatchlist.js +411 -0
  38. package/Models/DatabaseModels/SecurityWatchlist.mjs +2 -0
  39. package/Models/DatabaseModels/SecurityWatchlistItem.d.mts +17 -0
  40. package/Models/DatabaseModels/SecurityWatchlistItem.d.ts +17 -0
  41. package/Models/DatabaseModels/SecurityWatchlistItem.js +321 -0
  42. package/Models/DatabaseModels/SecurityWatchlistItem.mjs +2 -0
  43. package/Types/AI/AiAffectedResources.d.mts +2 -1
  44. package/Types/AI/AiAffectedResources.d.ts +2 -1
  45. package/Types/AI/AiAffectedResources.js +12 -1
  46. package/Types/AffectedResources/AffectedResourceSearch.d.mts +53 -0
  47. package/Types/AffectedResources/AffectedResourceSearch.d.ts +53 -0
  48. package/Types/AffectedResources/AffectedResourceSearch.js +224 -0
  49. package/Types/AffectedResources/AffectedResourceSearch.mjs +11 -0
  50. package/Types/ArchivableValue/ArchivableValueUsage.d.mts +21 -2
  51. package/Types/ArchivableValue/ArchivableValueUsage.d.ts +21 -2
  52. package/Types/ArchivableValue/ArchivableValueUsage.js +91 -12
  53. package/Types/ArchivableValue/ArchivableValueUsage.mjs +1 -0
  54. package/Types/Color.d.mts +0 -2
  55. package/Types/Color.d.ts +0 -2
  56. package/Types/Color.js +0 -14
  57. package/Types/Database/DatabaseProperty.d.mts +0 -2
  58. package/Types/Database/DatabaseProperty.d.ts +0 -2
  59. package/Types/Database/DatabaseProperty.js +0 -3
  60. package/Types/Date.d.mts +0 -2
  61. package/Types/Date.d.ts +0 -2
  62. package/Types/Date.js +0 -23
  63. package/Types/Domain.d.mts +0 -2
  64. package/Types/Domain.d.ts +0 -2
  65. package/Types/Domain.js +0 -14
  66. package/Types/Email/EmailTemplateType.d.mts +2 -0
  67. package/Types/Email/EmailTemplateType.d.ts +2 -0
  68. package/Types/Email/EmailTemplateType.js +2 -0
  69. package/Types/Email.d.mts +0 -2
  70. package/Types/Email.d.ts +0 -2
  71. package/Types/Email.js +0 -15
  72. package/Types/IP/IP.d.mts +0 -2
  73. package/Types/IP/IP.d.ts +0 -2
  74. package/Types/IP/IP.js +0 -14
  75. package/Types/Monitor/CriteriaAlert.d.mts +0 -2
  76. package/Types/Monitor/CriteriaAlert.d.ts +0 -2
  77. package/Types/Monitor/CriteriaAlert.js +0 -18
  78. package/Types/Monitor/CriteriaAlert.mjs +1 -2
  79. package/Types/Monitor/CriteriaFilter.d.mts +0 -2
  80. package/Types/Monitor/CriteriaFilter.d.ts +0 -2
  81. package/Types/Monitor/CriteriaFilter.js +1 -42
  82. package/Types/Monitor/CriteriaFilter.mjs +0 -1
  83. package/Types/Monitor/CriteriaIncident.d.mts +0 -2
  84. package/Types/Monitor/CriteriaIncident.d.ts +0 -2
  85. package/Types/Monitor/CriteriaIncident.js +0 -23
  86. package/Types/Monitor/CriteriaIncident.mjs +1 -2
  87. package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.d.mts +0 -2
  88. package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.d.ts +0 -2
  89. package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.js +0 -11
  90. package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.mjs +1 -2
  91. package/Types/Monitor/MonitorCriteria.d.mts +0 -2
  92. package/Types/Monitor/MonitorCriteria.d.ts +0 -2
  93. package/Types/Monitor/MonitorCriteria.js +0 -21
  94. package/Types/Monitor/MonitorCriteriaInstance.d.mts +0 -2
  95. package/Types/Monitor/MonitorCriteriaInstance.d.ts +0 -2
  96. package/Types/Monitor/MonitorCriteriaInstance.js +0 -54
  97. package/Types/Monitor/MonitorStep.d.mts +0 -2
  98. package/Types/Monitor/MonitorStep.d.ts +0 -2
  99. package/Types/Monitor/MonitorStep.js +0 -80
  100. package/Types/Monitor/MonitorSteps.d.mts +0 -2
  101. package/Types/Monitor/MonitorSteps.d.ts +0 -2
  102. package/Types/Monitor/MonitorSteps.js +0 -31
  103. package/Types/Name.d.mts +0 -2
  104. package/Types/Name.d.ts +0 -2
  105. package/Types/Name.js +0 -14
  106. package/Types/NetFlow/NetworkAddressName.d.mts +30 -0
  107. package/Types/NetFlow/NetworkAddressName.d.ts +30 -0
  108. package/Types/NetFlow/NetworkAddressName.js +149 -0
  109. package/Types/NetFlow/NetworkAddressName.mjs +6 -0
  110. package/Types/NetFlow/NetworkTraffic.d.mts +20 -0
  111. package/Types/NetFlow/NetworkTraffic.d.ts +20 -0
  112. package/Types/NetFlow/NetworkTraffic.js +5 -1
  113. package/Types/NetFlow/NetworkTraffic.mjs +2 -0
  114. package/Types/NetworkController/NetworkControllerReadSummary.d.mts +2 -0
  115. package/Types/NetworkController/NetworkControllerReadSummary.d.ts +2 -0
  116. package/Types/NetworkController/NetworkControllerReadSummary.js +7 -1
  117. package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.d.mts +47 -1
  118. package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.d.ts +47 -1
  119. package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.js +173 -8
  120. package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.mjs +7 -0
  121. package/Types/NotificationSetting/NotificationEmailRollupCategory.js +3 -0
  122. package/Types/NotificationSetting/NotificationEmailRollupPolicy.js +6 -0
  123. package/Types/NotificationSetting/NotificationSettingEventType.d.mts +2 -0
  124. package/Types/NotificationSetting/NotificationSettingEventType.d.ts +2 -0
  125. package/Types/NotificationSetting/NotificationSettingEventType.js +9 -0
  126. package/Types/ObjectID.d.mts +0 -1
  127. package/Types/ObjectID.d.ts +0 -1
  128. package/Types/ObjectID.js +0 -9
  129. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.d.mts +4 -0
  130. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.d.ts +4 -0
  131. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.js +25 -1
  132. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.mjs +4 -0
  133. package/Types/OnCallDutyPolicy/OnCallEmptyLevel.d.mts +15 -0
  134. package/Types/OnCallDutyPolicy/OnCallEmptyLevel.d.ts +15 -0
  135. package/Types/OnCallDutyPolicy/OnCallEmptyLevel.js +118 -0
  136. package/Types/OnCallDutyPolicy/OnCallEmptyLevel.mjs +9 -0
  137. package/Types/Permission.d.mts +8 -0
  138. package/Types/Permission.d.ts +8 -0
  139. package/Types/Permission.js +87 -3
  140. package/Types/Phone.d.mts +0 -2
  141. package/Types/Phone.d.ts +0 -2
  142. package/Types/Phone.js +0 -14
  143. package/Types/Port.d.mts +0 -2
  144. package/Types/Port.d.ts +0 -2
  145. package/Types/Port.js +0 -14
  146. package/Types/ProviderLogo/ProviderLogo.d.mts +8 -1
  147. package/Types/ProviderLogo/ProviderLogo.d.ts +8 -1
  148. package/Types/ProviderLogo/ProviderLogo.js +14 -0
  149. package/Types/SecurityCase/SecurityCaseEvidenceKind.d.mts +7 -0
  150. package/Types/SecurityCase/SecurityCaseEvidenceKind.d.ts +7 -0
  151. package/Types/SecurityCase/SecurityCaseEvidenceKind.js +24 -0
  152. package/Types/SecurityCase/SecurityCaseEvidenceKind.mjs +4 -0
  153. package/Types/SecurityEvent/SecurityWatchlist.d.mts +167 -0
  154. package/Types/SecurityEvent/SecurityWatchlist.d.ts +167 -0
  155. package/Types/SecurityEvent/SecurityWatchlist.js +648 -0
  156. package/Types/SecurityEvent/SecurityWatchlist.mjs +51 -0
  157. package/Types/SecurityEvent/SigmaRule.d.mts +2 -0
  158. package/Types/SecurityEvent/SigmaRule.d.ts +2 -0
  159. package/Types/SecurityEvent/SigmaRule.js +5 -0
  160. package/Types/Telemetry/OpenTelemetryGuides.js +177 -5
  161. package/Types/Version.d.mts +0 -2
  162. package/Types/Version.d.ts +0 -2
  163. package/Types/Version.js +0 -14
  164. package/Types/Workflow/AffectedResourcesSetting.d.mts +13 -0
  165. package/Types/Workflow/AffectedResourcesSetting.d.ts +13 -0
  166. package/Types/Workflow/AffectedResourcesSetting.js +120 -0
  167. package/Types/Workflow/AffectedResourcesSetting.mjs +8 -0
  168. package/Types/Workflow/Components/BaseModel.js +15 -3
  169. package/Types/Workflow/Documentation/DatabaseDocumentation.js +36 -0
  170. package/Utils/Inventory/AssetFactSource.d.mts +6 -2
  171. package/Utils/Inventory/AssetFactSource.d.ts +6 -2
  172. package/Utils/Inventory/AssetFactSource.js +18 -1
  173. package/Utils/Inventory/AssetFactSource.mjs +1 -0
  174. package/Utils/Markdown/FeedLead.d.mts +10 -0
  175. package/Utils/Markdown/FeedLead.d.ts +10 -0
  176. package/Utils/Markdown/FeedLead.js +198 -0
  177. package/Utils/Markdown/FeedLead.mjs +8 -0
  178. package/Utils/NetworkDevice/NetworkDeviceAssetFacts.d.mts +9 -1
  179. package/Utils/NetworkDevice/NetworkDeviceAssetFacts.d.ts +9 -1
  180. package/Utils/NetworkDevice/NetworkDeviceAssetFacts.js +139 -18
  181. package/Utils/NetworkDevice/NetworkDeviceAssetFacts.mjs +1 -0
  182. package/Utils/NetworkDevice/NetworkDeviceRefresh.d.mts +88 -0
  183. package/Utils/NetworkDevice/NetworkDeviceRefresh.d.ts +88 -0
  184. package/Utils/NetworkDevice/NetworkDeviceRefresh.js +232 -0
  185. package/Utils/NetworkDevice/NetworkDeviceRefresh.mjs +16 -0
  186. package/Utils/NetworkTraffic/NetworkAddressBlock.d.mts +20 -0
  187. package/Utils/NetworkTraffic/NetworkAddressBlock.d.ts +20 -0
  188. package/Utils/NetworkTraffic/NetworkAddressBlock.js +264 -0
  189. package/Utils/NetworkTraffic/NetworkAddressBlock.mjs +3 -0
  190. package/Utils/Schema/MonitorSchemas.d.mts +9 -0
  191. package/Utils/Schema/MonitorSchemas.d.ts +9 -0
  192. package/Utils/Schema/MonitorSchemas.js +291 -0
  193. package/Utils/Schema/MonitorSchemas.mjs +9 -0
  194. package/Utils/Schema/TypeSchemas.d.mts +12 -0
  195. package/Utils/Schema/TypeSchemas.d.ts +12 -0
  196. package/Utils/Schema/TypeSchemas.js +176 -0
  197. package/Utils/Schema/TypeSchemas.mjs +11 -0
  198. package/Utils/Schema/Zod.js +17 -17
  199. package/Utils/SecurityCase/SecurityCaseMarkdown.d.mts +34 -0
  200. package/Utils/SecurityCase/SecurityCaseMarkdown.d.ts +34 -0
  201. package/Utils/SecurityCase/SecurityCaseMarkdown.js +69 -0
  202. package/Utils/SecurityCase/SecurityCaseMarkdown.mjs +9 -0
  203. package/Utils/SecurityCase/SecurityCasePriorities.d.mts +2 -0
  204. package/Utils/SecurityCase/SecurityCasePriorities.d.ts +2 -0
  205. package/Utils/SecurityCase/SecurityCasePriorities.js +15 -1
  206. package/Utils/SecurityCase/SecurityCaseTargets.d.mts +128 -0
  207. package/Utils/SecurityCase/SecurityCaseTargets.d.ts +128 -0
  208. package/Utils/SecurityCase/SecurityCaseTargets.js +482 -0
  209. package/Utils/SecurityCase/SecurityCaseTargets.mjs +28 -0
  210. package/Utils/SecurityEvent/Sigma/SigmaRuleParser.js +22 -0
  211. package/Utils/SecurityEvent/Sigma/SigmaWatchlists.d.mts +24 -0
  212. package/Utils/SecurityEvent/Sigma/SigmaWatchlists.d.ts +24 -0
  213. package/Utils/SecurityEvent/Sigma/SigmaWatchlists.js +183 -0
  214. package/Utils/SecurityEvent/Sigma/SigmaWatchlists.mjs +9 -0
  215. package/package.json +1 -1
@@ -0,0 +1,24 @@
1
+ import { JSONValue } from "../../../Types/JSON.mjs";
2
+ import SigmaRule, { SigmaFieldRequirement } from "../../../Types/SecurityEvent/SigmaRule.mjs";
3
+ import { DetectionRuleDefinition } from "../../../Types/SecurityEvent/SigmaCorrelation.mjs";
4
+ import { SigmaWatchlists } from "../../../Types/SecurityEvent/SecurityWatchlist.mjs";
5
+ export interface SigmaWatchlistReference {
6
+ name: string;
7
+ key: string;
8
+ }
9
+ export declare function getSigmaRuleWatchlistReferences(rule: SigmaRule): Array<SigmaWatchlistReference>;
10
+ export declare function getDetectionRuleWatchlistReferences(definition: DetectionRuleDefinition): Array<SigmaWatchlistReference>;
11
+ export declare function readDetectionRuleWatchlistReferences(yaml: unknown): Array<SigmaWatchlistReference>;
12
+ export interface WatchlistReadingRule {
13
+ id: string;
14
+ name: string;
15
+ sigmaRuleYaml?: string | null | undefined;
16
+ }
17
+ export declare function getRulesReadingWatchlists(rules: ReadonlyArray<WatchlistReadingRule>): Map<string, Array<{
18
+ id: string;
19
+ name: string;
20
+ }>>;
21
+ export declare function getMissingSigmaWatchlists(definition: DetectionRuleDefinition, watchlists: SigmaWatchlists): Array<string>;
22
+ export declare function bindSigmaWatchlists(definition: DetectionRuleDefinition, watchlists: SigmaWatchlists): DetectionRuleDefinition;
23
+ export declare function isSigmaWatchlistRequirement(requirement: SigmaFieldRequirement): boolean;
24
+ export declare function getSigmaWatchlistKey(value: JSONValue): string | null;
@@ -0,0 +1,24 @@
1
+ import { JSONValue } from "../../../Types/JSON";
2
+ import SigmaRule, { SigmaFieldRequirement } from "../../../Types/SecurityEvent/SigmaRule";
3
+ import { DetectionRuleDefinition } from "../../../Types/SecurityEvent/SigmaCorrelation";
4
+ import { SigmaWatchlists } from "../../../Types/SecurityEvent/SecurityWatchlist";
5
+ export interface SigmaWatchlistReference {
6
+ name: string;
7
+ key: string;
8
+ }
9
+ export declare function getSigmaRuleWatchlistReferences(rule: SigmaRule): Array<SigmaWatchlistReference>;
10
+ export declare function getDetectionRuleWatchlistReferences(definition: DetectionRuleDefinition): Array<SigmaWatchlistReference>;
11
+ export declare function readDetectionRuleWatchlistReferences(yaml: unknown): Array<SigmaWatchlistReference>;
12
+ export interface WatchlistReadingRule {
13
+ id: string;
14
+ name: string;
15
+ sigmaRuleYaml?: string | null | undefined;
16
+ }
17
+ export declare function getRulesReadingWatchlists(rules: ReadonlyArray<WatchlistReadingRule>): Map<string, Array<{
18
+ id: string;
19
+ name: string;
20
+ }>>;
21
+ export declare function getMissingSigmaWatchlists(definition: DetectionRuleDefinition, watchlists: SigmaWatchlists): Array<string>;
22
+ export declare function bindSigmaWatchlists(definition: DetectionRuleDefinition, watchlists: SigmaWatchlists): DetectionRuleDefinition;
23
+ export declare function isSigmaWatchlistRequirement(requirement: SigmaFieldRequirement): boolean;
24
+ export declare function getSigmaWatchlistKey(value: JSONValue): string | null;
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getSigmaRuleWatchlistReferences = getSigmaRuleWatchlistReferences;
37
+ exports.getDetectionRuleWatchlistReferences = getDetectionRuleWatchlistReferences;
38
+ exports.readDetectionRuleWatchlistReferences = readDetectionRuleWatchlistReferences;
39
+ exports.getRulesReadingWatchlists = getRulesReadingWatchlists;
40
+ exports.getMissingSigmaWatchlists = getMissingSigmaWatchlists;
41
+ exports.bindSigmaWatchlists = bindSigmaWatchlists;
42
+ exports.isSigmaWatchlistRequirement = isSigmaWatchlistRequirement;
43
+ exports.getSigmaWatchlistKey = getSigmaWatchlistKey;
44
+ const SecurityWatchlist_1 = require("../../../Types/SecurityEvent/SecurityWatchlist");
45
+ const SigmaRuleSetParser_1 = __importStar(require("./SigmaRuleSetParser"));
46
+ function requirementsOf(rule) {
47
+ return rule.selections.flatMap((selection) => {
48
+ return selection.fieldMaps.flat();
49
+ });
50
+ }
51
+ // The watchlists one Sigma rule names, each once, in the order the rule names them.
52
+ function getSigmaRuleWatchlistReferences(rule) {
53
+ const references = [];
54
+ const seen = new Set();
55
+ for (const requirement of requirementsOf(rule)) {
56
+ if (!requirement.modifiers.includes(SecurityWatchlist_1.SECURITY_WATCHLIST_MODIFIER)) {
57
+ continue;
58
+ }
59
+ for (const value of requirement.values) {
60
+ const name = (0, SecurityWatchlist_1.readSecurityWatchlistPlaceholder)(value);
61
+ if (!name) {
62
+ continue;
63
+ }
64
+ const key = (0, SecurityWatchlist_1.getSecurityWatchlistNameKey)(name);
65
+ if (!seen.has(key)) {
66
+ seen.add(key);
67
+ references.push({ name, key });
68
+ }
69
+ }
70
+ }
71
+ return references;
72
+ }
73
+ /*
74
+ * The watchlists a detection rule's YAML names, each once: every Sigma rule
75
+ * of the file - a single rule, or a correlation's steps. A rule a
76
+ * correlation reads from the project's other detection rules names its own
77
+ * lists, in its own YAML.
78
+ */
79
+ function getDetectionRuleWatchlistReferences(definition) {
80
+ const references = [];
81
+ const seen = new Set();
82
+ for (const rule of (0, SigmaRuleSetParser_1.sigmaRulesOf)(definition)) {
83
+ for (const reference of getSigmaRuleWatchlistReferences(rule)) {
84
+ if (!seen.has(reference.key)) {
85
+ seen.add(reference.key);
86
+ references.push(reference);
87
+ }
88
+ }
89
+ }
90
+ return references;
91
+ }
92
+ /*
93
+ * The watchlists a rule's YAML names, or none when it does not parse (a rule
94
+ * being typed, or a stored rule an older version saved).
95
+ */
96
+ function readDetectionRuleWatchlistReferences(yaml) {
97
+ if (typeof yaml !== "string" || !yaml.trim()) {
98
+ return [];
99
+ }
100
+ // Cheap first: a rule that never writes the modifier reads no list.
101
+ if (!yaml.includes(`|${SecurityWatchlist_1.SECURITY_WATCHLIST_MODIFIER}`)) {
102
+ return [];
103
+ }
104
+ try {
105
+ return getDetectionRuleWatchlistReferences(SigmaRuleSetParser_1.default.parse(yaml));
106
+ }
107
+ catch (_a) {
108
+ return [];
109
+ }
110
+ }
111
+ /*
112
+ * The rules that read each watchlist, by name key, in the order given:
113
+ * what a watchlist's row says ("Read by"), and what keeps it from being
114
+ * deleted or renamed while a rule still reads it.
115
+ */
116
+ function getRulesReadingWatchlists(rules) {
117
+ const byKey = new Map();
118
+ for (const rule of rules) {
119
+ for (const reference of readDetectionRuleWatchlistReferences(rule.sigmaRuleYaml)) {
120
+ const readers = byKey.get(reference.key) || [];
121
+ readers.push({ id: rule.id, name: rule.name });
122
+ byKey.set(reference.key, readers);
123
+ }
124
+ }
125
+ return byKey;
126
+ }
127
+ /*
128
+ * The names a definition reads that are not among the lists given: what a
129
+ * save refuses, naming each.
130
+ */
131
+ function getMissingSigmaWatchlists(definition, watchlists) {
132
+ return getDetectionRuleWatchlistReferences(definition)
133
+ .filter((reference) => {
134
+ return !Object.prototype.hasOwnProperty.call(watchlists, reference.key);
135
+ })
136
+ .map((reference) => {
137
+ return reference.name;
138
+ });
139
+ }
140
+ // The lists one rule reads, out of those given: what is bound to it.
141
+ function watchlistsFor(rule, watchlists) {
142
+ const references = getSigmaRuleWatchlistReferences(rule);
143
+ if (references.length === 0) {
144
+ return undefined;
145
+ }
146
+ const bound = {};
147
+ for (const reference of references) {
148
+ if (Object.prototype.hasOwnProperty.call(watchlists, reference.key)) {
149
+ bound[reference.key] = watchlists[reference.key];
150
+ }
151
+ }
152
+ return bound;
153
+ }
154
+ function bindRule(rule, watchlists) {
155
+ const bound = watchlistsFor(rule, watchlists);
156
+ return bound ? Object.assign(Object.assign({}, rule), { watchlists: bound }) : rule;
157
+ }
158
+ /*
159
+ * The definition with each of its Sigma rules carrying the lists it names
160
+ * (SigmaRule.watchlists), for the compiler. A copy: the rules given are
161
+ * left as they were. A name missing from the lists given stays unbound, and
162
+ * compiling it fails - check getMissingSigmaWatchlists first to say which.
163
+ */
164
+ function bindSigmaWatchlists(definition, watchlists) {
165
+ if (definition.kind === "single") {
166
+ return Object.assign(Object.assign({}, definition), { rule: bindRule(definition.rule, watchlists) });
167
+ }
168
+ return Object.assign(Object.assign({}, definition), { steps: definition.steps.map((step) => {
169
+ return Object.assign(Object.assign({}, step), { rule: step.rule ? bindRule(step.rule, watchlists) : step.rule, count: step.count
170
+ ? Object.assign(Object.assign({}, step.count), { rules: step.count.rules.map((rule) => {
171
+ return bindRule(rule, watchlists);
172
+ }) }) : step.count });
173
+ }) });
174
+ }
175
+ // Whether a requirement reads watchlists: `field|expand`.
176
+ function isSigmaWatchlistRequirement(requirement) {
177
+ return requirement.modifiers.includes(SecurityWatchlist_1.SECURITY_WATCHLIST_MODIFIER);
178
+ }
179
+ // The name key a requirement's value names, or null for a value that names no list.
180
+ function getSigmaWatchlistKey(value) {
181
+ const name = (0, SecurityWatchlist_1.readSecurityWatchlistPlaceholder)(value);
182
+ return name ? (0, SecurityWatchlist_1.getSecurityWatchlistNameKey)(name) : null;
183
+ }
@@ -0,0 +1,9 @@
1
+ import commonJsModule from "./SigmaWatchlists.js";
2
+ export const bindSigmaWatchlists = commonJsModule.bindSigmaWatchlists;
3
+ export const getDetectionRuleWatchlistReferences = commonJsModule.getDetectionRuleWatchlistReferences;
4
+ export const getMissingSigmaWatchlists = commonJsModule.getMissingSigmaWatchlists;
5
+ export const getRulesReadingWatchlists = commonJsModule.getRulesReadingWatchlists;
6
+ export const getSigmaRuleWatchlistReferences = commonJsModule.getSigmaRuleWatchlistReferences;
7
+ export const getSigmaWatchlistKey = commonJsModule.getSigmaWatchlistKey;
8
+ export const isSigmaWatchlistRequirement = commonJsModule.isSigmaWatchlistRequirement;
9
+ export const readDetectionRuleWatchlistReferences = commonJsModule.readDetectionRuleWatchlistReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneuptime/common",
3
- "version": "14.0.96",
3
+ "version": "14.0.97",
4
4
  "description": "OneUptime's shared types, utilities and data models, for Node.js and TypeScript.",
5
5
  "homepage": "https://oneuptime.com",
6
6
  "repository": {