@oneuptime/common 14.0.95 → 14.0.96
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/DatabaseBaseModel/DatabaseBaseModel.js +14 -37
- package/Models/DatabaseModels/DetectionRuleException.d.mts +25 -0
- package/Models/DatabaseModels/DetectionRuleException.d.ts +25 -0
- package/Models/DatabaseModels/DetectionRuleException.js +412 -0
- package/Models/DatabaseModels/DetectionRuleException.mjs +2 -0
- package/Models/DatabaseModels/Index.js +2 -0
- package/Types/Database/TableColumn.d.mts +8 -0
- package/Types/Database/TableColumn.d.ts +8 -0
- package/Types/Database/TableColumn.js +69 -23
- package/Types/Database/TableColumn.mjs +1 -0
- package/Types/JSONFunctions.js +16 -1
- package/Types/Monitor/MonitorType.js +5 -4
- package/Types/Monitor/TelemetryAlertRule.d.mts +111 -0
- package/Types/Monitor/TelemetryAlertRule.d.ts +111 -0
- package/Types/Monitor/TelemetryAlertRule.js +886 -0
- package/Types/Monitor/TelemetryAlertRule.mjs +5 -0
- package/Types/Monitor/TelemetryRulePreview.d.mts +57 -0
- package/Types/Monitor/TelemetryRulePreview.d.ts +57 -0
- package/Types/Monitor/TelemetryRulePreview.js +190 -0
- package/Types/Monitor/TelemetryRulePreview.mjs +6 -0
- package/Types/OnCallDutyPolicy/EveryNewEventRules.d.mts +23 -0
- package/Types/OnCallDutyPolicy/EveryNewEventRules.d.ts +23 -0
- package/Types/OnCallDutyPolicy/EveryNewEventRules.js +105 -0
- package/Types/OnCallDutyPolicy/EveryNewEventRules.mjs +9 -0
- package/Types/ProviderLogo/ProviderLogo.d.mts +17 -1
- package/Types/ProviderLogo/ProviderLogo.d.ts +17 -1
- package/Types/ProviderLogo/ProviderLogo.js +33 -0
- package/Types/SecurityEvent/DetectionRetrohunt.d.mts +38 -0
- package/Types/SecurityEvent/DetectionRetrohunt.d.ts +38 -0
- package/Types/SecurityEvent/DetectionRetrohunt.js +147 -0
- package/Types/SecurityEvent/DetectionRetrohunt.mjs +10 -0
- package/Types/SecurityEvent/DetectionRuleException.d.mts +65 -0
- package/Types/SecurityEvent/DetectionRuleException.d.ts +65 -0
- package/Types/SecurityEvent/DetectionRuleException.js +441 -0
- package/Types/SecurityEvent/DetectionRuleException.mjs +24 -0
- package/Types/Telemetry/OpenTelemetryGuides.d.mts +52 -0
- package/Types/Telemetry/OpenTelemetryGuides.d.ts +52 -0
- package/Types/Telemetry/OpenTelemetryGuides.js +419 -0
- package/Types/Telemetry/OpenTelemetryGuides.mjs +17 -0
- package/Utils/Schema/OpenApiMetadataRegistry.d.mts +4 -0
- package/Utils/Schema/OpenApiMetadataRegistry.d.ts +4 -0
- package/Utils/Schema/OpenApiMetadataRegistry.js +20 -0
- package/Utils/Schema/OpenApiMetadataRegistry.mjs +2 -0
- package/Utils/Schema/Zod.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DetectionRuleExceptionStatus = exports.DETECTION_RULE_EXCEPTION_WILDCARD = exports.DETECTION_RULE_EXCEPTIONS_PER_RULE_MAX = exports.DETECTION_RULE_EXCEPTION_WINDOW_MAX_IN_DAYS = exports.DETECTION_RULE_EXCEPTION_REASON_MAX_LENGTH = exports.DETECTION_RULE_EXCEPTION_FIELD_MAX_LENGTH = exports.DETECTION_RULE_EXCEPTION_VALUE_MAX_LENGTH = exports.DETECTION_RULE_EXCEPTION_ENTITY_FIELDS = exports.DETECTION_RULE_EXCEPTION_ENTITY_TYPES = exports.DETECTION_RULE_EXCEPTION_KINDS = exports.DetectionRuleExceptionKind = void 0;
|
|
4
|
+
exports.isDetectionRuleExceptionKind = isDetectionRuleExceptionKind;
|
|
5
|
+
exports.isDetectionRuleExceptionEntityType = isDetectionRuleExceptionEntityType;
|
|
6
|
+
exports.readDetectionRuleExceptionDate = readDetectionRuleExceptionDate;
|
|
7
|
+
exports.normalizeDetectionRuleExceptionValue = normalizeDetectionRuleExceptionValue;
|
|
8
|
+
exports.normalizeDetectionRuleExceptionField = normalizeDetectionRuleExceptionField;
|
|
9
|
+
exports.isDetectionRuleExceptionCidr = isDetectionRuleExceptionCidr;
|
|
10
|
+
exports.getDetectionRuleExceptionStatus = getDetectionRuleExceptionStatus;
|
|
11
|
+
exports.doesDetectionRuleExceptionApply = doesDetectionRuleExceptionApply;
|
|
12
|
+
exports.getDetectionRuleExceptionProblems = getDetectionRuleExceptionProblems;
|
|
13
|
+
exports.getDetectionRuleExceptionFieldProblem = getDetectionRuleExceptionFieldProblem;
|
|
14
|
+
exports.getDetectionRuleExceptionProblem = getDetectionRuleExceptionProblem;
|
|
15
|
+
exports.getDetectionRuleExceptionColumns = getDetectionRuleExceptionColumns;
|
|
16
|
+
const SecurityEntity_1 = require("../SecurityCase/SecurityEntity");
|
|
17
|
+
/*
|
|
18
|
+
* DETECTION RULE EXCEPTIONS: WHAT A DETECTION RULE SKIPS.
|
|
19
|
+
*
|
|
20
|
+
* A rule that fires on something expected - the vulnerability scanner, the
|
|
21
|
+
* nightly backup job, a planned penetration test - is tuned with an
|
|
22
|
+
* exception rather than turned off or rewritten. An exception names one
|
|
23
|
+
* thing the rule skips:
|
|
24
|
+
*
|
|
25
|
+
* - an entity: a user, a host or an IP address, wherever an event names
|
|
26
|
+
* it (as who acted, as who was acted on, or among its observables);
|
|
27
|
+
* - a value: one event field's value, such as processName backup.exe;
|
|
28
|
+
* - a time window: every event between two times.
|
|
29
|
+
*
|
|
30
|
+
* Each says why it is safe to skip (its reason), and who added it and when
|
|
31
|
+
* are kept with it. An entity or a value can expire: after its expiry the
|
|
32
|
+
* rule sees it again. A time window ends by itself, so it has no expiry.
|
|
33
|
+
*
|
|
34
|
+
* Values are matched whatever the case, and * stands for any run of
|
|
35
|
+
* characters, as Protected Entities and Entity Criticality match theirs:
|
|
36
|
+
* svc-* skips every service account, *.corp.example.com every host of a
|
|
37
|
+
* domain. An IP address may also be a range: 10.20.0.0/16.
|
|
38
|
+
*
|
|
39
|
+
* Skipped events are left out before the rule counts anything: they never
|
|
40
|
+
* reach its Match Count Threshold, open nothing and add no risk. Exceptions
|
|
41
|
+
* apply to the rule's scheduled runs and to its runs on past events, and
|
|
42
|
+
* never to a test attack (Send a test attack checks that the pipeline
|
|
43
|
+
* works, and must not be hidden by them).
|
|
44
|
+
*
|
|
45
|
+
* Kept free of anything server-side: the Dashboard's form and list read the
|
|
46
|
+
* same rules the server enforces.
|
|
47
|
+
*/
|
|
48
|
+
var DetectionRuleExceptionKind;
|
|
49
|
+
(function (DetectionRuleExceptionKind) {
|
|
50
|
+
DetectionRuleExceptionKind["Entity"] = "Entity";
|
|
51
|
+
DetectionRuleExceptionKind["Value"] = "Value";
|
|
52
|
+
DetectionRuleExceptionKind["TimeWindow"] = "Time Window";
|
|
53
|
+
})(DetectionRuleExceptionKind || (exports.DetectionRuleExceptionKind = DetectionRuleExceptionKind = {}));
|
|
54
|
+
// The kinds, in the order the form offers them.
|
|
55
|
+
exports.DETECTION_RULE_EXCEPTION_KINDS = [
|
|
56
|
+
DetectionRuleExceptionKind.Entity,
|
|
57
|
+
DetectionRuleExceptionKind.Value,
|
|
58
|
+
DetectionRuleExceptionKind.TimeWindow,
|
|
59
|
+
];
|
|
60
|
+
/*
|
|
61
|
+
* Who an entity exception can name: the users, hosts and addresses a
|
|
62
|
+
* detection is about. Domains, URLs and hashes are threat intel's to judge;
|
|
63
|
+
* a value exception skips one of them in a field when it must.
|
|
64
|
+
*/
|
|
65
|
+
exports.DETECTION_RULE_EXCEPTION_ENTITY_TYPES = [
|
|
66
|
+
SecurityEntity_1.SecurityEntityType.User,
|
|
67
|
+
SecurityEntity_1.SecurityEntityType.Host,
|
|
68
|
+
SecurityEntity_1.SecurityEntityType.IpAddress,
|
|
69
|
+
];
|
|
70
|
+
/*
|
|
71
|
+
* The event fields an entity of each kind is read from, beside the event's
|
|
72
|
+
* observables: as who acted, and as who was acted on.
|
|
73
|
+
*/
|
|
74
|
+
exports.DETECTION_RULE_EXCEPTION_ENTITY_FIELDS = {
|
|
75
|
+
[SecurityEntity_1.SecurityEntityType.User]: ["principalUser", "targetUser"],
|
|
76
|
+
[SecurityEntity_1.SecurityEntityType.Host]: ["principalHost", "targetHost"],
|
|
77
|
+
[SecurityEntity_1.SecurityEntityType.IpAddress]: ["principalIp", "targetIp"],
|
|
78
|
+
};
|
|
79
|
+
exports.DETECTION_RULE_EXCEPTION_VALUE_MAX_LENGTH = 500;
|
|
80
|
+
exports.DETECTION_RULE_EXCEPTION_FIELD_MAX_LENGTH = 100;
|
|
81
|
+
exports.DETECTION_RULE_EXCEPTION_REASON_MAX_LENGTH = 500;
|
|
82
|
+
/*
|
|
83
|
+
* The longest time window: a window hides everything the rule would see in
|
|
84
|
+
* it, so it is for a planned change or test, not a way to switch a rule off
|
|
85
|
+
* (which the rule's Enabled switch says plainly).
|
|
86
|
+
*/
|
|
87
|
+
exports.DETECTION_RULE_EXCEPTION_WINDOW_MAX_IN_DAYS = 30;
|
|
88
|
+
/*
|
|
89
|
+
* The most exceptions one rule keeps. Every one is a condition on every
|
|
90
|
+
* event the rule reads, so the list stays short enough to read - and to
|
|
91
|
+
* review.
|
|
92
|
+
*/
|
|
93
|
+
exports.DETECTION_RULE_EXCEPTIONS_PER_RULE_MAX = 100;
|
|
94
|
+
exports.DETECTION_RULE_EXCEPTION_WILDCARD = "*";
|
|
95
|
+
// A CIDR prefix length: one to three digits.
|
|
96
|
+
const CIDR_PREFIX_REGEX = /^\d{1,3}$/;
|
|
97
|
+
// Any whitespace: a field name has none.
|
|
98
|
+
const WHITESPACE_REGEX = /\s/;
|
|
99
|
+
// Where an exception stands now, as its list shows it.
|
|
100
|
+
var DetectionRuleExceptionStatus;
|
|
101
|
+
(function (DetectionRuleExceptionStatus) {
|
|
102
|
+
// Skipping: an entity or a value with no expiry or one still ahead, or a window under way.
|
|
103
|
+
DetectionRuleExceptionStatus["Active"] = "Active";
|
|
104
|
+
// An entity or a value past its expiry: the rule sees it again.
|
|
105
|
+
DetectionRuleExceptionStatus["Expired"] = "Expired";
|
|
106
|
+
// A window that has not started yet.
|
|
107
|
+
DetectionRuleExceptionStatus["Upcoming"] = "Upcoming";
|
|
108
|
+
// A window that is over.
|
|
109
|
+
DetectionRuleExceptionStatus["Ended"] = "Ended";
|
|
110
|
+
})(DetectionRuleExceptionStatus || (exports.DetectionRuleExceptionStatus = DetectionRuleExceptionStatus = {}));
|
|
111
|
+
function isDetectionRuleExceptionKind(value) {
|
|
112
|
+
return (typeof value === "string" &&
|
|
113
|
+
exports.DETECTION_RULE_EXCEPTION_KINDS.includes(value));
|
|
114
|
+
}
|
|
115
|
+
function isDetectionRuleExceptionEntityType(value) {
|
|
116
|
+
return (typeof value === "string" &&
|
|
117
|
+
exports.DETECTION_RULE_EXCEPTION_ENTITY_TYPES.includes(value));
|
|
118
|
+
}
|
|
119
|
+
// A date from a row or a form: a Date, or text one parses from; null for anything else.
|
|
120
|
+
function readDetectionRuleExceptionDate(value) {
|
|
121
|
+
if (value instanceof Date) {
|
|
122
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
123
|
+
}
|
|
124
|
+
if (typeof value === "string" && value.trim()) {
|
|
125
|
+
const date = new Date(value);
|
|
126
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
// A value or pattern as stored: trimmed, with no run of wildcards.
|
|
131
|
+
function normalizeDetectionRuleExceptionValue(value) {
|
|
132
|
+
if (typeof value !== "string") {
|
|
133
|
+
return "";
|
|
134
|
+
}
|
|
135
|
+
let text = value.trim();
|
|
136
|
+
while (text.includes("**")) {
|
|
137
|
+
text = text.split("**").join("*");
|
|
138
|
+
}
|
|
139
|
+
return text;
|
|
140
|
+
}
|
|
141
|
+
// A field name as stored: trimmed.
|
|
142
|
+
function normalizeDetectionRuleExceptionField(value) {
|
|
143
|
+
return typeof value === "string" ? value.trim() : "";
|
|
144
|
+
}
|
|
145
|
+
/*
|
|
146
|
+
* Whether the text is an address range written as CIDR: an IPv4 or IPv6
|
|
147
|
+
* address, a slash and a prefix length the address can have (0-32, 0-128).
|
|
148
|
+
*/
|
|
149
|
+
function isDetectionRuleExceptionCidr(value) {
|
|
150
|
+
const text = (value || "").trim();
|
|
151
|
+
const slash = text.indexOf("/");
|
|
152
|
+
if (slash <= 0 || slash !== text.lastIndexOf("/")) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
const address = text.slice(0, slash);
|
|
156
|
+
const prefix = text.slice(slash + 1);
|
|
157
|
+
if (!CIDR_PREFIX_REGEX.test(prefix) || !(0, SecurityEntity_1.isIpAddress)(address)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const length = Number(prefix);
|
|
161
|
+
const maximum = address.includes(":") ? 128 : 32;
|
|
162
|
+
return length >= 0 && length <= maximum;
|
|
163
|
+
}
|
|
164
|
+
/*
|
|
165
|
+
* Where the exception stands at `now`. A window is judged by its own times;
|
|
166
|
+
* an entity or a value by its expiry, and with none it is active for good.
|
|
167
|
+
*/
|
|
168
|
+
function getDetectionRuleExceptionStatus(exception, now) {
|
|
169
|
+
if (exception.kind === DetectionRuleExceptionKind.TimeWindow) {
|
|
170
|
+
const startsAt = readDetectionRuleExceptionDate(exception.startsAt);
|
|
171
|
+
const endsAt = readDetectionRuleExceptionDate(exception.endsAt);
|
|
172
|
+
if (endsAt && endsAt.getTime() <= now.getTime()) {
|
|
173
|
+
return DetectionRuleExceptionStatus.Ended;
|
|
174
|
+
}
|
|
175
|
+
if (startsAt && startsAt.getTime() > now.getTime()) {
|
|
176
|
+
return DetectionRuleExceptionStatus.Upcoming;
|
|
177
|
+
}
|
|
178
|
+
return DetectionRuleExceptionStatus.Active;
|
|
179
|
+
}
|
|
180
|
+
const expiresAt = readDetectionRuleExceptionDate(exception.expiresAt);
|
|
181
|
+
if (expiresAt && expiresAt.getTime() <= now.getTime()) {
|
|
182
|
+
return DetectionRuleExceptionStatus.Expired;
|
|
183
|
+
}
|
|
184
|
+
return DetectionRuleExceptionStatus.Active;
|
|
185
|
+
}
|
|
186
|
+
/*
|
|
187
|
+
* Whether the exception takes part in a read of the events from `from` to
|
|
188
|
+
* `until`, made at `now`: an entity or a value that has not expired by now
|
|
189
|
+
* (an expired one is kept on the list, and skips nothing); a window that
|
|
190
|
+
* overlaps the read, whenever that is - a window is about the events in it,
|
|
191
|
+
* so a run on past events skips last week's planned test too.
|
|
192
|
+
*/
|
|
193
|
+
function doesDetectionRuleExceptionApply(exception, read) {
|
|
194
|
+
if (!isDetectionRuleExceptionKind(exception.kind)) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
if (exception.kind === DetectionRuleExceptionKind.TimeWindow) {
|
|
198
|
+
const startsAt = readDetectionRuleExceptionDate(exception.startsAt);
|
|
199
|
+
const endsAt = readDetectionRuleExceptionDate(exception.endsAt);
|
|
200
|
+
if (!startsAt || !endsAt || endsAt.getTime() <= startsAt.getTime()) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
return (startsAt.getTime() < read.until.getTime() &&
|
|
204
|
+
endsAt.getTime() > read.from.getTime());
|
|
205
|
+
}
|
|
206
|
+
return (getDetectionRuleExceptionStatus(exception, read.now) ===
|
|
207
|
+
DetectionRuleExceptionStatus.Active);
|
|
208
|
+
}
|
|
209
|
+
// A value's problems: missing, a lone * (which would skip everything), or too long.
|
|
210
|
+
function getValueProblems(value, missing) {
|
|
211
|
+
const text = normalizeDetectionRuleExceptionValue(value);
|
|
212
|
+
if (text === exports.DETECTION_RULE_EXCEPTION_WILDCARD) {
|
|
213
|
+
return [
|
|
214
|
+
{
|
|
215
|
+
field: "value",
|
|
216
|
+
message: "A value of only * would skip everything. To stop the rule, turn it off.",
|
|
217
|
+
},
|
|
218
|
+
];
|
|
219
|
+
}
|
|
220
|
+
if (!text) {
|
|
221
|
+
return [missing];
|
|
222
|
+
}
|
|
223
|
+
if (text.length > exports.DETECTION_RULE_EXCEPTION_VALUE_MAX_LENGTH) {
|
|
224
|
+
return [
|
|
225
|
+
{
|
|
226
|
+
field: "value",
|
|
227
|
+
message: "A value is at most 500 characters.",
|
|
228
|
+
},
|
|
229
|
+
];
|
|
230
|
+
}
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
function getEntityProblems(exception) {
|
|
234
|
+
const problems = [];
|
|
235
|
+
if (!isDetectionRuleExceptionEntityType(exception.entityType)) {
|
|
236
|
+
problems.push({
|
|
237
|
+
field: "entityType",
|
|
238
|
+
message: "Choose the kind of entity: a user, a host or an IP address.",
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const valueProblems = getValueProblems(exception.value, {
|
|
242
|
+
field: "value",
|
|
243
|
+
message: "Enter the user, host or address the rule skips.",
|
|
244
|
+
});
|
|
245
|
+
if (valueProblems.length > 0) {
|
|
246
|
+
return [...problems, ...valueProblems];
|
|
247
|
+
}
|
|
248
|
+
const value = normalizeDetectionRuleExceptionValue(exception.value);
|
|
249
|
+
// An address with a slash is a range, and must be one.
|
|
250
|
+
if (exception.entityType === SecurityEntity_1.SecurityEntityType.IpAddress &&
|
|
251
|
+
value.includes("/") &&
|
|
252
|
+
!isDetectionRuleExceptionCidr(value)) {
|
|
253
|
+
problems.push({
|
|
254
|
+
field: "value",
|
|
255
|
+
message: "Enter an address, a range such as 10.20.0.0/16, or a pattern with *.",
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
return problems;
|
|
259
|
+
}
|
|
260
|
+
function getValueKindProblems(exception) {
|
|
261
|
+
const problems = [];
|
|
262
|
+
const field = normalizeDetectionRuleExceptionField(exception.fieldName);
|
|
263
|
+
if (!field) {
|
|
264
|
+
problems.push({
|
|
265
|
+
field: "fieldName",
|
|
266
|
+
message: "Enter the event field to match, such as processName.",
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
else if (field.length > exports.DETECTION_RULE_EXCEPTION_FIELD_MAX_LENGTH) {
|
|
270
|
+
problems.push({
|
|
271
|
+
field: "fieldName",
|
|
272
|
+
message: "A field name is at most 100 characters.",
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
else if (WHITESPACE_REGEX.test(field)) {
|
|
276
|
+
problems.push({
|
|
277
|
+
field: "fieldName",
|
|
278
|
+
message: "A field name has no spaces: principalUser, processName or an attribute key such as http.user_agent.",
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
return [
|
|
282
|
+
...problems,
|
|
283
|
+
...getValueProblems(exception.value, {
|
|
284
|
+
field: "value",
|
|
285
|
+
message: "Enter the value the rule skips.",
|
|
286
|
+
}),
|
|
287
|
+
];
|
|
288
|
+
}
|
|
289
|
+
function getWindowProblems(exception) {
|
|
290
|
+
const startsAt = readDetectionRuleExceptionDate(exception.startsAt);
|
|
291
|
+
const endsAt = readDetectionRuleExceptionDate(exception.endsAt);
|
|
292
|
+
const problems = [];
|
|
293
|
+
if (!startsAt) {
|
|
294
|
+
problems.push({
|
|
295
|
+
field: "startsAt",
|
|
296
|
+
message: "Enter when the window starts.",
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
if (!endsAt) {
|
|
300
|
+
problems.push({
|
|
301
|
+
field: "endsAt",
|
|
302
|
+
message: "Enter when the window ends.",
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
if (!startsAt || !endsAt) {
|
|
306
|
+
return problems;
|
|
307
|
+
}
|
|
308
|
+
if (endsAt.getTime() <= startsAt.getTime()) {
|
|
309
|
+
return [
|
|
310
|
+
{
|
|
311
|
+
field: "endsAt",
|
|
312
|
+
message: "The window must end after it starts.",
|
|
313
|
+
},
|
|
314
|
+
];
|
|
315
|
+
}
|
|
316
|
+
if (endsAt.getTime() - startsAt.getTime() >
|
|
317
|
+
exports.DETECTION_RULE_EXCEPTION_WINDOW_MAX_IN_DAYS * 24 * 60 * 60 * 1000) {
|
|
318
|
+
return [
|
|
319
|
+
{
|
|
320
|
+
field: "endsAt",
|
|
321
|
+
message: "A window is at most 30 days. To stop a rule for longer, turn it off.",
|
|
322
|
+
},
|
|
323
|
+
];
|
|
324
|
+
}
|
|
325
|
+
return [];
|
|
326
|
+
}
|
|
327
|
+
function getExpiryProblems(exception, options) {
|
|
328
|
+
if (!options.isExpiryNew) {
|
|
329
|
+
return [];
|
|
330
|
+
}
|
|
331
|
+
const expiresAt = readDetectionRuleExceptionDate(exception.expiresAt);
|
|
332
|
+
if (exception.expiresAt && !expiresAt) {
|
|
333
|
+
return [
|
|
334
|
+
{
|
|
335
|
+
field: "expiresAt",
|
|
336
|
+
message: "Enter when the exception expires, or leave it empty.",
|
|
337
|
+
},
|
|
338
|
+
];
|
|
339
|
+
}
|
|
340
|
+
if (expiresAt && expiresAt.getTime() <= options.now.getTime()) {
|
|
341
|
+
return [
|
|
342
|
+
{
|
|
343
|
+
field: "expiresAt",
|
|
344
|
+
message: "An exception expires in the future. To stop one now, delete it.",
|
|
345
|
+
},
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
return [];
|
|
349
|
+
}
|
|
350
|
+
function getReasonProblems(exception) {
|
|
351
|
+
const reason = typeof exception.reason === "string" ? exception.reason.trim() : "";
|
|
352
|
+
if (!reason) {
|
|
353
|
+
return [
|
|
354
|
+
{
|
|
355
|
+
field: "reason",
|
|
356
|
+
message: "Say why it is safe for the rule to skip this.",
|
|
357
|
+
},
|
|
358
|
+
];
|
|
359
|
+
}
|
|
360
|
+
if (reason.length > exports.DETECTION_RULE_EXCEPTION_REASON_MAX_LENGTH) {
|
|
361
|
+
return [
|
|
362
|
+
{
|
|
363
|
+
field: "reason",
|
|
364
|
+
message: "A reason is at most 500 characters.",
|
|
365
|
+
},
|
|
366
|
+
];
|
|
367
|
+
}
|
|
368
|
+
return [];
|
|
369
|
+
}
|
|
370
|
+
/*
|
|
371
|
+
* Every problem with the exception, in the order the form asks for its
|
|
372
|
+
* fields; empty when it can be saved.
|
|
373
|
+
*/
|
|
374
|
+
function getDetectionRuleExceptionProblems(exception, options) {
|
|
375
|
+
if (!isDetectionRuleExceptionKind(exception.kind)) {
|
|
376
|
+
return [
|
|
377
|
+
{
|
|
378
|
+
field: "kind",
|
|
379
|
+
message: "Choose what the rule skips: an entity, a value or a time window.",
|
|
380
|
+
},
|
|
381
|
+
...getReasonProblems(exception),
|
|
382
|
+
];
|
|
383
|
+
}
|
|
384
|
+
switch (exception.kind) {
|
|
385
|
+
case DetectionRuleExceptionKind.Entity:
|
|
386
|
+
return [
|
|
387
|
+
...getEntityProblems(exception),
|
|
388
|
+
...getExpiryProblems(exception, options),
|
|
389
|
+
...getReasonProblems(exception),
|
|
390
|
+
];
|
|
391
|
+
case DetectionRuleExceptionKind.Value:
|
|
392
|
+
return [
|
|
393
|
+
...getValueKindProblems(exception),
|
|
394
|
+
...getExpiryProblems(exception, options),
|
|
395
|
+
...getReasonProblems(exception),
|
|
396
|
+
];
|
|
397
|
+
default:
|
|
398
|
+
// A window ends by itself: it has no expiry to check.
|
|
399
|
+
return [...getWindowProblems(exception), ...getReasonProblems(exception)];
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
// The first problem with one form field, or null: what the form shows under it.
|
|
403
|
+
function getDetectionRuleExceptionFieldProblem(exception, field, options) {
|
|
404
|
+
const problem = getDetectionRuleExceptionProblems(exception, options).find((item) => {
|
|
405
|
+
return item.field === field;
|
|
406
|
+
});
|
|
407
|
+
return problem ? problem.message : null;
|
|
408
|
+
}
|
|
409
|
+
// The first problem, or null when the exception can be saved: what the API answers.
|
|
410
|
+
function getDetectionRuleExceptionProblem(exception, options) {
|
|
411
|
+
const problems = getDetectionRuleExceptionProblems(exception, options);
|
|
412
|
+
return problems.length > 0 ? problems[0].message : null;
|
|
413
|
+
}
|
|
414
|
+
function getDetectionRuleExceptionColumns(exception) {
|
|
415
|
+
const reason = typeof exception.reason === "string" ? exception.reason.trim() : "";
|
|
416
|
+
if (exception.kind === DetectionRuleExceptionKind.TimeWindow) {
|
|
417
|
+
return {
|
|
418
|
+
entityType: null,
|
|
419
|
+
fieldName: null,
|
|
420
|
+
value: null,
|
|
421
|
+
startsAt: readDetectionRuleExceptionDate(exception.startsAt),
|
|
422
|
+
endsAt: readDetectionRuleExceptionDate(exception.endsAt),
|
|
423
|
+
expiresAt: null,
|
|
424
|
+
reason,
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
const isEntity = exception.kind === DetectionRuleExceptionKind.Entity;
|
|
428
|
+
return {
|
|
429
|
+
entityType: isEntity && isDetectionRuleExceptionEntityType(exception.entityType)
|
|
430
|
+
? exception.entityType
|
|
431
|
+
: null,
|
|
432
|
+
fieldName: isEntity
|
|
433
|
+
? null
|
|
434
|
+
: normalizeDetectionRuleExceptionField(exception.fieldName) || null,
|
|
435
|
+
value: normalizeDetectionRuleExceptionValue(exception.value) || null,
|
|
436
|
+
startsAt: null,
|
|
437
|
+
endsAt: null,
|
|
438
|
+
expiresAt: readDetectionRuleExceptionDate(exception.expiresAt),
|
|
439
|
+
reason,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import commonJsModule from "./DetectionRuleException.js";
|
|
2
|
+
export const DETECTION_RULE_EXCEPTIONS_PER_RULE_MAX = commonJsModule.DETECTION_RULE_EXCEPTIONS_PER_RULE_MAX;
|
|
3
|
+
export const DETECTION_RULE_EXCEPTION_ENTITY_FIELDS = commonJsModule.DETECTION_RULE_EXCEPTION_ENTITY_FIELDS;
|
|
4
|
+
export const DETECTION_RULE_EXCEPTION_ENTITY_TYPES = commonJsModule.DETECTION_RULE_EXCEPTION_ENTITY_TYPES;
|
|
5
|
+
export const DETECTION_RULE_EXCEPTION_FIELD_MAX_LENGTH = commonJsModule.DETECTION_RULE_EXCEPTION_FIELD_MAX_LENGTH;
|
|
6
|
+
export const DETECTION_RULE_EXCEPTION_KINDS = commonJsModule.DETECTION_RULE_EXCEPTION_KINDS;
|
|
7
|
+
export const DETECTION_RULE_EXCEPTION_REASON_MAX_LENGTH = commonJsModule.DETECTION_RULE_EXCEPTION_REASON_MAX_LENGTH;
|
|
8
|
+
export const DETECTION_RULE_EXCEPTION_VALUE_MAX_LENGTH = commonJsModule.DETECTION_RULE_EXCEPTION_VALUE_MAX_LENGTH;
|
|
9
|
+
export const DETECTION_RULE_EXCEPTION_WILDCARD = commonJsModule.DETECTION_RULE_EXCEPTION_WILDCARD;
|
|
10
|
+
export const DETECTION_RULE_EXCEPTION_WINDOW_MAX_IN_DAYS = commonJsModule.DETECTION_RULE_EXCEPTION_WINDOW_MAX_IN_DAYS;
|
|
11
|
+
export const DetectionRuleExceptionKind = commonJsModule.DetectionRuleExceptionKind;
|
|
12
|
+
export const DetectionRuleExceptionStatus = commonJsModule.DetectionRuleExceptionStatus;
|
|
13
|
+
export const doesDetectionRuleExceptionApply = commonJsModule.doesDetectionRuleExceptionApply;
|
|
14
|
+
export const getDetectionRuleExceptionColumns = commonJsModule.getDetectionRuleExceptionColumns;
|
|
15
|
+
export const getDetectionRuleExceptionFieldProblem = commonJsModule.getDetectionRuleExceptionFieldProblem;
|
|
16
|
+
export const getDetectionRuleExceptionProblem = commonJsModule.getDetectionRuleExceptionProblem;
|
|
17
|
+
export const getDetectionRuleExceptionProblems = commonJsModule.getDetectionRuleExceptionProblems;
|
|
18
|
+
export const getDetectionRuleExceptionStatus = commonJsModule.getDetectionRuleExceptionStatus;
|
|
19
|
+
export const isDetectionRuleExceptionCidr = commonJsModule.isDetectionRuleExceptionCidr;
|
|
20
|
+
export const isDetectionRuleExceptionEntityType = commonJsModule.isDetectionRuleExceptionEntityType;
|
|
21
|
+
export const isDetectionRuleExceptionKind = commonJsModule.isDetectionRuleExceptionKind;
|
|
22
|
+
export const normalizeDetectionRuleExceptionField = commonJsModule.normalizeDetectionRuleExceptionField;
|
|
23
|
+
export const normalizeDetectionRuleExceptionValue = commonJsModule.normalizeDetectionRuleExceptionValue;
|
|
24
|
+
export const readDetectionRuleExceptionDate = commonJsModule.readDetectionRuleExceptionDate;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import ProviderLogo from "../ProviderLogo/ProviderLogo.mjs";
|
|
2
|
+
export declare enum OpenTelemetryGuideLanguage {
|
|
3
|
+
JavaScript = "javascript",
|
|
4
|
+
Python = "python",
|
|
5
|
+
Java = "java",
|
|
6
|
+
Kotlin = "kotlin",
|
|
7
|
+
DotNet = "dotnet",
|
|
8
|
+
Go = "go",
|
|
9
|
+
Ruby = "ruby",
|
|
10
|
+
Php = "php",
|
|
11
|
+
Rust = "rust",
|
|
12
|
+
Elixir = "elixir"
|
|
13
|
+
}
|
|
14
|
+
export type TelemetryGuideLanguageKey = "node" | "python" | "go" | "java" | "dotnet" | "rust" | "php" | "ruby" | "elixir" | "cpp" | "swift" | "react" | "angular";
|
|
15
|
+
export declare const TELEMETRY_GUIDE_LANGUAGE_KEYS: ReadonlyArray<TelemetryGuideLanguageKey>;
|
|
16
|
+
export interface OpenTelemetryGuideLanguageGroup {
|
|
17
|
+
language: OpenTelemetryGuideLanguage;
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
logo?: ProviderLogo | undefined;
|
|
21
|
+
searchTerms?: ReadonlyArray<string> | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare const OPEN_TELEMETRY_GUIDE_LANGUAGE_GROUPS: ReadonlyArray<OpenTelemetryGuideLanguageGroup>;
|
|
24
|
+
export type OpenTelemetryGuideKind = "runtime" | "framework" | "worker" | "browser";
|
|
25
|
+
export interface OpenTelemetryGuideEntry {
|
|
26
|
+
slug: string;
|
|
27
|
+
name: string;
|
|
28
|
+
inSentence?: string | undefined;
|
|
29
|
+
language: OpenTelemetryGuideLanguage;
|
|
30
|
+
kind: OpenTelemetryGuideKind;
|
|
31
|
+
logo?: ProviderLogo | undefined;
|
|
32
|
+
telemetryGuideLanguage?: TelemetryGuideLanguageKey | undefined;
|
|
33
|
+
isLanguageGuide?: boolean | undefined;
|
|
34
|
+
isFeatured?: boolean | undefined;
|
|
35
|
+
}
|
|
36
|
+
export declare const MAX_FEATURED_OPEN_TELEMETRY_GUIDES: number;
|
|
37
|
+
export declare const OPEN_TELEMETRY_GUIDES: ReadonlyArray<OpenTelemetryGuideEntry>;
|
|
38
|
+
export declare const OPEN_TELEMETRY_GUIDES_INDEX_PATH: string;
|
|
39
|
+
export declare const OPEN_TELEMETRY_GUIDE_PATH_PREFIX: string;
|
|
40
|
+
export declare const OPEN_TELEMETRY_GUIDES_ORIGIN: string;
|
|
41
|
+
export declare function getOpenTelemetryGuidePath(slug: string): string;
|
|
42
|
+
export declare function getOpenTelemetryGuideUrl(slug: string): string;
|
|
43
|
+
export declare function getOpenTelemetryGuidesIndexUrl(): string;
|
|
44
|
+
export declare function getOpenTelemetryGuide(slug: string): OpenTelemetryGuideEntry | undefined;
|
|
45
|
+
export declare function getFeaturedOpenTelemetryGuides(): Array<OpenTelemetryGuideEntry>;
|
|
46
|
+
export declare function getOpenTelemetryGuidesOfLanguage(language: OpenTelemetryGuideLanguage): Array<OpenTelemetryGuideEntry>;
|
|
47
|
+
export declare function getOpenTelemetryGuideLanguageGroup(language: OpenTelemetryGuideLanguage): OpenTelemetryGuideLanguageGroup;
|
|
48
|
+
export interface TelemetryGuideLanguageGuides {
|
|
49
|
+
languageGuide: OpenTelemetryGuideEntry;
|
|
50
|
+
frameworkGuides: Array<OpenTelemetryGuideEntry>;
|
|
51
|
+
}
|
|
52
|
+
export declare function getGuidesForTelemetryGuideLanguage(key: TelemetryGuideLanguageKey): TelemetryGuideLanguageGuides | undefined;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import ProviderLogo from "../ProviderLogo/ProviderLogo";
|
|
2
|
+
export declare enum OpenTelemetryGuideLanguage {
|
|
3
|
+
JavaScript = "javascript",
|
|
4
|
+
Python = "python",
|
|
5
|
+
Java = "java",
|
|
6
|
+
Kotlin = "kotlin",
|
|
7
|
+
DotNet = "dotnet",
|
|
8
|
+
Go = "go",
|
|
9
|
+
Ruby = "ruby",
|
|
10
|
+
Php = "php",
|
|
11
|
+
Rust = "rust",
|
|
12
|
+
Elixir = "elixir"
|
|
13
|
+
}
|
|
14
|
+
export type TelemetryGuideLanguageKey = "node" | "python" | "go" | "java" | "dotnet" | "rust" | "php" | "ruby" | "elixir" | "cpp" | "swift" | "react" | "angular";
|
|
15
|
+
export declare const TELEMETRY_GUIDE_LANGUAGE_KEYS: ReadonlyArray<TelemetryGuideLanguageKey>;
|
|
16
|
+
export interface OpenTelemetryGuideLanguageGroup {
|
|
17
|
+
language: OpenTelemetryGuideLanguage;
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
logo?: ProviderLogo | undefined;
|
|
21
|
+
searchTerms?: ReadonlyArray<string> | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare const OPEN_TELEMETRY_GUIDE_LANGUAGE_GROUPS: ReadonlyArray<OpenTelemetryGuideLanguageGroup>;
|
|
24
|
+
export type OpenTelemetryGuideKind = "runtime" | "framework" | "worker" | "browser";
|
|
25
|
+
export interface OpenTelemetryGuideEntry {
|
|
26
|
+
slug: string;
|
|
27
|
+
name: string;
|
|
28
|
+
inSentence?: string | undefined;
|
|
29
|
+
language: OpenTelemetryGuideLanguage;
|
|
30
|
+
kind: OpenTelemetryGuideKind;
|
|
31
|
+
logo?: ProviderLogo | undefined;
|
|
32
|
+
telemetryGuideLanguage?: TelemetryGuideLanguageKey | undefined;
|
|
33
|
+
isLanguageGuide?: boolean | undefined;
|
|
34
|
+
isFeatured?: boolean | undefined;
|
|
35
|
+
}
|
|
36
|
+
export declare const MAX_FEATURED_OPEN_TELEMETRY_GUIDES: number;
|
|
37
|
+
export declare const OPEN_TELEMETRY_GUIDES: ReadonlyArray<OpenTelemetryGuideEntry>;
|
|
38
|
+
export declare const OPEN_TELEMETRY_GUIDES_INDEX_PATH: string;
|
|
39
|
+
export declare const OPEN_TELEMETRY_GUIDE_PATH_PREFIX: string;
|
|
40
|
+
export declare const OPEN_TELEMETRY_GUIDES_ORIGIN: string;
|
|
41
|
+
export declare function getOpenTelemetryGuidePath(slug: string): string;
|
|
42
|
+
export declare function getOpenTelemetryGuideUrl(slug: string): string;
|
|
43
|
+
export declare function getOpenTelemetryGuidesIndexUrl(): string;
|
|
44
|
+
export declare function getOpenTelemetryGuide(slug: string): OpenTelemetryGuideEntry | undefined;
|
|
45
|
+
export declare function getFeaturedOpenTelemetryGuides(): Array<OpenTelemetryGuideEntry>;
|
|
46
|
+
export declare function getOpenTelemetryGuidesOfLanguage(language: OpenTelemetryGuideLanguage): Array<OpenTelemetryGuideEntry>;
|
|
47
|
+
export declare function getOpenTelemetryGuideLanguageGroup(language: OpenTelemetryGuideLanguage): OpenTelemetryGuideLanguageGroup;
|
|
48
|
+
export interface TelemetryGuideLanguageGuides {
|
|
49
|
+
languageGuide: OpenTelemetryGuideEntry;
|
|
50
|
+
frameworkGuides: Array<OpenTelemetryGuideEntry>;
|
|
51
|
+
}
|
|
52
|
+
export declare function getGuidesForTelemetryGuideLanguage(key: TelemetryGuideLanguageKey): TelemetryGuideLanguageGuides | undefined;
|