@oneuptime/common 14.0.96 → 14.0.98

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 (271) 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/CodeRepository.d.mts +3 -0
  8. package/Models/DatabaseModels/CodeRepository.d.ts +3 -0
  9. package/Models/DatabaseModels/CodeRepository.js +104 -0
  10. package/Models/DatabaseModels/Incident.d.mts +2 -0
  11. package/Models/DatabaseModels/Incident.d.ts +2 -0
  12. package/Models/DatabaseModels/Incident.js +63 -0
  13. package/Models/DatabaseModels/Index.js +12 -0
  14. package/Models/DatabaseModels/NetworkAddressName.d.mts +14 -0
  15. package/Models/DatabaseModels/NetworkAddressName.d.ts +14 -0
  16. package/Models/DatabaseModels/NetworkAddressName.js +300 -0
  17. package/Models/DatabaseModels/NetworkAddressName.mjs +2 -0
  18. package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
  19. package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
  20. package/Models/DatabaseModels/NetworkDevice.js +38 -0
  21. package/Models/DatabaseModels/SecurityCase.d.mts +8 -0
  22. package/Models/DatabaseModels/SecurityCase.d.ts +8 -0
  23. package/Models/DatabaseModels/SecurityCase.js +145 -0
  24. package/Models/DatabaseModels/SecurityCaseEvidence.d.mts +32 -0
  25. package/Models/DatabaseModels/SecurityCaseEvidence.d.ts +32 -0
  26. package/Models/DatabaseModels/SecurityCaseEvidence.js +548 -0
  27. package/Models/DatabaseModels/SecurityCaseEvidence.mjs +2 -0
  28. package/Models/DatabaseModels/SecurityCaseFeed.d.mts +4 -1
  29. package/Models/DatabaseModels/SecurityCaseFeed.d.ts +4 -1
  30. package/Models/DatabaseModels/SecurityCaseFeed.js +6 -0
  31. package/Models/DatabaseModels/SecurityCasePriority.d.mts +2 -0
  32. package/Models/DatabaseModels/SecurityCasePriority.d.ts +2 -0
  33. package/Models/DatabaseModels/SecurityCasePriority.js +44 -0
  34. package/Models/DatabaseModels/SecurityCaseTask.d.mts +22 -0
  35. package/Models/DatabaseModels/SecurityCaseTask.d.ts +22 -0
  36. package/Models/DatabaseModels/SecurityCaseTask.js +467 -0
  37. package/Models/DatabaseModels/SecurityCaseTask.mjs +2 -0
  38. package/Models/DatabaseModels/SecurityHunt.d.mts +34 -0
  39. package/Models/DatabaseModels/SecurityHunt.d.ts +34 -0
  40. package/Models/DatabaseModels/SecurityHunt.js +608 -0
  41. package/Models/DatabaseModels/SecurityHunt.mjs +2 -0
  42. package/Models/DatabaseModels/SecurityWatchlist.d.mts +22 -0
  43. package/Models/DatabaseModels/SecurityWatchlist.d.ts +22 -0
  44. package/Models/DatabaseModels/SecurityWatchlist.js +411 -0
  45. package/Models/DatabaseModels/SecurityWatchlist.mjs +2 -0
  46. package/Models/DatabaseModels/SecurityWatchlistItem.d.mts +17 -0
  47. package/Models/DatabaseModels/SecurityWatchlistItem.d.ts +17 -0
  48. package/Models/DatabaseModels/SecurityWatchlistItem.js +321 -0
  49. package/Models/DatabaseModels/SecurityWatchlistItem.mjs +2 -0
  50. package/Types/AI/AIChatTypes.d.mts +1 -0
  51. package/Types/AI/AIChatTypes.d.ts +1 -0
  52. package/Types/AI/AIRunEventType.d.mts +1 -0
  53. package/Types/AI/AIRunEventType.d.ts +1 -0
  54. package/Types/AI/AIRunEventType.js +8 -0
  55. package/Types/AI/AiAffectedResources.d.mts +2 -1
  56. package/Types/AI/AiAffectedResources.d.ts +2 -1
  57. package/Types/AI/AiAffectedResources.js +12 -1
  58. package/Types/AI/AiTokenCount.d.mts +22 -1
  59. package/Types/AI/AiTokenCount.d.ts +22 -1
  60. package/Types/AI/AiTokenCount.js +126 -57
  61. package/Types/AI/AiTokenCount.mjs +2 -0
  62. package/Types/AI/CodeFixTaskContext.d.mts +1 -0
  63. package/Types/AI/CodeFixTaskContext.d.ts +1 -0
  64. package/Types/AffectedResources/AffectedResourceSearch.d.mts +53 -0
  65. package/Types/AffectedResources/AffectedResourceSearch.d.ts +53 -0
  66. package/Types/AffectedResources/AffectedResourceSearch.js +224 -0
  67. package/Types/AffectedResources/AffectedResourceSearch.mjs +11 -0
  68. package/Types/ArchivableValue/ArchivableValueUsage.d.mts +21 -2
  69. package/Types/ArchivableValue/ArchivableValueUsage.d.ts +21 -2
  70. package/Types/ArchivableValue/ArchivableValueUsage.js +91 -12
  71. package/Types/ArchivableValue/ArchivableValueUsage.mjs +1 -0
  72. package/Types/CodeRepository/CodeRepositorySetting.d.mts +1 -0
  73. package/Types/CodeRepository/CodeRepositorySetting.d.ts +1 -0
  74. package/Types/CodeRepository/CodeRepositorySetting.js +2 -0
  75. package/Types/Color.d.mts +0 -2
  76. package/Types/Color.d.ts +0 -2
  77. package/Types/Color.js +0 -14
  78. package/Types/Database/DatabaseProperty.d.mts +0 -2
  79. package/Types/Database/DatabaseProperty.d.ts +0 -2
  80. package/Types/Database/DatabaseProperty.js +0 -3
  81. package/Types/Date.d.mts +0 -2
  82. package/Types/Date.d.ts +0 -2
  83. package/Types/Date.js +0 -23
  84. package/Types/Domain.d.mts +0 -2
  85. package/Types/Domain.d.ts +0 -2
  86. package/Types/Domain.js +0 -14
  87. package/Types/Email/EmailTemplateType.d.mts +3 -0
  88. package/Types/Email/EmailTemplateType.d.ts +3 -0
  89. package/Types/Email/EmailTemplateType.js +4 -0
  90. package/Types/Email.d.mts +0 -2
  91. package/Types/Email.d.ts +0 -2
  92. package/Types/Email.js +0 -15
  93. package/Types/IP/IP.d.mts +0 -2
  94. package/Types/IP/IP.d.ts +0 -2
  95. package/Types/IP/IP.js +0 -14
  96. package/Types/Link.d.mts +1 -0
  97. package/Types/Link.d.ts +1 -0
  98. package/Types/Monitor/CriteriaAlert.d.mts +0 -2
  99. package/Types/Monitor/CriteriaAlert.d.ts +0 -2
  100. package/Types/Monitor/CriteriaAlert.js +0 -18
  101. package/Types/Monitor/CriteriaAlert.mjs +1 -2
  102. package/Types/Monitor/CriteriaFilter.d.mts +0 -2
  103. package/Types/Monitor/CriteriaFilter.d.ts +0 -2
  104. package/Types/Monitor/CriteriaFilter.js +1 -42
  105. package/Types/Monitor/CriteriaFilter.mjs +0 -1
  106. package/Types/Monitor/CriteriaIncident.d.mts +0 -2
  107. package/Types/Monitor/CriteriaIncident.d.ts +0 -2
  108. package/Types/Monitor/CriteriaIncident.js +0 -23
  109. package/Types/Monitor/CriteriaIncident.mjs +1 -2
  110. package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.d.mts +0 -2
  111. package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.d.ts +0 -2
  112. package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.js +0 -11
  113. package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.mjs +1 -2
  114. package/Types/Monitor/MonitorCriteria.d.mts +0 -2
  115. package/Types/Monitor/MonitorCriteria.d.ts +0 -2
  116. package/Types/Monitor/MonitorCriteria.js +0 -21
  117. package/Types/Monitor/MonitorCriteriaInstance.d.mts +0 -2
  118. package/Types/Monitor/MonitorCriteriaInstance.d.ts +0 -2
  119. package/Types/Monitor/MonitorCriteriaInstance.js +0 -54
  120. package/Types/Monitor/MonitorStep.d.mts +0 -2
  121. package/Types/Monitor/MonitorStep.d.ts +0 -2
  122. package/Types/Monitor/MonitorStep.js +0 -80
  123. package/Types/Monitor/MonitorSteps.d.mts +0 -2
  124. package/Types/Monitor/MonitorSteps.d.ts +0 -2
  125. package/Types/Monitor/MonitorSteps.js +0 -31
  126. package/Types/Name.d.mts +0 -2
  127. package/Types/Name.d.ts +0 -2
  128. package/Types/Name.js +0 -14
  129. package/Types/NetFlow/NetworkAddressName.d.mts +30 -0
  130. package/Types/NetFlow/NetworkAddressName.d.ts +30 -0
  131. package/Types/NetFlow/NetworkAddressName.js +149 -0
  132. package/Types/NetFlow/NetworkAddressName.mjs +6 -0
  133. package/Types/NetFlow/NetworkTraffic.d.mts +20 -0
  134. package/Types/NetFlow/NetworkTraffic.d.ts +20 -0
  135. package/Types/NetFlow/NetworkTraffic.js +5 -1
  136. package/Types/NetFlow/NetworkTraffic.mjs +2 -0
  137. package/Types/NetworkController/NetworkControllerReadSummary.d.mts +2 -0
  138. package/Types/NetworkController/NetworkControllerReadSummary.d.ts +2 -0
  139. package/Types/NetworkController/NetworkControllerReadSummary.js +7 -1
  140. package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.d.mts +47 -1
  141. package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.d.ts +47 -1
  142. package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.js +173 -8
  143. package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.mjs +7 -0
  144. package/Types/NotificationSetting/NotificationEmailRollupCategory.d.mts +1 -0
  145. package/Types/NotificationSetting/NotificationEmailRollupCategory.d.ts +1 -0
  146. package/Types/NotificationSetting/NotificationEmailRollupCategory.js +12 -0
  147. package/Types/NotificationSetting/NotificationEmailRollupPolicy.js +6 -0
  148. package/Types/NotificationSetting/NotificationSettingEventType.d.mts +3 -0
  149. package/Types/NotificationSetting/NotificationSettingEventType.d.ts +3 -0
  150. package/Types/NotificationSetting/NotificationSettingEventType.js +15 -0
  151. package/Types/ObjectID.d.mts +0 -1
  152. package/Types/ObjectID.d.ts +0 -1
  153. package/Types/ObjectID.js +0 -9
  154. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.d.mts +4 -0
  155. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.d.ts +4 -0
  156. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.js +25 -1
  157. package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.mjs +4 -0
  158. package/Types/OnCallDutyPolicy/OnCallEmptyLevel.d.mts +15 -0
  159. package/Types/OnCallDutyPolicy/OnCallEmptyLevel.d.ts +15 -0
  160. package/Types/OnCallDutyPolicy/OnCallEmptyLevel.js +118 -0
  161. package/Types/OnCallDutyPolicy/OnCallEmptyLevel.mjs +9 -0
  162. package/Types/Permission.d.mts +8 -0
  163. package/Types/Permission.d.ts +8 -0
  164. package/Types/Permission.js +87 -3
  165. package/Types/Phone.d.mts +0 -2
  166. package/Types/Phone.d.ts +0 -2
  167. package/Types/Phone.js +0 -14
  168. package/Types/Port.d.mts +0 -2
  169. package/Types/Port.d.ts +0 -2
  170. package/Types/Port.js +0 -14
  171. package/Types/ProviderLogo/ProviderLogo.d.mts +8 -1
  172. package/Types/ProviderLogo/ProviderLogo.d.ts +8 -1
  173. package/Types/ProviderLogo/ProviderLogo.js +14 -0
  174. package/Types/SecurityCase/SecurityCaseEventEvidence.d.mts +67 -0
  175. package/Types/SecurityCase/SecurityCaseEventEvidence.d.ts +67 -0
  176. package/Types/SecurityCase/SecurityCaseEventEvidence.js +271 -0
  177. package/Types/SecurityCase/SecurityCaseEventEvidence.mjs +13 -0
  178. package/Types/SecurityCase/SecurityCaseEvidenceKind.d.mts +8 -0
  179. package/Types/SecurityCase/SecurityCaseEvidenceKind.d.ts +8 -0
  180. package/Types/SecurityCase/SecurityCaseEvidenceKind.js +34 -0
  181. package/Types/SecurityCase/SecurityCaseEvidenceKind.mjs +4 -0
  182. package/Types/SecurityEvent/SecurityHunt.d.mts +122 -0
  183. package/Types/SecurityEvent/SecurityHunt.d.ts +122 -0
  184. package/Types/SecurityEvent/SecurityHunt.js +391 -0
  185. package/Types/SecurityEvent/SecurityHunt.mjs +32 -0
  186. package/Types/SecurityEvent/SecurityWatchlist.d.mts +167 -0
  187. package/Types/SecurityEvent/SecurityWatchlist.d.ts +167 -0
  188. package/Types/SecurityEvent/SecurityWatchlist.js +648 -0
  189. package/Types/SecurityEvent/SecurityWatchlist.mjs +51 -0
  190. package/Types/SecurityEvent/SigmaRule.d.mts +2 -0
  191. package/Types/SecurityEvent/SigmaRule.d.ts +2 -0
  192. package/Types/SecurityEvent/SigmaRule.js +5 -0
  193. package/Types/Telemetry/OpenTelemetryGuides.js +177 -5
  194. package/Types/Version.d.mts +0 -2
  195. package/Types/Version.d.ts +0 -2
  196. package/Types/Version.js +0 -14
  197. package/Types/Workflow/AffectedResourcesSetting.d.mts +13 -0
  198. package/Types/Workflow/AffectedResourcesSetting.d.ts +13 -0
  199. package/Types/Workflow/AffectedResourcesSetting.js +120 -0
  200. package/Types/Workflow/AffectedResourcesSetting.mjs +8 -0
  201. package/Types/Workflow/Components/BaseModel.js +15 -3
  202. package/Types/Workflow/Documentation/DatabaseDocumentation.js +36 -0
  203. package/Types/Workflow/RunRecord.d.mts +3 -14
  204. package/Types/Workflow/RunRecord.d.ts +3 -14
  205. package/Types/Workflow/RunRecord.js +10 -51
  206. package/Utils/AI/InvestigationLogStall.d.mts +38 -0
  207. package/Utils/AI/InvestigationLogStall.d.ts +38 -0
  208. package/Utils/AI/InvestigationLogStall.js +163 -0
  209. package/Utils/AI/InvestigationLogStall.mjs +11 -0
  210. package/Utils/Inventory/AssetFactSource.d.mts +6 -2
  211. package/Utils/Inventory/AssetFactSource.d.ts +6 -2
  212. package/Utils/Inventory/AssetFactSource.js +18 -1
  213. package/Utils/Inventory/AssetFactSource.mjs +1 -0
  214. package/Utils/Markdown/FeedLead.d.mts +10 -0
  215. package/Utils/Markdown/FeedLead.d.ts +10 -0
  216. package/Utils/Markdown/FeedLead.js +198 -0
  217. package/Utils/Markdown/FeedLead.mjs +8 -0
  218. package/Utils/NetworkDevice/NetworkDeviceAssetFacts.d.mts +9 -1
  219. package/Utils/NetworkDevice/NetworkDeviceAssetFacts.d.ts +9 -1
  220. package/Utils/NetworkDevice/NetworkDeviceAssetFacts.js +139 -18
  221. package/Utils/NetworkDevice/NetworkDeviceAssetFacts.mjs +1 -0
  222. package/Utils/NetworkDevice/NetworkDeviceRefresh.d.mts +88 -0
  223. package/Utils/NetworkDevice/NetworkDeviceRefresh.d.ts +88 -0
  224. package/Utils/NetworkDevice/NetworkDeviceRefresh.js +232 -0
  225. package/Utils/NetworkDevice/NetworkDeviceRefresh.mjs +16 -0
  226. package/Utils/NetworkTraffic/NetworkAddressBlock.d.mts +20 -0
  227. package/Utils/NetworkTraffic/NetworkAddressBlock.d.ts +20 -0
  228. package/Utils/NetworkTraffic/NetworkAddressBlock.js +264 -0
  229. package/Utils/NetworkTraffic/NetworkAddressBlock.mjs +3 -0
  230. package/Utils/Project/RecordNumber.d.mts +43 -0
  231. package/Utils/Project/RecordNumber.d.ts +43 -0
  232. package/Utils/Project/RecordNumber.js +151 -0
  233. package/Utils/Project/RecordNumber.mjs +6 -0
  234. package/Utils/Schema/MonitorSchemas.d.mts +9 -0
  235. package/Utils/Schema/MonitorSchemas.d.ts +9 -0
  236. package/Utils/Schema/MonitorSchemas.js +291 -0
  237. package/Utils/Schema/MonitorSchemas.mjs +9 -0
  238. package/Utils/Schema/TypeSchemas.d.mts +12 -0
  239. package/Utils/Schema/TypeSchemas.d.ts +12 -0
  240. package/Utils/Schema/TypeSchemas.js +176 -0
  241. package/Utils/Schema/TypeSchemas.mjs +11 -0
  242. package/Utils/Schema/Zod.js +17 -17
  243. package/Utils/SecurityCase/SecurityCaseMarkdown.d.mts +43 -0
  244. package/Utils/SecurityCase/SecurityCaseMarkdown.d.ts +43 -0
  245. package/Utils/SecurityCase/SecurityCaseMarkdown.js +89 -0
  246. package/Utils/SecurityCase/SecurityCaseMarkdown.mjs +11 -0
  247. package/Utils/SecurityCase/SecurityCasePriorities.d.mts +2 -0
  248. package/Utils/SecurityCase/SecurityCasePriorities.d.ts +2 -0
  249. package/Utils/SecurityCase/SecurityCasePriorities.js +15 -1
  250. package/Utils/SecurityCase/SecurityCaseTargets.d.mts +128 -0
  251. package/Utils/SecurityCase/SecurityCaseTargets.d.ts +128 -0
  252. package/Utils/SecurityCase/SecurityCaseTargets.js +482 -0
  253. package/Utils/SecurityCase/SecurityCaseTargets.mjs +28 -0
  254. package/Utils/SecurityEvent/SecurityEventSearch.d.mts +56 -0
  255. package/Utils/SecurityEvent/SecurityEventSearch.d.ts +56 -0
  256. package/Utils/SecurityEvent/SecurityEventSearch.js +422 -0
  257. package/Utils/SecurityEvent/SecurityEventSearch.mjs +21 -0
  258. package/Utils/SecurityEvent/SecurityHuntSearch.d.mts +12 -0
  259. package/Utils/SecurityEvent/SecurityHuntSearch.d.ts +12 -0
  260. package/Utils/SecurityEvent/SecurityHuntSearch.js +51 -0
  261. package/Utils/SecurityEvent/SecurityHuntSearch.mjs +3 -0
  262. package/Utils/SecurityEvent/Sigma/SigmaRuleParser.js +22 -0
  263. package/Utils/SecurityEvent/Sigma/SigmaWatchlists.d.mts +24 -0
  264. package/Utils/SecurityEvent/Sigma/SigmaWatchlists.d.ts +24 -0
  265. package/Utils/SecurityEvent/Sigma/SigmaWatchlists.js +183 -0
  266. package/Utils/SecurityEvent/Sigma/SigmaWatchlists.mjs +9 -0
  267. package/Utils/Suggestions/TracePerformanceFixSuggestion.d.mts +9 -0
  268. package/Utils/Suggestions/TracePerformanceFixSuggestion.d.ts +9 -0
  269. package/Utils/Suggestions/TracePerformanceFixSuggestion.js +69 -1
  270. package/Utils/Suggestions/TracePerformanceFixSuggestion.mjs +4 -0
  271. package/package.json +1 -1
@@ -7,6 +7,7 @@ exports.extractMitre = extractMitre;
7
7
  const js_yaml_1 = __importDefault(require("js-yaml"));
8
8
  const BadDataException_1 = __importDefault(require("../../../Types/Exception/BadDataException"));
9
9
  const MitreAttack_1 = require("../../../Types/SecurityEvent/MitreAttack");
10
+ const SecurityWatchlist_1 = require("../../../Types/SecurityEvent/SecurityWatchlist");
10
11
  const SigmaRule_1 = require("../../../Types/SecurityEvent/SigmaRule");
11
12
  /*
12
13
  * Sigma YAML -> typed SigmaRule.
@@ -178,8 +179,29 @@ function parseFieldRequirement(key, rawValue) {
178
179
  throw new BadDataException_1.default(`Sigma detection: field "${key}" has a nested object value — only scalars, lists of scalars, and null are supported.`);
179
180
  }
180
181
  }
182
+ if (modifiers.includes(SecurityWatchlist_1.SECURITY_WATCHLIST_MODIFIER)) {
183
+ checkWatchlistRequirement(key, modifiers, values);
184
+ }
181
185
  return { field, modifiers, values };
182
186
  }
187
+ /*
188
+ * `field|expand` reads watchlists (Types/SecurityEvent/SecurityWatchlist):
189
+ * each value names one, as '%vip_users%', and the field matches when it is
190
+ * on any of them. How a list's values match - whatever the case, * for any
191
+ * run, an address range - is the list's, so expand takes no other modifier.
192
+ * Whether the project has the lists is checked where the project is known,
193
+ * when the rule is saved and each time it runs.
194
+ */
195
+ function checkWatchlistRequirement(key, modifiers, values) {
196
+ if (modifiers.length > 1) {
197
+ throw new BadDataException_1.default(`Sigma detection: "${key}" reads a watchlist, and expand takes no other modifier. Write the field and |expand alone, such as principalUser|expand: '%vip_users%'; to match part of a value, put * in the watchlist's values.`);
198
+ }
199
+ for (const value of values) {
200
+ if ((0, SecurityWatchlist_1.readSecurityWatchlistPlaceholder)(value) === null) {
201
+ throw new BadDataException_1.default(`Sigma detection: "${key}" names a watchlist between % signs, such as '%vip_users%' (letters, digits and underscores, starting with a letter), not ${JSON.stringify(value)}.`);
202
+ }
203
+ }
204
+ }
183
205
  function parseSelection(name, rawValue) {
184
206
  // Map: fields AND together.
185
207
  if (rawValue !== null &&
@@ -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;
@@ -26,10 +26,19 @@ export interface TracePerformanceFixOffer {
26
26
  export declare function getTracePerformanceFixOffer(input: TracePerformanceFixOfferInput): TracePerformanceFixOffer;
27
27
  export declare function isDatabaseFinding(finding: PerformanceFinding): boolean;
28
28
  export declare function getFindingOperationName(finding: PerformanceFinding): string;
29
+ export interface TracePerformanceFixRepository {
30
+ id: string;
31
+ name: string;
32
+ }
33
+ export declare const MAX_TRACE_PERFORMANCE_FIX_REPOSITORIES: number;
34
+ export declare const PICK_A_REPOSITORY_FOR_THE_FIX_MESSAGE: string;
35
+ export declare const PICKED_REPOSITORY_NOT_CONNECTED_MESSAGE: string;
29
36
  export interface TracePerformanceFixSuggestion extends TracePerformanceFixOffer {
30
37
  aiRunId: string | null;
38
+ repositories: Array<TracePerformanceFixRepository>;
31
39
  }
32
40
  export declare const NO_TRACE_PERFORMANCE_FIX_SUGGESTION: TracePerformanceFixSuggestion;
41
+ export declare function parseTracePerformanceFixRepositories(value: unknown): Array<TracePerformanceFixRepository>;
33
42
  export declare function parsePerformanceFinding(value: unknown): PerformanceFinding | null;
34
43
  export declare function parseTracePerformanceFixSuggestion(value: unknown): TracePerformanceFixSuggestion;
35
44
  export declare function tracePerformanceFixSuggestionToJSON(suggestion: TracePerformanceFixSuggestion): JSONObject;
@@ -26,10 +26,19 @@ export interface TracePerformanceFixOffer {
26
26
  export declare function getTracePerformanceFixOffer(input: TracePerformanceFixOfferInput): TracePerformanceFixOffer;
27
27
  export declare function isDatabaseFinding(finding: PerformanceFinding): boolean;
28
28
  export declare function getFindingOperationName(finding: PerformanceFinding): string;
29
+ export interface TracePerformanceFixRepository {
30
+ id: string;
31
+ name: string;
32
+ }
33
+ export declare const MAX_TRACE_PERFORMANCE_FIX_REPOSITORIES: number;
34
+ export declare const PICK_A_REPOSITORY_FOR_THE_FIX_MESSAGE: string;
35
+ export declare const PICKED_REPOSITORY_NOT_CONNECTED_MESSAGE: string;
29
36
  export interface TracePerformanceFixSuggestion extends TracePerformanceFixOffer {
30
37
  aiRunId: string | null;
38
+ repositories: Array<TracePerformanceFixRepository>;
31
39
  }
32
40
  export declare const NO_TRACE_PERFORMANCE_FIX_SUGGESTION: TracePerformanceFixSuggestion;
41
+ export declare function parseTracePerformanceFixRepositories(value: unknown): Array<TracePerformanceFixRepository>;
33
42
  export declare function parsePerformanceFinding(value: unknown): PerformanceFinding | null;
34
43
  export declare function parseTracePerformanceFixSuggestion(value: unknown): TracePerformanceFixSuggestion;
35
44
  export declare function tracePerformanceFixSuggestionToJSON(suggestion: TracePerformanceFixSuggestion): JSONObject;
@@ -33,12 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.NO_TRACE_PERFORMANCE_FIX_SUGGESTION = exports.TRACE_NOT_WORTH_FIXING_MESSAGE = exports.WORTH_FIXING_MIN_PERCENT_OF_TRACE = exports.WORTH_FIXING_MIN_MS = void 0;
36
+ exports.NO_TRACE_PERFORMANCE_FIX_SUGGESTION = exports.PICKED_REPOSITORY_NOT_CONNECTED_MESSAGE = exports.PICK_A_REPOSITORY_FOR_THE_FIX_MESSAGE = exports.MAX_TRACE_PERFORMANCE_FIX_REPOSITORIES = exports.TRACE_NOT_WORTH_FIXING_MESSAGE = exports.WORTH_FIXING_MIN_PERCENT_OF_TRACE = exports.WORTH_FIXING_MIN_MS = void 0;
37
37
  exports.isFindingWorthFixing = isFindingWorthFixing;
38
38
  exports.getFindingsWorthFixing = getFindingsWorthFixing;
39
39
  exports.getTracePerformanceFixOffer = getTracePerformanceFixOffer;
40
40
  exports.isDatabaseFinding = isDatabaseFinding;
41
41
  exports.getFindingOperationName = getFindingOperationName;
42
+ exports.parseTracePerformanceFixRepositories = parseTracePerformanceFixRepositories;
42
43
  exports.parsePerformanceFinding = parsePerformanceFinding;
43
44
  exports.parseTracePerformanceFixSuggestion = parseTracePerformanceFixSuggestion;
44
45
  exports.tracePerformanceFixSuggestionToJSON = tracePerformanceFixSuggestionToJSON;
@@ -179,6 +180,25 @@ function getFindingOperationName(finding) {
179
180
  }
180
181
  return finding.normalizedSpanName;
181
182
  }
183
+ /*
184
+ * The most repositories the page is offered to pick from: far more than a
185
+ * project connects, and a bound on what one answer carries.
186
+ */
187
+ exports.MAX_TRACE_PERFORMANCE_FIX_REPOSITORIES = 200;
188
+ /*
189
+ * The server's refusal of a fix the person did not pick a repository for,
190
+ * when several are connected and none was found to hold the trace's code
191
+ * for certain. The trace page asks for the pick first, so people meet this
192
+ * through the API, or on the page after the second repository was
193
+ * connected since it read the list - after "Could not start the fix:",
194
+ * beside the picker the page then shows.
195
+ */
196
+ exports.PICK_A_REPOSITORY_FOR_THE_FIX_MESSAGE = "Several repositories are connected, and none could be matched to this trace's service or code. Pick the one that holds this code.";
197
+ /*
198
+ * The server's refusal of a pick that is not one of the project's connected
199
+ * repositories AI can work in.
200
+ */
201
+ exports.PICKED_REPOSITORY_NOT_CONNECTED_MESSAGE = "That repository is not one of this project's connected repositories OneUptime AI can work in. Pick another, or connect it in Code.";
182
202
  exports.NO_TRACE_PERFORMANCE_FIX_SUGGESTION = {
183
203
  offer: SuggestionOffer_1.default.None,
184
204
  finding: null,
@@ -186,7 +206,48 @@ exports.NO_TRACE_PERFORMANCE_FIX_SUGGESTION = {
186
206
  fixOutcome: null,
187
207
  blocker: null,
188
208
  aiRunId: null,
209
+ repositories: [],
189
210
  };
211
+ function parseRepository(value) {
212
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
213
+ return null;
214
+ }
215
+ const record = value;
216
+ const id = record["id"];
217
+ const name = record["name"];
218
+ if (typeof id !== "string" ||
219
+ !id.trim() ||
220
+ typeof name !== "string" ||
221
+ !name.trim()) {
222
+ return null;
223
+ }
224
+ return { id: id.trim(), name: name.trim() };
225
+ }
226
+ /*
227
+ * The repositories off the wire: whole entries only, each once, at most
228
+ * MAX_TRACE_PERFORMANCE_FIX_REPOSITORIES, in the order the server sent.
229
+ * One repository is no choice (the fix would work in it anyway), so a list
230
+ * of fewer than two reads as none.
231
+ */
232
+ function parseTracePerformanceFixRepositories(value) {
233
+ if (!Array.isArray(value)) {
234
+ return [];
235
+ }
236
+ const seen = new Set();
237
+ const repositories = [];
238
+ for (const entry of value) {
239
+ const repository = parseRepository(entry);
240
+ if (!repository || seen.has(repository.id.toLowerCase())) {
241
+ continue;
242
+ }
243
+ seen.add(repository.id.toLowerCase());
244
+ repositories.push(repository);
245
+ if (repositories.length >= exports.MAX_TRACE_PERFORMANCE_FIX_REPOSITORIES) {
246
+ break;
247
+ }
248
+ }
249
+ return repositories.length > 1 ? repositories : [];
250
+ }
190
251
  function isFiniteNumber(value) {
191
252
  return typeof value === "number" && Number.isFinite(value);
192
253
  }
@@ -320,6 +381,10 @@ function parseTracePerformanceFixSuggestion(value) {
320
381
  fixOutcome,
321
382
  blocker,
322
383
  aiRunId: linksRun ? aiRunId : null,
384
+ // A pick is the fix's own step: only an offer of the fix carries one.
385
+ repositories: offer === SuggestionOffer_1.default.Act
386
+ ? parseTracePerformanceFixRepositories(record["repositories"])
387
+ : [],
323
388
  };
324
389
  }
325
390
  // The route's answer as JSON (the server's side of the parser above).
@@ -335,5 +400,8 @@ function tracePerformanceFixSuggestionToJSON(suggestion) {
335
400
  ? (0, SuggestionBlocker_1.suggestionBlockerToJSON)(suggestion.blocker)
336
401
  : null,
337
402
  aiRunId: suggestion.aiRunId,
403
+ repositories: suggestion.repositories.map((repository) => {
404
+ return { id: repository.id, name: repository.name };
405
+ }),
338
406
  };
339
407
  }
@@ -1,5 +1,8 @@
1
1
  import commonJsModule from "./TracePerformanceFixSuggestion.js";
2
+ export const MAX_TRACE_PERFORMANCE_FIX_REPOSITORIES = commonJsModule.MAX_TRACE_PERFORMANCE_FIX_REPOSITORIES;
2
3
  export const NO_TRACE_PERFORMANCE_FIX_SUGGESTION = commonJsModule.NO_TRACE_PERFORMANCE_FIX_SUGGESTION;
4
+ export const PICKED_REPOSITORY_NOT_CONNECTED_MESSAGE = commonJsModule.PICKED_REPOSITORY_NOT_CONNECTED_MESSAGE;
5
+ export const PICK_A_REPOSITORY_FOR_THE_FIX_MESSAGE = commonJsModule.PICK_A_REPOSITORY_FOR_THE_FIX_MESSAGE;
3
6
  export const TRACE_NOT_WORTH_FIXING_MESSAGE = commonJsModule.TRACE_NOT_WORTH_FIXING_MESSAGE;
4
7
  export const WORTH_FIXING_MIN_MS = commonJsModule.WORTH_FIXING_MIN_MS;
5
8
  export const WORTH_FIXING_MIN_PERCENT_OF_TRACE = commonJsModule.WORTH_FIXING_MIN_PERCENT_OF_TRACE;
@@ -9,5 +12,6 @@ export const getTracePerformanceFixOffer = commonJsModule.getTracePerformanceFix
9
12
  export const isDatabaseFinding = commonJsModule.isDatabaseFinding;
10
13
  export const isFindingWorthFixing = commonJsModule.isFindingWorthFixing;
11
14
  export const parsePerformanceFinding = commonJsModule.parsePerformanceFinding;
15
+ export const parseTracePerformanceFixRepositories = commonJsModule.parseTracePerformanceFixRepositories;
12
16
  export const parseTracePerformanceFixSuggestion = commonJsModule.parseTracePerformanceFixSuggestion;
13
17
  export const tracePerformanceFixSuggestionToJSON = commonJsModule.tracePerformanceFixSuggestionToJSON;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneuptime/common",
3
- "version": "14.0.96",
3
+ "version": "14.0.98",
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": {