@oneuptime/common 14.0.91 → 14.0.92

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 (90) hide show
  1. package/Models/DatabaseModels/AutoRemediationRule.js +1 -1
  2. package/Models/DatabaseModels/CodeRepository.d.mts +1 -0
  3. package/Models/DatabaseModels/CodeRepository.d.ts +1 -0
  4. package/Models/DatabaseModels/CodeRepository.js +69 -6
  5. package/Types/AI/CodeTask.d.mts +1 -0
  6. package/Types/AI/CodeTask.d.ts +1 -0
  7. package/Types/AI/TelemetryAiActivity.d.mts +1 -0
  8. package/Types/AI/TelemetryAiActivity.d.ts +1 -0
  9. package/Types/AI/TelemetryAiActivity.js +4 -0
  10. package/Types/CodeRepository/CodeRepositorySetting.d.mts +15 -0
  11. package/Types/CodeRepository/CodeRepositorySetting.d.ts +15 -0
  12. package/Types/CodeRepository/CodeRepositorySetting.js +49 -0
  13. package/Types/CodeRepository/CodeRepositorySetting.mjs +3 -0
  14. package/Types/Date.d.mts +10 -0
  15. package/Types/Date.d.ts +10 -0
  16. package/Types/Date.js +385 -98
  17. package/Types/DateLanguage.d.mts +67 -0
  18. package/Types/DateLanguage.d.ts +67 -0
  19. package/Types/DateLanguage.js +478 -0
  20. package/Types/DateLanguage.mjs +21 -0
  21. package/Types/Runner/CodeRepositoryRunner.d.mts +7 -0
  22. package/Types/Runner/CodeRepositoryRunner.d.ts +7 -0
  23. package/Types/Runner/CodeRepositoryRunner.js +60 -14
  24. package/Types/Runner/CodeRepositoryRunner.mjs +1 -0
  25. package/Types/SecurityEvent/OcsfProcessActivity.d.mts +25 -0
  26. package/Types/SecurityEvent/OcsfProcessActivity.d.ts +25 -0
  27. package/Types/SecurityEvent/OcsfProcessActivity.js +131 -0
  28. package/Types/SecurityEvent/OcsfProcessActivity.mjs +8 -0
  29. package/UI/Utils/TranslateTemplate.d.mts +73 -0
  30. package/UI/Utils/TranslateTemplate.d.ts +73 -0
  31. package/Utils/CronTab.d.mts +41 -3
  32. package/Utils/CronTab.d.ts +41 -3
  33. package/Utils/CronTab.js +112 -38
  34. package/Utils/Monitor/MonitorOverviewTargetUtil.d.mts +2 -0
  35. package/Utils/Monitor/MonitorOverviewTargetUtil.d.ts +2 -0
  36. package/Utils/Monitor/MonitorOverviewTargetUtil.js +13 -2
  37. package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.d.mts +5 -0
  38. package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.d.ts +5 -0
  39. package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.js +219 -58
  40. package/Utils/SecurityEvent/OcsfNormalizer.js +22 -13
  41. package/Utils/Slo/SloDuration.d.mts +1 -0
  42. package/Utils/Slo/SloDuration.d.ts +1 -0
  43. package/Utils/Slo/SloDuration.js +57 -8
  44. package/Utils/Slo/SloDuration.mjs +1 -0
  45. package/Utils/Suggestions/CodeFixSuggestion.d.mts +15 -0
  46. package/Utils/Suggestions/CodeFixSuggestion.d.ts +15 -0
  47. package/Utils/Suggestions/CodeFixSuggestion.js +62 -1
  48. package/Utils/Suggestions/CodeFixSuggestion.mjs +4 -0
  49. package/Utils/Suggestions/ProfileFixSuggestion.js +4 -0
  50. package/Utils/Suggestions/SuggestionBlocker.d.mts +8 -0
  51. package/Utils/Suggestions/SuggestionBlocker.d.ts +8 -0
  52. package/Utils/Suggestions/SuggestionBlocker.js +51 -0
  53. package/Utils/Suggestions/SuggestionBlocker.mjs +4 -0
  54. package/Utils/Suggestions/SuggestionOffer.d.mts +2 -1
  55. package/Utils/Suggestions/SuggestionOffer.d.ts +2 -1
  56. package/Utils/Suggestions/SuggestionOffer.js +5 -0
  57. package/Utils/Suggestions/TelemetryAiFixSuggestion.d.mts +2 -7
  58. package/Utils/Suggestions/TelemetryAiFixSuggestion.d.ts +2 -7
  59. package/Utils/Suggestions/TelemetryAiFixSuggestion.js +8 -36
  60. package/Utils/Suggestions/TelemetryImprovementSuggestion.d.mts +1 -0
  61. package/Utils/Suggestions/TelemetryImprovementSuggestion.d.ts +1 -0
  62. package/Utils/Suggestions/TelemetryImprovementSuggestion.js +1 -0
  63. package/Utils/Suggestions/TracePerformanceFixSuggestion.d.mts +6 -0
  64. package/Utils/Suggestions/TracePerformanceFixSuggestion.d.ts +6 -0
  65. package/Utils/Suggestions/TracePerformanceFixSuggestion.js +46 -5
  66. package/package.json +8 -1
  67. package/Utils/Monitor/MonitorCheckScheduleUtil.d.mts +0 -61
  68. package/Utils/Monitor/MonitorCheckScheduleUtil.d.ts +0 -61
  69. package/Utils/Monitor/MonitorCheckScheduleUtil.js +0 -476
  70. package/Utils/Monitor/MonitorCheckScheduleUtil.mjs +0 -3
  71. package/Utils/Monitor/MonitorOverviewFamily.d.mts +0 -39
  72. package/Utils/Monitor/MonitorOverviewFamily.d.ts +0 -39
  73. package/Utils/Monitor/MonitorOverviewFamily.js +0 -206
  74. package/Utils/Monitor/MonitorOverviewFamily.mjs +0 -4
  75. package/Utils/Monitor/MonitorOverviewPresentationUtil.d.mts +0 -189
  76. package/Utils/Monitor/MonitorOverviewPresentationUtil.d.ts +0 -189
  77. package/Utils/Monitor/MonitorOverviewPresentationUtil.js +0 -1480
  78. package/Utils/Monitor/MonitorOverviewPresentationUtil.mjs +0 -5
  79. package/Utils/Monitor/MonitorOverviewProbeUtil.d.mts +0 -112
  80. package/Utils/Monitor/MonitorOverviewProbeUtil.d.ts +0 -112
  81. package/Utils/Monitor/MonitorOverviewProbeUtil.js +0 -640
  82. package/Utils/Monitor/MonitorOverviewProbeUtil.mjs +0 -3
  83. package/Utils/Monitor/MonitorStatusHistoryUtil.d.mts +0 -27
  84. package/Utils/Monitor/MonitorStatusHistoryUtil.d.ts +0 -27
  85. package/Utils/Monitor/MonitorStatusHistoryUtil.js +0 -132
  86. package/Utils/Monitor/MonitorStatusHistoryUtil.mjs +0 -2
  87. package/Utils/Monitor/MonitorUptimeSummaryUtil.d.mts +0 -42
  88. package/Utils/Monitor/MonitorUptimeSummaryUtil.d.ts +0 -42
  89. package/Utils/Monitor/MonitorUptimeSummaryUtil.js +0 -468
  90. package/Utils/Monitor/MonitorUptimeSummaryUtil.mjs +0 -2
@@ -7,34 +7,65 @@ exports.UDM_PRODUCT_NAME_FALLBACK = exports.UDM_VENDOR_NAME_FALLBACK = exports.U
7
7
  exports.chooseUdmEventType = chooseUdmEventType;
8
8
  exports.toUdmEvent = toUdmEvent;
9
9
  const IP_1 = __importDefault(require("../../../Types/IP/IP"));
10
+ const OcsfProcessActivity_1 = require("../../../Types/SecurityEvent/OcsfProcessActivity");
11
+ const NormalizerHelpers_1 = require("../NormalizerHelpers");
10
12
  /*
11
13
  * A OneUptime security event as a Google SecOps UDM event - what the
12
14
  * Chronicle API's events:import takes (inlineSource.events[].udm).
13
15
  *
14
16
  * UDM checks each event type for the fields it needs: a USER_LOGIN names
15
- * the account and the machine, a PROCESS_LAUNCH the machine and the
16
- * process, a NETWORK_CONNECTION both ends. An event is given the specific
17
- * type only when it carries those fields, and GENERIC_EVENT - which needs
18
- * nothing - otherwise, so every event OneUptime holds has a type SecOps
19
- * accepts. What OneUptime found about it (a rule's match, its severity, the
20
- * ATT&CK tactics and techniques) is the UDM security result, and the
21
- * event's id and class are additional fields, so an analyst in SecOps can
22
- * find the event in OneUptime again.
17
+ * the account and the machine, a process event (PROCESS_LAUNCH,
18
+ * PROCESS_OPEN, ...) the machine and the process acted on, a
19
+ * NETWORK_CONNECTION both ends. An event is given the specific type only
20
+ * when it carries those fields, and GENERIC_EVENT - which needs nothing -
21
+ * otherwise, so every event OneUptime holds has a type SecOps accepts.
22
+ * What OneUptime found about it (a rule's match, its severity, the ATT&CK
23
+ * tactics and techniques) is the UDM security result, and the event's id
24
+ * and class are additional fields, so an analyst in SecOps can find the
25
+ * event in OneUptime again.
23
26
  *
24
27
  * Field names are the canonical JSON names of the UDM proto (lowerCamelCase),
25
28
  * which the API reads.
26
29
  * https://cloud.google.com/chronicle/docs/reference/udm-field-list
30
+ * https://cloud.google.com/chronicle/docs/unified-data-model/udm-usage
27
31
  */
28
32
  var UdmEventType;
29
33
  (function (UdmEventType) {
30
34
  UdmEventType["UserLogin"] = "USER_LOGIN";
31
35
  UdmEventType["ProcessLaunch"] = "PROCESS_LAUNCH";
36
+ UdmEventType["ProcessOpen"] = "PROCESS_OPEN";
37
+ UdmEventType["ProcessInjection"] = "PROCESS_INJECTION";
38
+ UdmEventType["ProcessTermination"] = "PROCESS_TERMINATION";
39
+ UdmEventType["ProcessPrivilegeEscalation"] = "PROCESS_PRIVILEGE_ESCALATION";
40
+ UdmEventType["ProcessUncategorized"] = "PROCESS_UNCATEGORIZED";
32
41
  UdmEventType["NetworkConnection"] = "NETWORK_CONNECTION";
33
42
  UdmEventType["GenericEvent"] = "GENERIC_EVENT";
34
43
  })(UdmEventType || (exports.UdmEventType = UdmEventType = {}));
44
+ /*
45
+ * The process event types in which one process acts on another: the one
46
+ * that acted is the principal's process and the one acted on the target's
47
+ * (UDM usage guide, "PROCESS_INJECTION, PROCESS_LAUNCH, PROCESS_OPEN,
48
+ * PROCESS_TERMINATION, PROCESS_UNCATEGORIZED"). A launch is the same with
49
+ * the parent as the one that acted, which OneUptime already holds as the
50
+ * parent's own fields.
51
+ */
52
+ const ACTED_ON_PROCESS_TYPES = [
53
+ UdmEventType.ProcessOpen,
54
+ UdmEventType.ProcessInjection,
55
+ UdmEventType.ProcessTermination,
56
+ UdmEventType.ProcessPrivilegeEscalation,
57
+ UdmEventType.ProcessUncategorized,
58
+ ];
59
+ // The UDM type of each kind of process activity done to another process.
60
+ const ACTED_ON_TYPE_BY_KIND = {
61
+ [OcsfProcessActivity_1.ProcessActivityKind.Open]: UdmEventType.ProcessOpen,
62
+ [OcsfProcessActivity_1.ProcessActivityKind.Inject]: UdmEventType.ProcessInjection,
63
+ [OcsfProcessActivity_1.ProcessActivityKind.Terminate]: UdmEventType.ProcessTermination,
64
+ [OcsfProcessActivity_1.ProcessActivityKind.PrivilegeEscalation]: UdmEventType.ProcessPrivilegeEscalation,
65
+ [OcsfProcessActivity_1.ProcessActivityKind.Other]: UdmEventType.ProcessUncategorized,
66
+ };
35
67
  // OCSF classes (OcsfEventClass) a specific UDM type exists for.
36
68
  const OCSF_AUTHENTICATION_CLASS_UID = 3002;
37
- const OCSF_PROCESS_ACTIVITY_CLASS_UID = 1007;
38
69
  const OCSF_NETWORK_ACTIVITY_CLASS_UID = 4001;
39
70
  exports.UDM_VENDOR_NAME_FALLBACK = "OneUptime";
40
71
  exports.UDM_PRODUCT_NAME_FALLBACK = "OneUptime Security Events";
@@ -42,26 +73,32 @@ exports.UDM_PRODUCT_NAME_FALLBACK = "OneUptime Security Events";
42
73
  const MAX_DESCRIPTION_LENGTH = 1024;
43
74
  const MAX_ADDITIONAL_FIELDS = 40;
44
75
  const MAX_ADDITIONAL_VALUE_LENGTH = 512;
76
+ const WHITESPACE = /\s/;
77
+ /*
78
+ * Both tables are Maps, not objects: a status is the source's own text, and
79
+ * an object answers "constructor" or "toString" with what every object
80
+ * inherits - which went out as an action of [null], a batch SecOps refuses.
81
+ */
45
82
  // OCSF severity name -> UDM SecurityResult.ProductSeverity.
46
- const UDM_SEVERITY = {
47
- Unknown: "UNKNOWN_SEVERITY",
48
- Informational: "INFORMATIONAL",
49
- Low: "LOW",
50
- Medium: "MEDIUM",
51
- High: "HIGH",
52
- Critical: "CRITICAL",
53
- Fatal: "CRITICAL",
54
- Other: "UNKNOWN_SEVERITY",
55
- };
83
+ const UDM_SEVERITY = new Map([
84
+ ["Unknown", "UNKNOWN_SEVERITY"],
85
+ ["Informational", "INFORMATIONAL"],
86
+ ["Low", "LOW"],
87
+ ["Medium", "MEDIUM"],
88
+ ["High", "HIGH"],
89
+ ["Critical", "CRITICAL"],
90
+ ["Fatal", "CRITICAL"],
91
+ ["Other", "UNKNOWN_SEVERITY"],
92
+ ]);
56
93
  // OCSF status -> UDM SecurityResult.Action, the inverse of the UDM normalizer's.
57
- const UDM_ACTION = {
58
- success: "ALLOW",
59
- allowed: "ALLOW",
60
- failure: "FAIL",
61
- blocked: "BLOCK",
62
- denied: "BLOCK",
63
- quarantined: "QUARANTINE",
64
- };
94
+ const UDM_ACTION = new Map([
95
+ ["success", "ALLOW"],
96
+ ["allowed", "ALLOW"],
97
+ ["failure", "FAIL"],
98
+ ["blocked", "BLOCK"],
99
+ ["denied", "BLOCK"],
100
+ ["quarantined", "QUARANTINE"],
101
+ ]);
65
102
  function cut(text, limit) {
66
103
  return text.length > limit ? text.slice(0, limit) : text;
67
104
  }
@@ -87,36 +124,115 @@ function udmUser(name) {
87
124
  }
88
125
  return user;
89
126
  }
90
- // A UDM Process: its command line and its executable's path.
91
- function udmProcess(data) {
92
- const commandLine = (data.commandLine || "").trim();
93
- const path = (data.path || "").trim();
94
- if (!commandLine && !path) {
127
+ /*
128
+ * A UDM Process: its command line, and its executable. UDM has no field
129
+ * for a process's name: the executable is file.fullPath - its path when
130
+ * the source gave one, else its name, as SecOps' own parsers keep an image
131
+ * name they have no path for - and the name is in file.names, where
132
+ * OneUptime's UDM reader takes it back from.
133
+ */
134
+ function udmProcess(reading) {
135
+ const name = (reading.name || "").trim();
136
+ const path = (reading.path || "").trim();
137
+ const commandLine = (reading.commandLine || "").trim();
138
+ if (!name && !path && !commandLine) {
95
139
  return null;
96
140
  }
97
141
  const udmProcessNoun = {};
98
142
  if (commandLine) {
99
143
  udmProcessNoun["commandLine"] = cut(commandLine, 2048);
100
144
  }
101
- if (path) {
102
- udmProcessNoun["file"] = { fullPath: cut(path, 1024) };
145
+ const executable = path || name;
146
+ if (executable) {
147
+ const file = { fullPath: cut(executable, 1024) };
148
+ const fileName = name || (0, NormalizerHelpers_1.fileNameOfPath)(path);
149
+ if (fileName) {
150
+ file["names"] = [cut(fileName, 256)];
151
+ }
152
+ udmProcessNoun["file"] = file;
103
153
  }
104
154
  return udmProcessNoun;
105
155
  }
106
156
  /*
107
- * The process the event is about. A row stored before OneUptime read the
108
- * process fields names only principalProcess, which stands in for it.
157
+ * A process known by one text only - principalProcess, the process that
158
+ * acted, which a source fills with a name, a path or a command line: a
159
+ * command line when it has a space in it, its executable otherwise.
109
160
  */
110
- function eventProcess(record) {
111
- return (udmProcess({
112
- commandLine: record.processCommandLine,
161
+ function processFromText(text) {
162
+ const trimmed = (text || "").trim();
163
+ if (!trimmed) {
164
+ return {};
165
+ }
166
+ if (WHITESPACE.test(trimmed)) {
167
+ return { commandLine: trimmed };
168
+ }
169
+ return { path: trimmed, name: (0, NormalizerHelpers_1.fileNameOfPath)(trimmed) };
170
+ }
171
+ /*
172
+ * Whether the event names no process in its own process fields at all: a
173
+ * row stored before OneUptime read them, which knows its process only as
174
+ * principalProcess.
175
+ */
176
+ function namesNoProcessOfItsOwn(record) {
177
+ return ![
178
+ record.processName,
179
+ record.processPath,
180
+ record.processCommandLine,
181
+ record.parentProcessName,
182
+ record.parentProcessPath,
183
+ record.parentProcessCommandLine,
184
+ ].some((value) => {
185
+ return Boolean((value || "").trim());
186
+ });
187
+ }
188
+ // The process the event is about, from its own process fields.
189
+ function ownProcess(record) {
190
+ return udmProcess({
191
+ name: record.processName,
113
192
  path: record.processPath,
114
- }) || udmProcess({ commandLine: record.principalProcess }));
193
+ commandLine: record.processCommandLine,
194
+ });
115
195
  }
116
196
  function parentProcess(record) {
117
197
  return udmProcess({
118
- commandLine: record.parentProcessCommandLine,
198
+ name: record.parentProcessName,
119
199
  path: record.parentProcessPath,
200
+ commandLine: record.parentProcessCommandLine,
201
+ });
202
+ }
203
+ /*
204
+ * The process the event is about. A row stored before OneUptime read the
205
+ * process fields names only principalProcess, which stands in for it;
206
+ * once any of them is filled, they say which process it is, and the
207
+ * process that acted is never taken for it.
208
+ */
209
+ function eventProcess(record) {
210
+ if (namesNoProcessOfItsOwn(record)) {
211
+ return udmProcess(processFromText(record.principalProcess));
212
+ }
213
+ return ownProcess(record);
214
+ }
215
+ // The process that acted on another: principalProcess.
216
+ function actingProcess(record) {
217
+ return udmProcess(processFromText(record.principalProcess));
218
+ }
219
+ function withParent(process, parent) {
220
+ if (process && parent) {
221
+ process["parentProcess"] = parent;
222
+ }
223
+ return process;
224
+ }
225
+ /*
226
+ * What a Process Activity did to its process, read as ingest read it: the
227
+ * activity id its payload carried (kept in the attributes) before the
228
+ * name, so an event whose source sent only the id - stored before
229
+ * OneUptime named such an activity - is sent as the activity its process
230
+ * fields were read by.
231
+ */
232
+ function processActivityOf(record) {
233
+ return (0, OcsfProcessActivity_1.getProcessActivityKind)({
234
+ activityId: (0, OcsfProcessActivity_1.readProcessActivityId)(record.attributes["activity_id"]),
235
+ activityName: record.activityName,
120
236
  });
121
237
  }
122
238
  // A UDM Noun (principal or target): a machine, its user, process and port.
@@ -156,6 +272,36 @@ function isUrl(value) {
156
272
  value.startsWith("https://") ||
157
273
  value.startsWith("/"));
158
274
  }
275
+ /*
276
+ * The UDM type of a Process Activity on a machine, when the event carries
277
+ * what that type needs, and null when it does not:
278
+ *
279
+ * - a launch, the process launched (which a row stored before the process
280
+ * fields knows as principalProcess);
281
+ * - an open, an injection, an end or any other activity, the process
282
+ * acted on, from the event's own process fields - never principalProcess,
283
+ * which is the process that acted;
284
+ * - a privilege escalation, which UDM checks for the process that raised
285
+ * its privileges and the user it ran as, is PROCESS_UNCATEGORIZED
286
+ * without them.
287
+ */
288
+ function processEventType(record) {
289
+ const kind = processActivityOf(record);
290
+ if (kind === OcsfProcessActivity_1.ProcessActivityKind.Launch) {
291
+ return eventProcess(record) ? UdmEventType.ProcessLaunch : null;
292
+ }
293
+ if (kind === OcsfProcessActivity_1.ProcessActivityKind.PrivilegeEscalation &&
294
+ actingProcess(record) &&
295
+ record.principalUser.trim()) {
296
+ return UdmEventType.ProcessPrivilegeEscalation;
297
+ }
298
+ if (!ownProcess(record)) {
299
+ return null;
300
+ }
301
+ return kind === OcsfProcessActivity_1.ProcessActivityKind.PrivilegeEscalation
302
+ ? UdmEventType.ProcessUncategorized
303
+ : ACTED_ON_TYPE_BY_KIND[kind];
304
+ }
159
305
  /*
160
306
  * The UDM type an event is sent as: the specific one when it carries the
161
307
  * fields that type needs, GENERIC_EVENT otherwise.
@@ -168,10 +314,12 @@ function chooseUdmEventType(record) {
168
314
  (principalHasMachine || targetHasMachine)) {
169
315
  return UdmEventType.UserLogin;
170
316
  }
171
- if (record.classUid === OCSF_PROCESS_ACTIVITY_CLASS_UID &&
172
- eventProcess(record) &&
317
+ if (record.classUid === OcsfProcessActivity_1.OCSF_PROCESS_ACTIVITY_CLASS_UID &&
173
318
  principalHasMachine) {
174
- return UdmEventType.ProcessLaunch;
319
+ const processType = processEventType(record);
320
+ if (processType) {
321
+ return processType;
322
+ }
175
323
  }
176
324
  if (record.classUid === OCSF_NETWORK_ACTIVITY_CLASS_UID &&
177
325
  principalHasMachine &&
@@ -212,7 +360,7 @@ function additionalFields(record) {
212
360
  }
213
361
  function securityResult(record) {
214
362
  const result = {
215
- severity: UDM_SEVERITY[record.severityName] || "UNKNOWN_SEVERITY",
363
+ severity: UDM_SEVERITY.get(record.severityName) || "UNKNOWN_SEVERITY",
216
364
  summary: cut(record.ruleName || record.className || "Security event", 256),
217
365
  };
218
366
  if (record.message) {
@@ -224,7 +372,7 @@ function securityResult(record) {
224
372
  if (record.ruleId) {
225
373
  result["ruleId"] = cut(record.ruleId, 256);
226
374
  }
227
- const action = UDM_ACTION[record.statusName.trim().toLowerCase()];
375
+ const action = UDM_ACTION.get(record.statusName.trim().toLowerCase());
228
376
  if (action) {
229
377
  result["action"] = [action];
230
378
  }
@@ -264,24 +412,37 @@ function toUdmEvent(record, eventType = chooseUdmEventType(record)) {
264
412
  const targetResource = record.targetResource.trim();
265
413
  const isLogin = eventType === UdmEventType.UserLogin;
266
414
  const isProcessLaunch = eventType === UdmEventType.ProcessLaunch;
415
+ const isActedOn = ACTED_ON_PROCESS_TYPES.includes(eventType);
267
416
  /*
268
417
  * A login names the account on the target: OneUptime's sign-in events
269
418
  * keep it as the principal user (the one acting), UDM as the target user
270
419
  * (the one signed in to). The address it came from stays the principal.
271
- * A launched process is the target's process in UDM and the process that
272
- * started it the principal's; in any other event the process is the
273
- * principal's, with its parent.
420
+ *
421
+ * In a process event the principal's process is the one that acted and
422
+ * the target's the one acted on: in a launch, the parent and the process
423
+ * it launched; in an open, an injection or an end, principalProcess and
424
+ * the process opened, injected into or ended, with that process's own
425
+ * parent. In any other event the process is the principal's, with its
426
+ * parent.
274
427
  */
275
- const theProcess = eventProcess(record);
276
- const itsParent = parentProcess(record);
277
- if (!isProcessLaunch && theProcess && itsParent) {
278
- theProcess["parentProcess"] = itsParent;
428
+ let principalsProcess = null;
429
+ let targetsProcess = null;
430
+ if (isProcessLaunch) {
431
+ principalsProcess = parentProcess(record);
432
+ targetsProcess = eventProcess(record);
433
+ }
434
+ else if (isActedOn) {
435
+ principalsProcess = actingProcess(record);
436
+ targetsProcess = withParent(ownProcess(record), parentProcess(record));
437
+ }
438
+ else {
439
+ principalsProcess = withParent(eventProcess(record), parentProcess(record));
279
440
  }
280
441
  const principal = udmNoun({
281
442
  hostname: record.principalHost,
282
443
  ip: record.principalIp,
283
444
  user: isLogin ? "" : record.principalUser,
284
- process: isProcessLaunch ? itsParent : theProcess,
445
+ process: principalsProcess,
285
446
  });
286
447
  const target = udmNoun({
287
448
  hostname: record.targetHost,
@@ -289,17 +450,17 @@ function toUdmEvent(record, eventType = chooseUdmEventType(record)) {
289
450
  user: isLogin
290
451
  ? record.targetUser || record.principalUser
291
452
  : record.targetUser,
292
- process: isProcessLaunch ? theProcess : null,
453
+ process: targetsProcess,
293
454
  port: record.targetPort,
294
455
  url: targetResource && isUrl(targetResource) ? targetResource : "",
295
456
  resourceName: targetResource && !isUrl(targetResource) ? targetResource : "",
296
457
  });
297
458
  /*
298
- * A launched process runs on the principal's machine; UDM wants the
299
- * machine on the target's side of a PROCESS_LAUNCH too when the event
459
+ * The process acted on runs on the principal's machine; UDM wants the
460
+ * machine on the target's side of a process event too when the event
300
461
  * names no other target.
301
462
  */
302
- if (isProcessLaunch && !hasMachine(target)) {
463
+ if ((isProcessLaunch || isActedOn) && !hasMachine(target)) {
303
464
  if (principal["hostname"]) {
304
465
  target["hostname"] = principal["hostname"];
305
466
  }
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  const OcsfSeverity_1 = __importStar(require("../../Types/SecurityEvent/OcsfSeverity"));
37
37
  const OcsfEventClass_1 = require("../../Types/SecurityEvent/OcsfEventClass");
38
+ const OcsfProcessActivity_1 = require("../../Types/SecurityEvent/OcsfProcessActivity");
38
39
  const NormalizerHelpers_1 = require("./NormalizerHelpers");
39
40
  /*
40
41
  * Native OCSF event JSON -> NormalizedSecurityEvent.
@@ -47,8 +48,6 @@ const NormalizerHelpers_1 = require("./NormalizerHelpers");
47
48
  *
48
49
  * https://schema.ocsf.io/
49
50
  */
50
- const PROCESS_ACTIVITY_CLASS_UID = 1007;
51
- const LAUNCH_ACTIVITY_ID = 1;
52
51
  // An OCSF Process object at `at`: its name, its executable's path, its command line.
53
52
  function readOcsfProcess(payload, at) {
54
53
  return {
@@ -62,20 +61,30 @@ function readOcsfProcess(payload, at) {
62
61
  }
63
62
  /*
64
63
  * A Process Activity launch: activity_id 1, or no activity named at all,
65
- * since a launch is what nearly every process event is.
64
+ * since a launch is what nearly every process event is - the rule every
65
+ * reader of a process activity shares (getProcessActivityKind).
66
66
  */
67
67
  function isLaunch(payload, classUid) {
68
- if (classUid !== PROCESS_ACTIVITY_CLASS_UID) {
68
+ if (classUid !== OcsfProcessActivity_1.OCSF_PROCESS_ACTIVITY_CLASS_UID) {
69
69
  return false;
70
70
  }
71
- const activityId = (0, NormalizerHelpers_1.readNumber)(payload, "activity_id");
72
- if (activityId !== null) {
73
- return activityId === LAUNCH_ACTIVITY_ID;
71
+ return ((0, OcsfProcessActivity_1.getProcessActivityKind)({
72
+ activityId: (0, NormalizerHelpers_1.readNumber)(payload, "activity_id"),
73
+ activityName: (0, NormalizerHelpers_1.readString)(payload, "activity_name"),
74
+ }) === OcsfProcessActivity_1.ProcessActivityKind.Launch);
75
+ }
76
+ /*
77
+ * The activity's name: the payload's activity_name, or - for a Process
78
+ * Activity that gives only its activity_id - the name OCSF gives that id,
79
+ * so the event says it was an open or an injection wherever it is read
80
+ * (the event's panel, the Activity facet, a SIEM it is sent to).
81
+ */
82
+ function readActivityName(payload, classUid) {
83
+ const named = (0, NormalizerHelpers_1.readString)(payload, "activity_name");
84
+ if (named || classUid !== OcsfProcessActivity_1.OCSF_PROCESS_ACTIVITY_CLASS_UID) {
85
+ return named;
74
86
  }
75
- const activityName = (0, NormalizerHelpers_1.readString)(payload, "activity_name")
76
- .trim()
77
- .toLowerCase();
78
- return !activityName || activityName === "launch";
87
+ return (0, OcsfProcessActivity_1.ocsfProcessActivityName)((0, NormalizerHelpers_1.readNumber)(payload, "activity_id"));
79
88
  }
80
89
  /*
81
90
  * The process an event is about, and its parent. `process` is the process
@@ -98,7 +107,7 @@ function readOcsfProcesses(payload, classUid) {
98
107
  });
99
108
  }
100
109
  // A Process Activity event that does not name its process: the actor is never it.
101
- if (classUid === PROCESS_ACTIVITY_CLASS_UID) {
110
+ if (classUid === OcsfProcessActivity_1.OCSF_PROCESS_ACTIVITY_CLASS_UID) {
102
111
  return (0, NormalizerHelpers_1.buildProcessFields)({ parent: launch ? actor : undefined });
103
112
  }
104
113
  return (0, NormalizerHelpers_1.buildProcessFields)({
@@ -188,7 +197,7 @@ class OcsfNormalizer {
188
197
  return Object.assign(Object.assign({ time: time || new Date(), eventUid: (0, NormalizerHelpers_1.readString)(payload, "metadata.uid") || (0, NormalizerHelpers_1.contentHashEventUid)(payload), categoryUid,
189
198
  categoryName,
190
199
  classUid,
191
- className, activityName: (0, NormalizerHelpers_1.readString)(payload, "activity_name"), severityId: OcsfSeverity_1.OcsfSeverityId[severityName], severityName, statusName: (0, NormalizerHelpers_1.readString)(payload, "status") || (0, NormalizerHelpers_1.readString)(payload, "disposition"), message, vendorName: (0, NormalizerHelpers_1.readString)(payload, "metadata.product.vendor_name"), productName: (0, NormalizerHelpers_1.readString)(payload, "metadata.product.name"), ruleId: (0, NormalizerHelpers_1.readString)(payload, "metadata.rule.uid") ||
200
+ className, activityName: readActivityName(payload, classUid), severityId: OcsfSeverity_1.OcsfSeverityId[severityName], severityName, statusName: (0, NormalizerHelpers_1.readString)(payload, "status") || (0, NormalizerHelpers_1.readString)(payload, "disposition"), message, vendorName: (0, NormalizerHelpers_1.readString)(payload, "metadata.product.vendor_name"), productName: (0, NormalizerHelpers_1.readString)(payload, "metadata.product.name"), ruleId: (0, NormalizerHelpers_1.readString)(payload, "metadata.rule.uid") ||
192
201
  (0, NormalizerHelpers_1.readString)(payload, "finding_info.uid"), ruleName: (0, NormalizerHelpers_1.readString)(payload, "metadata.rule.name") ||
193
202
  (0, NormalizerHelpers_1.readString)(payload, "finding_info.title"), mitreTactics,
194
203
  mitreTechniques,
@@ -24,6 +24,7 @@
24
24
  */
25
25
  export type FormatDurationCompactFunction = (seconds: number) => string;
26
26
  export declare const formatDurationCompact: FormatDurationCompactFunction;
27
+ export declare const formatDurationCompactInLanguage: (seconds: number, language?: string | undefined) => string;
27
28
  /**
28
29
  * `errorBudgetRemainingSeconds` is SIGNED: negative means the budget is
29
30
  * overspent, and that overage is the single most useful number during a
@@ -24,6 +24,7 @@
24
24
  */
25
25
  export type FormatDurationCompactFunction = (seconds: number) => string;
26
26
  export declare const formatDurationCompact: FormatDurationCompactFunction;
27
+ export declare const formatDurationCompactInLanguage: (seconds: number, language?: string | undefined) => string;
27
28
  /**
28
29
  * `errorBudgetRemainingSeconds` is SIGNED: negative means the budget is
29
30
  * overspent, and that overage is the single most useful number during a
@@ -16,7 +16,8 @@
16
16
  * DOM.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.formatErrorBudgetRemainingOfTotal = exports.formatErrorBudgetRemaining = exports.formatDurationCompact = void 0;
19
+ exports.formatErrorBudgetRemainingOfTotal = exports.formatErrorBudgetRemaining = exports.formatDurationCompactInLanguage = exports.formatDurationCompact = void 0;
20
+ const DateLanguage_1 = require("../../Types/DateLanguage");
20
21
  /**
21
22
  * Seconds per unit, largest first. Only the two most significant non-zero
22
23
  * units are rendered: "2d 5h" is what an on-call engineer needs, "2d 5h
@@ -24,10 +25,10 @@ exports.formatErrorBudgetRemainingOfTotal = exports.formatErrorBudgetRemaining =
24
25
  * remaining budget from ever reading larger than it is.
25
26
  */
26
27
  const UNITS = [
27
- { suffix: "d", seconds: 86400 },
28
- { suffix: "h", seconds: 3600 },
29
- { suffix: "m", seconds: 60 },
30
- { suffix: "s", seconds: 1 },
28
+ { suffix: "d", seconds: 86400, unit: "day" },
29
+ { suffix: "h", seconds: 3600, unit: "hour" },
30
+ { suffix: "m", seconds: 60, unit: "minute" },
31
+ { suffix: "s", seconds: 1, unit: "second" },
31
32
  ];
32
33
  const MAX_UNITS_SHOWN = 2;
33
34
  const toFiniteNumber = (value) => {
@@ -36,7 +37,8 @@ const toFiniteNumber = (value) => {
36
37
  }
37
38
  return value;
38
39
  };
39
- const formatDurationCompact = (seconds) => {
40
+ // The units a compact duration names, with their counts: [2 d, 5 h].
41
+ const getCompactParts = (seconds) => {
40
42
  let remainingSeconds = Math.floor(Math.abs(seconds));
41
43
  const parts = [];
42
44
  for (const unit of UNITS) {
@@ -52,15 +54,62 @@ const formatDurationCompact = (seconds) => {
52
54
  if (count <= 0) {
53
55
  continue;
54
56
  }
55
- parts.push(`${count}${unit.suffix}`);
57
+ parts.push({ count: count, suffix: unit.suffix, unit: unit.unit });
56
58
  remainingSeconds -= count * unit.seconds;
57
59
  }
60
+ return parts;
61
+ };
62
+ const formatDurationCompact = (seconds) => {
63
+ const parts = getCompactParts(seconds);
58
64
  if (parts.length === 0) {
59
65
  return "0s";
60
66
  }
61
- return parts.join(" ");
67
+ return parts
68
+ .map((part) => {
69
+ return `${part.count}${part.suffix}`;
70
+ })
71
+ .join(" ");
62
72
  };
63
73
  exports.formatDurationCompact = formatDurationCompact;
74
+ /*
75
+ * formatDurationCompact in a reader's language, for a duration that goes
76
+ * into a translated sentence: "2 Std., 12 Min." in German, "3 h 12 min" in
77
+ * French, "3 ساعت 12 دقیقه" in Persian, "3小时12分钟" in Chinese - the same
78
+ * two largest units, each with the short name the language abbreviates it
79
+ * with (Intl, through Common/Types/DateLanguage). Not Intl's narrow names:
80
+ * those are Latin letters in some languages ("3h 12m" inside a Persian or a
81
+ * Japanese sentence) and a bare "T" for a German day.
82
+ *
83
+ * `language` is the sentence's language (a Translator's), or the date
84
+ * display language without one. English, and a language Intl cannot write,
85
+ * read exactly as formatDurationCompact. The text is remembered with its
86
+ * English, so a sentence the reader's language has not worded yet - read
87
+ * in English - puts "12m" back, never "12 Min." inside English words.
88
+ *
89
+ * formatDurationCompact itself stays English: the SLO pages still glue its
90
+ * text into English sentences of their own.
91
+ */
92
+ const formatDurationCompactInLanguage = (seconds, language) => {
93
+ const write = () => {
94
+ return (0, DateLanguage_1.writeInDateDisplayLanguage)(() => {
95
+ return (0, exports.formatDurationCompact)(seconds);
96
+ }, (_language, locale) => {
97
+ const parts = getCompactParts(seconds).map((part) => {
98
+ return { count: part.count, unit: part.unit };
99
+ });
100
+ return (0, DateLanguage_1.formatDurationText)({
101
+ parts: parts.length > 0 ? parts : [{ count: 0, unit: "second" }],
102
+ locale: locale,
103
+ unitDisplay: "short",
104
+ listStyle: "narrow",
105
+ });
106
+ });
107
+ };
108
+ return language === undefined
109
+ ? write()
110
+ : (0, DateLanguage_1.withDateDisplayLanguage)(language, write);
111
+ };
112
+ exports.formatDurationCompactInLanguage = formatDurationCompactInLanguage;
64
113
  const formatBudgetDuration = (seconds) => {
65
114
  return seconds !== 0 && Math.abs(seconds) < 1
66
115
  ? "under 1s"
@@ -1,4 +1,5 @@
1
1
  import commonJsModule from "./SloDuration.js";
2
2
  export const formatDurationCompact = commonJsModule.formatDurationCompact;
3
+ export const formatDurationCompactInLanguage = commonJsModule.formatDurationCompactInLanguage;
3
4
  export const formatErrorBudgetRemaining = commonJsModule.formatErrorBudgetRemaining;
4
5
  export const formatErrorBudgetRemainingOfTotal = commonJsModule.formatErrorBudgetRemainingOfTotal;
@@ -1,9 +1,24 @@
1
+ import AIRunStatus from "../../Types/AI/AIRunStatus.mjs";
2
+ import { CodeTaskStateInput } from "../../Types/AI/CodeTask.mjs";
1
3
  import SuggestionOffer from "./SuggestionOffer.mjs";
2
4
  export interface CodeFixSuggestionInput {
3
5
  isAiEnabled: boolean;
4
6
  applies: boolean;
5
7
  hasActiveFix: boolean;
8
+ hasFinishedFix?: boolean | undefined;
6
9
  hasConnectedRepository: boolean;
10
+ isBlocked?: boolean | undefined;
7
11
  isBackedByEvidence: boolean;
8
12
  }
9
13
  export declare function getCodeFixOffer(input: CodeFixSuggestionInput): SuggestionOffer;
14
+ export declare enum FinishedFixOutcome {
15
+ Fixed = "Fixed",
16
+ NothingToChange = "NothingToChange",
17
+ WaitingForYou = "WaitingForYou"
18
+ }
19
+ export declare function parseFinishedFixOutcome(value: unknown): FinishedFixOutcome | null;
20
+ export declare const FINISHED_FIX_STATUSES: ReadonlyArray<AIRunStatus>;
21
+ export declare function getFinishedFixOutcome(data: {
22
+ fix: CodeTaskStateInput;
23
+ latestTurn: CodeTaskStateInput;
24
+ }): FinishedFixOutcome | null;
@@ -1,9 +1,24 @@
1
+ import AIRunStatus from "../../Types/AI/AIRunStatus";
2
+ import { CodeTaskStateInput } from "../../Types/AI/CodeTask";
1
3
  import SuggestionOffer from "./SuggestionOffer";
2
4
  export interface CodeFixSuggestionInput {
3
5
  isAiEnabled: boolean;
4
6
  applies: boolean;
5
7
  hasActiveFix: boolean;
8
+ hasFinishedFix?: boolean | undefined;
6
9
  hasConnectedRepository: boolean;
10
+ isBlocked?: boolean | undefined;
7
11
  isBackedByEvidence: boolean;
8
12
  }
9
13
  export declare function getCodeFixOffer(input: CodeFixSuggestionInput): SuggestionOffer;
14
+ export declare enum FinishedFixOutcome {
15
+ Fixed = "Fixed",
16
+ NothingToChange = "NothingToChange",
17
+ WaitingForYou = "WaitingForYou"
18
+ }
19
+ export declare function parseFinishedFixOutcome(value: unknown): FinishedFixOutcome | null;
20
+ export declare const FINISHED_FIX_STATUSES: ReadonlyArray<AIRunStatus>;
21
+ export declare function getFinishedFixOutcome(data: {
22
+ fix: CodeTaskStateInput;
23
+ latestTurn: CodeTaskStateInput;
24
+ }): FinishedFixOutcome | null;