@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.
- package/Models/DatabaseModels/AutoRemediationRule.js +1 -1
- package/Models/DatabaseModels/CodeRepository.d.mts +1 -0
- package/Models/DatabaseModels/CodeRepository.d.ts +1 -0
- package/Models/DatabaseModels/CodeRepository.js +69 -6
- package/Types/AI/CodeTask.d.mts +1 -0
- package/Types/AI/CodeTask.d.ts +1 -0
- package/Types/AI/TelemetryAiActivity.d.mts +1 -0
- package/Types/AI/TelemetryAiActivity.d.ts +1 -0
- package/Types/AI/TelemetryAiActivity.js +4 -0
- package/Types/CodeRepository/CodeRepositorySetting.d.mts +15 -0
- package/Types/CodeRepository/CodeRepositorySetting.d.ts +15 -0
- package/Types/CodeRepository/CodeRepositorySetting.js +49 -0
- package/Types/CodeRepository/CodeRepositorySetting.mjs +3 -0
- package/Types/Date.d.mts +10 -0
- package/Types/Date.d.ts +10 -0
- package/Types/Date.js +385 -98
- package/Types/DateLanguage.d.mts +67 -0
- package/Types/DateLanguage.d.ts +67 -0
- package/Types/DateLanguage.js +478 -0
- package/Types/DateLanguage.mjs +21 -0
- package/Types/Runner/CodeRepositoryRunner.d.mts +7 -0
- package/Types/Runner/CodeRepositoryRunner.d.ts +7 -0
- package/Types/Runner/CodeRepositoryRunner.js +60 -14
- package/Types/Runner/CodeRepositoryRunner.mjs +1 -0
- package/Types/SecurityEvent/OcsfProcessActivity.d.mts +25 -0
- package/Types/SecurityEvent/OcsfProcessActivity.d.ts +25 -0
- package/Types/SecurityEvent/OcsfProcessActivity.js +131 -0
- package/Types/SecurityEvent/OcsfProcessActivity.mjs +8 -0
- package/UI/Utils/TranslateTemplate.d.mts +73 -0
- package/UI/Utils/TranslateTemplate.d.ts +73 -0
- package/Utils/CronTab.d.mts +41 -3
- package/Utils/CronTab.d.ts +41 -3
- package/Utils/CronTab.js +112 -38
- package/Utils/Monitor/MonitorOverviewTargetUtil.d.mts +2 -0
- package/Utils/Monitor/MonitorOverviewTargetUtil.d.ts +2 -0
- package/Utils/Monitor/MonitorOverviewTargetUtil.js +13 -2
- package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.d.mts +5 -0
- package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.d.ts +5 -0
- package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.js +219 -58
- package/Utils/SecurityEvent/OcsfNormalizer.js +22 -13
- package/Utils/Slo/SloDuration.d.mts +1 -0
- package/Utils/Slo/SloDuration.d.ts +1 -0
- package/Utils/Slo/SloDuration.js +57 -8
- package/Utils/Slo/SloDuration.mjs +1 -0
- package/Utils/Suggestions/CodeFixSuggestion.d.mts +15 -0
- package/Utils/Suggestions/CodeFixSuggestion.d.ts +15 -0
- package/Utils/Suggestions/CodeFixSuggestion.js +62 -1
- package/Utils/Suggestions/CodeFixSuggestion.mjs +4 -0
- package/Utils/Suggestions/ProfileFixSuggestion.js +4 -0
- package/Utils/Suggestions/SuggestionBlocker.d.mts +8 -0
- package/Utils/Suggestions/SuggestionBlocker.d.ts +8 -0
- package/Utils/Suggestions/SuggestionBlocker.js +51 -0
- package/Utils/Suggestions/SuggestionBlocker.mjs +4 -0
- package/Utils/Suggestions/SuggestionOffer.d.mts +2 -1
- package/Utils/Suggestions/SuggestionOffer.d.ts +2 -1
- package/Utils/Suggestions/SuggestionOffer.js +5 -0
- package/Utils/Suggestions/TelemetryAiFixSuggestion.d.mts +2 -7
- package/Utils/Suggestions/TelemetryAiFixSuggestion.d.ts +2 -7
- package/Utils/Suggestions/TelemetryAiFixSuggestion.js +8 -36
- package/Utils/Suggestions/TelemetryImprovementSuggestion.d.mts +1 -0
- package/Utils/Suggestions/TelemetryImprovementSuggestion.d.ts +1 -0
- package/Utils/Suggestions/TelemetryImprovementSuggestion.js +1 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.d.mts +6 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.d.ts +6 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.js +46 -5
- package/package.json +8 -1
- package/Utils/Monitor/MonitorCheckScheduleUtil.d.mts +0 -61
- package/Utils/Monitor/MonitorCheckScheduleUtil.d.ts +0 -61
- package/Utils/Monitor/MonitorCheckScheduleUtil.js +0 -476
- package/Utils/Monitor/MonitorCheckScheduleUtil.mjs +0 -3
- package/Utils/Monitor/MonitorOverviewFamily.d.mts +0 -39
- package/Utils/Monitor/MonitorOverviewFamily.d.ts +0 -39
- package/Utils/Monitor/MonitorOverviewFamily.js +0 -206
- package/Utils/Monitor/MonitorOverviewFamily.mjs +0 -4
- package/Utils/Monitor/MonitorOverviewPresentationUtil.d.mts +0 -189
- package/Utils/Monitor/MonitorOverviewPresentationUtil.d.ts +0 -189
- package/Utils/Monitor/MonitorOverviewPresentationUtil.js +0 -1480
- package/Utils/Monitor/MonitorOverviewPresentationUtil.mjs +0 -5
- package/Utils/Monitor/MonitorOverviewProbeUtil.d.mts +0 -112
- package/Utils/Monitor/MonitorOverviewProbeUtil.d.ts +0 -112
- package/Utils/Monitor/MonitorOverviewProbeUtil.js +0 -640
- package/Utils/Monitor/MonitorOverviewProbeUtil.mjs +0 -3
- package/Utils/Monitor/MonitorStatusHistoryUtil.d.mts +0 -27
- package/Utils/Monitor/MonitorStatusHistoryUtil.d.ts +0 -27
- package/Utils/Monitor/MonitorStatusHistoryUtil.js +0 -132
- package/Utils/Monitor/MonitorStatusHistoryUtil.mjs +0 -2
- package/Utils/Monitor/MonitorUptimeSummaryUtil.d.mts +0 -42
- package/Utils/Monitor/MonitorUptimeSummaryUtil.d.ts +0 -42
- package/Utils/Monitor/MonitorUptimeSummaryUtil.js +0 -468
- 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
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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
|
|
48
|
-
Informational
|
|
49
|
-
Low
|
|
50
|
-
Medium
|
|
51
|
-
High
|
|
52
|
-
Critical
|
|
53
|
-
Fatal
|
|
54
|
-
Other
|
|
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
|
|
59
|
-
allowed
|
|
60
|
-
failure
|
|
61
|
-
blocked
|
|
62
|
-
denied
|
|
63
|
-
quarantined
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
102
|
-
|
|
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
|
-
*
|
|
108
|
-
*
|
|
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
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
193
|
+
commandLine: record.processCommandLine,
|
|
194
|
+
});
|
|
115
195
|
}
|
|
116
196
|
function parentProcess(record) {
|
|
117
197
|
return udmProcess({
|
|
118
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
if (
|
|
278
|
-
|
|
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:
|
|
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:
|
|
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
|
-
*
|
|
299
|
-
* machine on the target's side of a
|
|
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 !==
|
|
68
|
+
if (classUid !== OcsfProcessActivity_1.OCSF_PROCESS_ACTIVITY_CLASS_UID) {
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
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 ===
|
|
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: (
|
|
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
|
package/Utils/Slo/SloDuration.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
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
|
|
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;
|