@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.
Files changed (45) hide show
  1. package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js +14 -37
  2. package/Models/DatabaseModels/DetectionRuleException.d.mts +25 -0
  3. package/Models/DatabaseModels/DetectionRuleException.d.ts +25 -0
  4. package/Models/DatabaseModels/DetectionRuleException.js +412 -0
  5. package/Models/DatabaseModels/DetectionRuleException.mjs +2 -0
  6. package/Models/DatabaseModels/Index.js +2 -0
  7. package/Types/Database/TableColumn.d.mts +8 -0
  8. package/Types/Database/TableColumn.d.ts +8 -0
  9. package/Types/Database/TableColumn.js +69 -23
  10. package/Types/Database/TableColumn.mjs +1 -0
  11. package/Types/JSONFunctions.js +16 -1
  12. package/Types/Monitor/MonitorType.js +5 -4
  13. package/Types/Monitor/TelemetryAlertRule.d.mts +111 -0
  14. package/Types/Monitor/TelemetryAlertRule.d.ts +111 -0
  15. package/Types/Monitor/TelemetryAlertRule.js +886 -0
  16. package/Types/Monitor/TelemetryAlertRule.mjs +5 -0
  17. package/Types/Monitor/TelemetryRulePreview.d.mts +57 -0
  18. package/Types/Monitor/TelemetryRulePreview.d.ts +57 -0
  19. package/Types/Monitor/TelemetryRulePreview.js +190 -0
  20. package/Types/Monitor/TelemetryRulePreview.mjs +6 -0
  21. package/Types/OnCallDutyPolicy/EveryNewEventRules.d.mts +23 -0
  22. package/Types/OnCallDutyPolicy/EveryNewEventRules.d.ts +23 -0
  23. package/Types/OnCallDutyPolicy/EveryNewEventRules.js +105 -0
  24. package/Types/OnCallDutyPolicy/EveryNewEventRules.mjs +9 -0
  25. package/Types/ProviderLogo/ProviderLogo.d.mts +17 -1
  26. package/Types/ProviderLogo/ProviderLogo.d.ts +17 -1
  27. package/Types/ProviderLogo/ProviderLogo.js +33 -0
  28. package/Types/SecurityEvent/DetectionRetrohunt.d.mts +38 -0
  29. package/Types/SecurityEvent/DetectionRetrohunt.d.ts +38 -0
  30. package/Types/SecurityEvent/DetectionRetrohunt.js +147 -0
  31. package/Types/SecurityEvent/DetectionRetrohunt.mjs +10 -0
  32. package/Types/SecurityEvent/DetectionRuleException.d.mts +65 -0
  33. package/Types/SecurityEvent/DetectionRuleException.d.ts +65 -0
  34. package/Types/SecurityEvent/DetectionRuleException.js +441 -0
  35. package/Types/SecurityEvent/DetectionRuleException.mjs +24 -0
  36. package/Types/Telemetry/OpenTelemetryGuides.d.mts +52 -0
  37. package/Types/Telemetry/OpenTelemetryGuides.d.ts +52 -0
  38. package/Types/Telemetry/OpenTelemetryGuides.js +419 -0
  39. package/Types/Telemetry/OpenTelemetryGuides.mjs +17 -0
  40. package/Utils/Schema/OpenApiMetadataRegistry.d.mts +4 -0
  41. package/Utils/Schema/OpenApiMetadataRegistry.d.ts +4 -0
  42. package/Utils/Schema/OpenApiMetadataRegistry.js +20 -0
  43. package/Utils/Schema/OpenApiMetadataRegistry.mjs +2 -0
  44. package/Utils/Schema/Zod.js +6 -0
  45. package/package.json +1 -1
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DETECTION_RETROHUNT_NOISY_FIRINGS_PER_DAY = exports.DETECTION_RETROHUNT_MAX_GROUPS = exports.DETECTION_RETROHUNT_DEFAULT_PERIOD_IN_HOURS = exports.DETECTION_RETROHUNT_PERIODS_IN_HOURS = void 0;
4
+ exports.isDetectionRetrohuntPeriod = isDetectionRetrohuntPeriod;
5
+ exports.getDetectionRetrohuntFiringsPerDay = getDetectionRetrohuntFiringsPerDay;
6
+ exports.isDetectionRetrohuntNoisy = isDetectionRetrohuntNoisy;
7
+ exports.detectionRetrohuntResultToJSON = detectionRetrohuntResultToJSON;
8
+ exports.parseDetectionRetrohuntResult = parseDetectionRetrohuntResult;
9
+ /*
10
+ * RETROHUNT: A DETECTION RULE RUN OVER PAST EVENTS.
11
+ *
12
+ * What a new or changed rule would have found had it been running: the
13
+ * rule - as saved, or as it stands in the form, before it is saved - read
14
+ * over the last day, week or month of events, with its exceptions, and
15
+ * counted the way its scheduled runs count. Nothing is opened, sent or
16
+ * written: no case, alert, incident, finding or risk.
17
+ *
18
+ * A single rule is counted in windows as long as its interval, each group
19
+ * firing in a window when its count there reaches the rule's threshold, as
20
+ * its runs fire. A correlation is read over the whole period at once, and
21
+ * names the groups it would have matched.
22
+ *
23
+ * Shared by the server, which runs it (DetectionRuleRetrohunt), and the
24
+ * Dashboard, which asks for it and draws the answer.
25
+ */
26
+ // The periods a retrohunt reads, in hours: the last day, week and month.
27
+ exports.DETECTION_RETROHUNT_PERIODS_IN_HOURS = [
28
+ 24,
29
+ 24 * 7,
30
+ 24 * 30,
31
+ ];
32
+ exports.DETECTION_RETROHUNT_DEFAULT_PERIOD_IN_HOURS = 24 * 7;
33
+ // The groups an answer lists, the ones that fired most first.
34
+ exports.DETECTION_RETROHUNT_MAX_GROUPS = 50;
35
+ /*
36
+ * More firings a day than a person can look at: past this the answer says
37
+ * how to make the rule quieter.
38
+ */
39
+ exports.DETECTION_RETROHUNT_NOISY_FIRINGS_PER_DAY = 20;
40
+ function isDetectionRetrohuntPeriod(value) {
41
+ return (typeof value === "number" &&
42
+ exports.DETECTION_RETROHUNT_PERIODS_IN_HOURS.includes(value));
43
+ }
44
+ // Firings per day over the period, rounded to one decimal place.
45
+ function getDetectionRetrohuntFiringsPerDay(result) {
46
+ const days = Math.max(1, result.periodInHours / 24);
47
+ return Math.round((result.firedCount / days) * 10) / 10;
48
+ }
49
+ // Whether the rule would have fired more often than a person can look at.
50
+ function isDetectionRetrohuntNoisy(result) {
51
+ return (getDetectionRetrohuntFiringsPerDay(result) >
52
+ exports.DETECTION_RETROHUNT_NOISY_FIRINGS_PER_DAY);
53
+ }
54
+ function dateToJSON(date) {
55
+ return date ? date.toISOString() : null;
56
+ }
57
+ function readDate(value) {
58
+ if (typeof value !== "string" || !value) {
59
+ return null;
60
+ }
61
+ const date = new Date(value);
62
+ return Number.isNaN(date.getTime()) ? null : date;
63
+ }
64
+ function readNumber(value) {
65
+ const number = Number(value);
66
+ return Number.isFinite(number) ? number : 0;
67
+ }
68
+ function readNullableNumber(value) {
69
+ if (value === null || value === undefined) {
70
+ return null;
71
+ }
72
+ return readNumber(value);
73
+ }
74
+ function readText(value) {
75
+ return typeof value === "string" ? value : "";
76
+ }
77
+ function detectionRetrohuntResultToJSON(result) {
78
+ return {
79
+ startTime: dateToJSON(result.startTime),
80
+ endTime: dateToJSON(result.endTime),
81
+ periodInHours: result.periodInHours,
82
+ isCorrelation: result.isCorrelation,
83
+ windowInMinutes: result.windowInMinutes,
84
+ threshold: result.threshold,
85
+ firedCount: result.firedCount,
86
+ groupCount: result.groupCount,
87
+ eventCount: result.eventCount,
88
+ matchedEventCount: result.matchedEventCount,
89
+ exceptionCount: result.exceptionCount,
90
+ skippedEventCount: result.skippedEventCount,
91
+ preventedFiredCount: result.preventedFiredCount,
92
+ hasMoreGroups: result.hasMoreGroups,
93
+ candidateLimit: result.candidateLimit,
94
+ groups: result.groups.map((group) => {
95
+ return {
96
+ value: group.value,
97
+ entityType: group.entityType,
98
+ firedCount: group.firedCount,
99
+ eventCount: group.eventCount,
100
+ firstFiredAt: dateToJSON(group.firstFiredAt),
101
+ lastFiredAt: dateToJSON(group.lastFiredAt),
102
+ sampleMessage: group.sampleMessage,
103
+ summary: group.summary,
104
+ };
105
+ }),
106
+ };
107
+ }
108
+ // The answer as the API sends it, read defensively.
109
+ function parseDetectionRetrohuntResult(json) {
110
+ const groups = Array.isArray(json["groups"])
111
+ ? json["groups"]
112
+ : [];
113
+ return {
114
+ startTime: readDate(json["startTime"]) || new Date(0),
115
+ endTime: readDate(json["endTime"]) || new Date(0),
116
+ periodInHours: readNumber(json["periodInHours"]),
117
+ isCorrelation: json["isCorrelation"] === true,
118
+ windowInMinutes: readNumber(json["windowInMinutes"]),
119
+ threshold: readNullableNumber(json["threshold"]),
120
+ firedCount: readNumber(json["firedCount"]),
121
+ groupCount: readNumber(json["groupCount"]),
122
+ eventCount: readNumber(json["eventCount"]),
123
+ matchedEventCount: readNullableNumber(json["matchedEventCount"]),
124
+ exceptionCount: readNumber(json["exceptionCount"]),
125
+ skippedEventCount: readNullableNumber(json["skippedEventCount"]),
126
+ preventedFiredCount: readNullableNumber(json["preventedFiredCount"]),
127
+ hasMoreGroups: json["hasMoreGroups"] === true,
128
+ candidateLimit: readNullableNumber(json["candidateLimit"]),
129
+ groups: groups
130
+ .filter((item) => {
131
+ return (Boolean(item) && typeof item === "object" && !Array.isArray(item));
132
+ })
133
+ .map((item) => {
134
+ const group = item;
135
+ return {
136
+ value: readText(group["value"]),
137
+ entityType: readText(group["entityType"]),
138
+ firedCount: readNumber(group["firedCount"]),
139
+ eventCount: readNumber(group["eventCount"]),
140
+ firstFiredAt: readDate(group["firstFiredAt"]),
141
+ lastFiredAt: readDate(group["lastFiredAt"]),
142
+ sampleMessage: readText(group["sampleMessage"]),
143
+ summary: readText(group["summary"]),
144
+ };
145
+ }),
146
+ };
147
+ }
@@ -0,0 +1,10 @@
1
+ import commonJsModule from "./DetectionRetrohunt.js";
2
+ export const DETECTION_RETROHUNT_DEFAULT_PERIOD_IN_HOURS = commonJsModule.DETECTION_RETROHUNT_DEFAULT_PERIOD_IN_HOURS;
3
+ export const DETECTION_RETROHUNT_MAX_GROUPS = commonJsModule.DETECTION_RETROHUNT_MAX_GROUPS;
4
+ export const DETECTION_RETROHUNT_NOISY_FIRINGS_PER_DAY = commonJsModule.DETECTION_RETROHUNT_NOISY_FIRINGS_PER_DAY;
5
+ export const DETECTION_RETROHUNT_PERIODS_IN_HOURS = commonJsModule.DETECTION_RETROHUNT_PERIODS_IN_HOURS;
6
+ export const detectionRetrohuntResultToJSON = commonJsModule.detectionRetrohuntResultToJSON;
7
+ export const getDetectionRetrohuntFiringsPerDay = commonJsModule.getDetectionRetrohuntFiringsPerDay;
8
+ export const isDetectionRetrohuntNoisy = commonJsModule.isDetectionRetrohuntNoisy;
9
+ export const isDetectionRetrohuntPeriod = commonJsModule.isDetectionRetrohuntPeriod;
10
+ export const parseDetectionRetrohuntResult = commonJsModule.parseDetectionRetrohuntResult;
@@ -0,0 +1,65 @@
1
+ import { SecurityEntityType } from "../SecurityCase/SecurityEntity.mjs";
2
+ export declare enum DetectionRuleExceptionKind {
3
+ Entity = "Entity",
4
+ Value = "Value",
5
+ TimeWindow = "Time Window"
6
+ }
7
+ export declare const DETECTION_RULE_EXCEPTION_KINDS: ReadonlyArray<DetectionRuleExceptionKind>;
8
+ export declare const DETECTION_RULE_EXCEPTION_ENTITY_TYPES: ReadonlyArray<SecurityEntityType>;
9
+ export declare const DETECTION_RULE_EXCEPTION_ENTITY_FIELDS: Readonly<Record<string, ReadonlyArray<string>>>;
10
+ export declare const DETECTION_RULE_EXCEPTION_VALUE_MAX_LENGTH: number;
11
+ export declare const DETECTION_RULE_EXCEPTION_FIELD_MAX_LENGTH: number;
12
+ export declare const DETECTION_RULE_EXCEPTION_REASON_MAX_LENGTH: number;
13
+ export declare const DETECTION_RULE_EXCEPTION_WINDOW_MAX_IN_DAYS: number;
14
+ export declare const DETECTION_RULE_EXCEPTIONS_PER_RULE_MAX: number;
15
+ export declare const DETECTION_RULE_EXCEPTION_WILDCARD: string;
16
+ export declare enum DetectionRuleExceptionStatus {
17
+ Active = "Active",
18
+ Expired = "Expired",
19
+ Upcoming = "Upcoming",
20
+ Ended = "Ended"
21
+ }
22
+ export interface DetectionRuleExceptionShape {
23
+ kind?: string | null | undefined;
24
+ entityType?: string | null | undefined;
25
+ fieldName?: string | null | undefined;
26
+ value?: string | null | undefined;
27
+ startsAt?: Date | string | null | undefined;
28
+ endsAt?: Date | string | null | undefined;
29
+ expiresAt?: Date | string | null | undefined;
30
+ reason?: string | null | undefined;
31
+ }
32
+ export declare function isDetectionRuleExceptionKind(value: unknown): value is DetectionRuleExceptionKind;
33
+ export declare function isDetectionRuleExceptionEntityType(value: unknown): value is SecurityEntityType;
34
+ export declare function readDetectionRuleExceptionDate(value: unknown): Date | null;
35
+ export declare function normalizeDetectionRuleExceptionValue(value: unknown): string;
36
+ export declare function normalizeDetectionRuleExceptionField(value: unknown): string;
37
+ export declare function isDetectionRuleExceptionCidr(value: string): boolean;
38
+ export declare function getDetectionRuleExceptionStatus(exception: DetectionRuleExceptionShape, now: Date): DetectionRuleExceptionStatus;
39
+ export declare function doesDetectionRuleExceptionApply(exception: DetectionRuleExceptionShape, read: {
40
+ from: Date;
41
+ until: Date;
42
+ now: Date;
43
+ }): boolean;
44
+ export type DetectionRuleExceptionFormField = "kind" | "entityType" | "fieldName" | "value" | "startsAt" | "endsAt" | "expiresAt" | "reason";
45
+ export interface DetectionRuleExceptionProblem {
46
+ field: DetectionRuleExceptionFormField;
47
+ message: string;
48
+ }
49
+ export interface DetectionRuleExceptionCheckOptions {
50
+ now: Date;
51
+ isExpiryNew: boolean;
52
+ }
53
+ export declare function getDetectionRuleExceptionProblems(exception: DetectionRuleExceptionShape, options: DetectionRuleExceptionCheckOptions): Array<DetectionRuleExceptionProblem>;
54
+ export declare function getDetectionRuleExceptionFieldProblem(exception: DetectionRuleExceptionShape, field: DetectionRuleExceptionFormField, options: DetectionRuleExceptionCheckOptions): string | null;
55
+ export declare function getDetectionRuleExceptionProblem(exception: DetectionRuleExceptionShape, options: DetectionRuleExceptionCheckOptions): string | null;
56
+ export interface DetectionRuleExceptionColumns {
57
+ entityType: SecurityEntityType | null;
58
+ fieldName: string | null;
59
+ value: string | null;
60
+ startsAt: Date | null;
61
+ endsAt: Date | null;
62
+ expiresAt: Date | null;
63
+ reason: string;
64
+ }
65
+ export declare function getDetectionRuleExceptionColumns(exception: DetectionRuleExceptionShape): DetectionRuleExceptionColumns;
@@ -0,0 +1,65 @@
1
+ import { SecurityEntityType } from "../SecurityCase/SecurityEntity";
2
+ export declare enum DetectionRuleExceptionKind {
3
+ Entity = "Entity",
4
+ Value = "Value",
5
+ TimeWindow = "Time Window"
6
+ }
7
+ export declare const DETECTION_RULE_EXCEPTION_KINDS: ReadonlyArray<DetectionRuleExceptionKind>;
8
+ export declare const DETECTION_RULE_EXCEPTION_ENTITY_TYPES: ReadonlyArray<SecurityEntityType>;
9
+ export declare const DETECTION_RULE_EXCEPTION_ENTITY_FIELDS: Readonly<Record<string, ReadonlyArray<string>>>;
10
+ export declare const DETECTION_RULE_EXCEPTION_VALUE_MAX_LENGTH: number;
11
+ export declare const DETECTION_RULE_EXCEPTION_FIELD_MAX_LENGTH: number;
12
+ export declare const DETECTION_RULE_EXCEPTION_REASON_MAX_LENGTH: number;
13
+ export declare const DETECTION_RULE_EXCEPTION_WINDOW_MAX_IN_DAYS: number;
14
+ export declare const DETECTION_RULE_EXCEPTIONS_PER_RULE_MAX: number;
15
+ export declare const DETECTION_RULE_EXCEPTION_WILDCARD: string;
16
+ export declare enum DetectionRuleExceptionStatus {
17
+ Active = "Active",
18
+ Expired = "Expired",
19
+ Upcoming = "Upcoming",
20
+ Ended = "Ended"
21
+ }
22
+ export interface DetectionRuleExceptionShape {
23
+ kind?: string | null | undefined;
24
+ entityType?: string | null | undefined;
25
+ fieldName?: string | null | undefined;
26
+ value?: string | null | undefined;
27
+ startsAt?: Date | string | null | undefined;
28
+ endsAt?: Date | string | null | undefined;
29
+ expiresAt?: Date | string | null | undefined;
30
+ reason?: string | null | undefined;
31
+ }
32
+ export declare function isDetectionRuleExceptionKind(value: unknown): value is DetectionRuleExceptionKind;
33
+ export declare function isDetectionRuleExceptionEntityType(value: unknown): value is SecurityEntityType;
34
+ export declare function readDetectionRuleExceptionDate(value: unknown): Date | null;
35
+ export declare function normalizeDetectionRuleExceptionValue(value: unknown): string;
36
+ export declare function normalizeDetectionRuleExceptionField(value: unknown): string;
37
+ export declare function isDetectionRuleExceptionCidr(value: string): boolean;
38
+ export declare function getDetectionRuleExceptionStatus(exception: DetectionRuleExceptionShape, now: Date): DetectionRuleExceptionStatus;
39
+ export declare function doesDetectionRuleExceptionApply(exception: DetectionRuleExceptionShape, read: {
40
+ from: Date;
41
+ until: Date;
42
+ now: Date;
43
+ }): boolean;
44
+ export type DetectionRuleExceptionFormField = "kind" | "entityType" | "fieldName" | "value" | "startsAt" | "endsAt" | "expiresAt" | "reason";
45
+ export interface DetectionRuleExceptionProblem {
46
+ field: DetectionRuleExceptionFormField;
47
+ message: string;
48
+ }
49
+ export interface DetectionRuleExceptionCheckOptions {
50
+ now: Date;
51
+ isExpiryNew: boolean;
52
+ }
53
+ export declare function getDetectionRuleExceptionProblems(exception: DetectionRuleExceptionShape, options: DetectionRuleExceptionCheckOptions): Array<DetectionRuleExceptionProblem>;
54
+ export declare function getDetectionRuleExceptionFieldProblem(exception: DetectionRuleExceptionShape, field: DetectionRuleExceptionFormField, options: DetectionRuleExceptionCheckOptions): string | null;
55
+ export declare function getDetectionRuleExceptionProblem(exception: DetectionRuleExceptionShape, options: DetectionRuleExceptionCheckOptions): string | null;
56
+ export interface DetectionRuleExceptionColumns {
57
+ entityType: SecurityEntityType | null;
58
+ fieldName: string | null;
59
+ value: string | null;
60
+ startsAt: Date | null;
61
+ endsAt: Date | null;
62
+ expiresAt: Date | null;
63
+ reason: string;
64
+ }
65
+ export declare function getDetectionRuleExceptionColumns(exception: DetectionRuleExceptionShape): DetectionRuleExceptionColumns;