@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
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CODE_REPOSITORY_RUNNER_TOKEN_REFUSAL = exports.CodeWorkerKind = exports.CodeRepositoryRunnerChoiceKind = void 0;
|
|
7
|
+
exports.followsProjectDefaultRunner = followsProjectDefaultRunner;
|
|
7
8
|
exports.getRepositoryRunnerId = getRepositoryRunnerId;
|
|
8
9
|
exports.decideCodeRepositoryRunner = decideCodeRepositoryRunner;
|
|
9
10
|
exports.mayWorkInCodeRepository = mayWorkInCodeRepository;
|
|
@@ -11,14 +12,26 @@ const ObjectID_1 = __importDefault(require("../ObjectID"));
|
|
|
11
12
|
/*
|
|
12
13
|
* WHERE AI WORKS IN A CODE REPOSITORY - the repository's one rule.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
15
|
+
* The default order a runbook step's Runner follows (Types/Runner/
|
|
16
|
+
* RunnerChoice), for a repository:
|
|
17
|
+
*
|
|
18
|
+
* 1. the Runner the repository picked (CodeRepository.runnerId, its
|
|
19
|
+
* Runner setting in Code) - a pick always wins: only that Runner may
|
|
20
|
+
* take the repository's AI work and be handed a token for it;
|
|
21
|
+
* 2. for a repository that picked none, the project's default Runner
|
|
22
|
+
* (Runner.isProjectDefault, Types/Runner/ProjectDefaultRunner) when it
|
|
23
|
+
* has one - followed, not copied: making another Runner the default
|
|
24
|
+
* moves every repository that picks none onto it;
|
|
25
|
+
* 3. otherwise a global Runner - the one OneUptime runs for every project
|
|
26
|
+
* (on a self-hosted install, the bundled `runner` service of Docker
|
|
27
|
+
* Compose and the Helm chart) - unless its project turned global
|
|
28
|
+
* Runners off (Project.useGlobalRunners), in which case it needs one of
|
|
29
|
+
* the project's own Runners.
|
|
30
|
+
*
|
|
31
|
+
* A repository may also pick the Global Runner itself
|
|
32
|
+
* (CodeRepository.isGlobalRunnerPicked): it then never follows the
|
|
33
|
+
* project's default Runner, as a step that picked the Global Runner never
|
|
34
|
+
* does (GLOBAL_RUNNER_CHOICE_ID).
|
|
22
35
|
*
|
|
23
36
|
* An AI agent of the project's own from before Runners (an AIAgent row with
|
|
24
37
|
* a project) still serves the project's repositories that picked no Runner,
|
|
@@ -32,11 +45,28 @@ var CodeRepositoryRunnerChoiceKind;
|
|
|
32
45
|
(function (CodeRepositoryRunnerChoiceKind) {
|
|
33
46
|
// The repository picked one of its project's Runners.
|
|
34
47
|
CodeRepositoryRunnerChoiceKind["Custom"] = "custom";
|
|
35
|
-
// The repository picked none, and its project
|
|
48
|
+
// The repository picked none, and its project has a default Runner.
|
|
49
|
+
CodeRepositoryRunnerChoiceKind["ProjectDefault"] = "project-default";
|
|
50
|
+
/*
|
|
51
|
+
* The repository picked none and its project has no default Runner, or
|
|
52
|
+
* it picked the Global Runner; its project uses global Runners.
|
|
53
|
+
*/
|
|
36
54
|
CodeRepositoryRunnerChoiceKind["Global"] = "global";
|
|
37
|
-
|
|
55
|
+
/*
|
|
56
|
+
* The repository picked none and its project has no default Runner, or
|
|
57
|
+
* it picked the Global Runner; its project turned global Runners off.
|
|
58
|
+
*/
|
|
38
59
|
CodeRepositoryRunnerChoiceKind["NoRunner"] = "no-runner";
|
|
39
60
|
})(CodeRepositoryRunnerChoiceKind || (exports.CodeRepositoryRunnerChoiceKind = CodeRepositoryRunnerChoiceKind = {}));
|
|
61
|
+
/*
|
|
62
|
+
* Whether a repository's work follows its project's default Runner: it
|
|
63
|
+
* picked no Runner, and did not pick the Global Runner either. Such a
|
|
64
|
+
* repository runs on the project's default Runner whenever there is one.
|
|
65
|
+
*/
|
|
66
|
+
function followsProjectDefaultRunner(facts) {
|
|
67
|
+
return (!getRepositoryRunnerId(facts.repositoryRunnerId) &&
|
|
68
|
+
facts.picksGlobalRunner !== true);
|
|
69
|
+
}
|
|
40
70
|
// Who asks to work in a repository.
|
|
41
71
|
var CodeWorkerKind;
|
|
42
72
|
(function (CodeWorkerKind) {
|
|
@@ -64,6 +94,14 @@ function decideCodeRepositoryRunner(facts) {
|
|
|
64
94
|
if (runnerId) {
|
|
65
95
|
return { kind: CodeRepositoryRunnerChoiceKind.Custom, runnerId };
|
|
66
96
|
}
|
|
97
|
+
// Then the project's default Runner, unless it picked the Global Runner.
|
|
98
|
+
const defaultRunnerId = getRepositoryRunnerId(facts.projectDefaultRunnerId);
|
|
99
|
+
if (defaultRunnerId && followsProjectDefaultRunner(facts)) {
|
|
100
|
+
return {
|
|
101
|
+
kind: CodeRepositoryRunnerChoiceKind.ProjectDefault,
|
|
102
|
+
runnerId: defaultRunnerId,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
67
105
|
if (facts.projectUsesGlobalRunners) {
|
|
68
106
|
return { kind: CodeRepositoryRunnerChoiceKind.Global };
|
|
69
107
|
}
|
|
@@ -74,10 +112,13 @@ function decideCodeRepositoryRunner(facts) {
|
|
|
74
112
|
* take its AI work, and be handed a token for it.
|
|
75
113
|
*
|
|
76
114
|
* - a repository that picked a Runner: that Runner, and nothing else;
|
|
77
|
-
* - one that
|
|
78
|
-
*
|
|
115
|
+
* - one that follows its project's default Runner: that Runner, and an
|
|
116
|
+
* AI agent of the project's own;
|
|
117
|
+
* - one that runs on a global Runner: a global Runner while its project
|
|
118
|
+
* uses them, and an AI agent of the project's own either way.
|
|
79
119
|
*
|
|
80
|
-
* A project's Runner never works in a repository that did not pick it
|
|
120
|
+
* A project's Runner never works in a repository that did not pick it,
|
|
121
|
+
* unless it is the project's default Runner and the repository follows it.
|
|
81
122
|
*/
|
|
82
123
|
function mayWorkInCodeRepository(data) {
|
|
83
124
|
const workerId = getRepositoryRunnerId(data.worker.id);
|
|
@@ -86,6 +127,11 @@ function mayWorkInCodeRepository(data) {
|
|
|
86
127
|
return (data.worker.kind === CodeWorkerKind.ProjectRunner &&
|
|
87
128
|
Boolean(workerId) &&
|
|
88
129
|
workerId === data.decision.runnerId);
|
|
130
|
+
case CodeRepositoryRunnerChoiceKind.ProjectDefault:
|
|
131
|
+
return ((data.worker.kind === CodeWorkerKind.ProjectRunner &&
|
|
132
|
+
Boolean(workerId) &&
|
|
133
|
+
workerId === data.decision.runnerId) ||
|
|
134
|
+
data.worker.kind === CodeWorkerKind.ProjectAgent);
|
|
89
135
|
case CodeRepositoryRunnerChoiceKind.Global:
|
|
90
136
|
return (data.worker.kind === CodeWorkerKind.GlobalRunner ||
|
|
91
137
|
data.worker.kind === CodeWorkerKind.ProjectAgent);
|
|
@@ -103,4 +149,4 @@ function mayWorkInCodeRepository(data) {
|
|
|
103
149
|
* without naming the Runner the repository picked: the worker asking is not
|
|
104
150
|
* told about another Runner of the project.
|
|
105
151
|
*/
|
|
106
|
-
exports.CODE_REPOSITORY_RUNNER_TOKEN_REFUSAL = "This repository's AI work runs on the Runner its settings in Code pick
|
|
152
|
+
exports.CODE_REPOSITORY_RUNNER_TOKEN_REFUSAL = "This repository's AI work runs on the Runner its settings in Code pick - the project's default Runner when they pick none - and that is not this Runner, so it was not given access to the repository. Start the task again: it goes to the repository's Runner.";
|
|
@@ -3,5 +3,6 @@ export const CODE_REPOSITORY_RUNNER_TOKEN_REFUSAL = commonJsModule.CODE_REPOSITO
|
|
|
3
3
|
export const CodeRepositoryRunnerChoiceKind = commonJsModule.CodeRepositoryRunnerChoiceKind;
|
|
4
4
|
export const CodeWorkerKind = commonJsModule.CodeWorkerKind;
|
|
5
5
|
export const decideCodeRepositoryRunner = commonJsModule.decideCodeRepositoryRunner;
|
|
6
|
+
export const followsProjectDefaultRunner = commonJsModule.followsProjectDefaultRunner;
|
|
6
7
|
export const getRepositoryRunnerId = commonJsModule.getRepositoryRunnerId;
|
|
7
8
|
export const mayWorkInCodeRepository = commonJsModule.mayWorkInCodeRepository;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const OCSF_PROCESS_ACTIVITY_CLASS_UID: number;
|
|
2
|
+
export declare enum OcsfProcessActivityId {
|
|
3
|
+
Unknown = 0,
|
|
4
|
+
Launch = 1,
|
|
5
|
+
Terminate = 2,
|
|
6
|
+
Open = 3,
|
|
7
|
+
Inject = 4,
|
|
8
|
+
SetUserId = 5,
|
|
9
|
+
Other = 99
|
|
10
|
+
}
|
|
11
|
+
export declare const OCSF_PROCESS_ACTIVITY_NAMES: Readonly<Record<OcsfProcessActivityId, string>>;
|
|
12
|
+
export declare function ocsfProcessActivityName(activityId: number | null | undefined): string;
|
|
13
|
+
export declare enum ProcessActivityKind {
|
|
14
|
+
Launch = "Launch",
|
|
15
|
+
Terminate = "Terminate",
|
|
16
|
+
Open = "Open",
|
|
17
|
+
Inject = "Inject",
|
|
18
|
+
PrivilegeEscalation = "PrivilegeEscalation",
|
|
19
|
+
Other = "Other"
|
|
20
|
+
}
|
|
21
|
+
export declare function getProcessActivityKind(data: {
|
|
22
|
+
activityId?: number | null | undefined;
|
|
23
|
+
activityName?: string | null | undefined;
|
|
24
|
+
}): ProcessActivityKind;
|
|
25
|
+
export declare function readProcessActivityId(value: unknown): number | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const OCSF_PROCESS_ACTIVITY_CLASS_UID: number;
|
|
2
|
+
export declare enum OcsfProcessActivityId {
|
|
3
|
+
Unknown = 0,
|
|
4
|
+
Launch = 1,
|
|
5
|
+
Terminate = 2,
|
|
6
|
+
Open = 3,
|
|
7
|
+
Inject = 4,
|
|
8
|
+
SetUserId = 5,
|
|
9
|
+
Other = 99
|
|
10
|
+
}
|
|
11
|
+
export declare const OCSF_PROCESS_ACTIVITY_NAMES: Readonly<Record<OcsfProcessActivityId, string>>;
|
|
12
|
+
export declare function ocsfProcessActivityName(activityId: number | null | undefined): string;
|
|
13
|
+
export declare enum ProcessActivityKind {
|
|
14
|
+
Launch = "Launch",
|
|
15
|
+
Terminate = "Terminate",
|
|
16
|
+
Open = "Open",
|
|
17
|
+
Inject = "Inject",
|
|
18
|
+
PrivilegeEscalation = "PrivilegeEscalation",
|
|
19
|
+
Other = "Other"
|
|
20
|
+
}
|
|
21
|
+
export declare function getProcessActivityKind(data: {
|
|
22
|
+
activityId?: number | null | undefined;
|
|
23
|
+
activityName?: string | null | undefined;
|
|
24
|
+
}): ProcessActivityKind;
|
|
25
|
+
export declare function readProcessActivityId(value: unknown): number | null;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* What a Process Activity event (OCSF class 1007) says was done to its
|
|
4
|
+
* process: launched, ended, opened, injected into, or something else.
|
|
5
|
+
*
|
|
6
|
+
* OCSF names it by `activity_id` and `activity_name`; Google SecOps' UDM by
|
|
7
|
+
* its event type (PROCESS_LAUNCH, PROCESS_OPEN, ...), which the UDM
|
|
8
|
+
* normalizer reads in as these names. The process fields are read by it -
|
|
9
|
+
* in a launch the process that acted is the parent of the one launched,
|
|
10
|
+
* in any other activity some other process (OcsfNormalizer) - and a
|
|
11
|
+
* destination sends the event as the activity it is (GoogleSecOpsUdmMapper),
|
|
12
|
+
* so all of them read an event's activity by the one rule below.
|
|
13
|
+
*
|
|
14
|
+
* https://schema.ocsf.io/classes/process_activity
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ProcessActivityKind = exports.OCSF_PROCESS_ACTIVITY_NAMES = exports.OcsfProcessActivityId = exports.OCSF_PROCESS_ACTIVITY_CLASS_UID = void 0;
|
|
18
|
+
exports.ocsfProcessActivityName = ocsfProcessActivityName;
|
|
19
|
+
exports.getProcessActivityKind = getProcessActivityKind;
|
|
20
|
+
exports.readProcessActivityId = readProcessActivityId;
|
|
21
|
+
exports.OCSF_PROCESS_ACTIVITY_CLASS_UID = 1007;
|
|
22
|
+
var OcsfProcessActivityId;
|
|
23
|
+
(function (OcsfProcessActivityId) {
|
|
24
|
+
OcsfProcessActivityId[OcsfProcessActivityId["Unknown"] = 0] = "Unknown";
|
|
25
|
+
OcsfProcessActivityId[OcsfProcessActivityId["Launch"] = 1] = "Launch";
|
|
26
|
+
OcsfProcessActivityId[OcsfProcessActivityId["Terminate"] = 2] = "Terminate";
|
|
27
|
+
OcsfProcessActivityId[OcsfProcessActivityId["Open"] = 3] = "Open";
|
|
28
|
+
OcsfProcessActivityId[OcsfProcessActivityId["Inject"] = 4] = "Inject";
|
|
29
|
+
OcsfProcessActivityId[OcsfProcessActivityId["SetUserId"] = 5] = "SetUserId";
|
|
30
|
+
OcsfProcessActivityId[OcsfProcessActivityId["Other"] = 99] = "Other";
|
|
31
|
+
})(OcsfProcessActivityId || (exports.OcsfProcessActivityId = OcsfProcessActivityId = {}));
|
|
32
|
+
// Each activity id as OCSF captions it, which is what activity_name holds.
|
|
33
|
+
exports.OCSF_PROCESS_ACTIVITY_NAMES = {
|
|
34
|
+
[OcsfProcessActivityId.Unknown]: "Unknown",
|
|
35
|
+
[OcsfProcessActivityId.Launch]: "Launch",
|
|
36
|
+
[OcsfProcessActivityId.Terminate]: "Terminate",
|
|
37
|
+
[OcsfProcessActivityId.Open]: "Open",
|
|
38
|
+
[OcsfProcessActivityId.Inject]: "Inject",
|
|
39
|
+
[OcsfProcessActivityId.SetUserId]: "Set User ID",
|
|
40
|
+
[OcsfProcessActivityId.Other]: "Other",
|
|
41
|
+
};
|
|
42
|
+
function isProcessActivityId(value) {
|
|
43
|
+
return Object.prototype.hasOwnProperty.call(exports.OCSF_PROCESS_ACTIVITY_NAMES, value);
|
|
44
|
+
}
|
|
45
|
+
/*
|
|
46
|
+
* The name of a Process Activity's activity id, for an event that gives
|
|
47
|
+
* only the id; "" for an id OCSF does not define.
|
|
48
|
+
*/
|
|
49
|
+
function ocsfProcessActivityName(activityId) {
|
|
50
|
+
if (activityId === null ||
|
|
51
|
+
activityId === undefined ||
|
|
52
|
+
!Number.isInteger(activityId) ||
|
|
53
|
+
!isProcessActivityId(activityId)) {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
return exports.OCSF_PROCESS_ACTIVITY_NAMES[activityId];
|
|
57
|
+
}
|
|
58
|
+
/*
|
|
59
|
+
* The kinds of process activity told apart downstream. Privilege
|
|
60
|
+
* Escalation is UDM's own (PROCESS_PRIVILEGE_ESCALATION, read in under that
|
|
61
|
+
* name); OCSF's Set User ID, Unknown and Other, and any name not listed
|
|
62
|
+
* here, are Other.
|
|
63
|
+
*/
|
|
64
|
+
var ProcessActivityKind;
|
|
65
|
+
(function (ProcessActivityKind) {
|
|
66
|
+
ProcessActivityKind["Launch"] = "Launch";
|
|
67
|
+
ProcessActivityKind["Terminate"] = "Terminate";
|
|
68
|
+
ProcessActivityKind["Open"] = "Open";
|
|
69
|
+
ProcessActivityKind["Inject"] = "Inject";
|
|
70
|
+
ProcessActivityKind["PrivilegeEscalation"] = "PrivilegeEscalation";
|
|
71
|
+
ProcessActivityKind["Other"] = "Other";
|
|
72
|
+
})(ProcessActivityKind || (exports.ProcessActivityKind = ProcessActivityKind = {}));
|
|
73
|
+
const KIND_BY_ID = {
|
|
74
|
+
[OcsfProcessActivityId.Unknown]: ProcessActivityKind.Other,
|
|
75
|
+
[OcsfProcessActivityId.Launch]: ProcessActivityKind.Launch,
|
|
76
|
+
[OcsfProcessActivityId.Terminate]: ProcessActivityKind.Terminate,
|
|
77
|
+
[OcsfProcessActivityId.Open]: ProcessActivityKind.Open,
|
|
78
|
+
[OcsfProcessActivityId.Inject]: ProcessActivityKind.Inject,
|
|
79
|
+
[OcsfProcessActivityId.SetUserId]: ProcessActivityKind.Other,
|
|
80
|
+
[OcsfProcessActivityId.Other]: ProcessActivityKind.Other,
|
|
81
|
+
};
|
|
82
|
+
/*
|
|
83
|
+
* A Map, not an object: the name is the source's text, and an object would
|
|
84
|
+
* answer "constructor" or "toString" with what every object inherits.
|
|
85
|
+
*/
|
|
86
|
+
const KIND_BY_NAME = new Map([
|
|
87
|
+
["launch", ProcessActivityKind.Launch],
|
|
88
|
+
["terminate", ProcessActivityKind.Terminate],
|
|
89
|
+
["open", ProcessActivityKind.Open],
|
|
90
|
+
["inject", ProcessActivityKind.Inject],
|
|
91
|
+
["privilege escalation", ProcessActivityKind.PrivilegeEscalation],
|
|
92
|
+
]);
|
|
93
|
+
/*
|
|
94
|
+
* The kind of a process activity, from what its event says: its activity
|
|
95
|
+
* id when it gives one (the id wins over the name, as OCSF has it), else
|
|
96
|
+
* its activity name. An event that names no activity at all is a launch,
|
|
97
|
+
* which is what nearly every process event is.
|
|
98
|
+
*/
|
|
99
|
+
function getProcessActivityKind(data) {
|
|
100
|
+
const activityId = data.activityId;
|
|
101
|
+
if (activityId !== null && activityId !== undefined) {
|
|
102
|
+
return Number.isInteger(activityId) && isProcessActivityId(activityId)
|
|
103
|
+
? KIND_BY_ID[activityId]
|
|
104
|
+
: ProcessActivityKind.Other;
|
|
105
|
+
}
|
|
106
|
+
const name = (data.activityName || "").trim().toLowerCase();
|
|
107
|
+
if (!name) {
|
|
108
|
+
return ProcessActivityKind.Launch;
|
|
109
|
+
}
|
|
110
|
+
return KIND_BY_NAME.get(name) || ProcessActivityKind.Other;
|
|
111
|
+
}
|
|
112
|
+
/*
|
|
113
|
+
* An activity id as a stored event keeps it: a number, or the text its
|
|
114
|
+
* flattened payload holds ("3"); null when it holds none, or no number.
|
|
115
|
+
* The same reading ingest gave the payload's activity_id (readNumber), so
|
|
116
|
+
* a stored event is sent as the activity its process fields were read by.
|
|
117
|
+
*/
|
|
118
|
+
function readProcessActivityId(value) {
|
|
119
|
+
if (typeof value === "number") {
|
|
120
|
+
return Number.isFinite(value) ? value : null;
|
|
121
|
+
}
|
|
122
|
+
if (typeof value !== "string") {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const text = value.trim();
|
|
126
|
+
if (!text) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const parsed = Number(text);
|
|
130
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
131
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import commonJsModule from "./OcsfProcessActivity.js";
|
|
2
|
+
export const OCSF_PROCESS_ACTIVITY_CLASS_UID = commonJsModule.OCSF_PROCESS_ACTIVITY_CLASS_UID;
|
|
3
|
+
export const OCSF_PROCESS_ACTIVITY_NAMES = commonJsModule.OCSF_PROCESS_ACTIVITY_NAMES;
|
|
4
|
+
export const OcsfProcessActivityId = commonJsModule.OcsfProcessActivityId;
|
|
5
|
+
export const ProcessActivityKind = commonJsModule.ProcessActivityKind;
|
|
6
|
+
export const getProcessActivityKind = commonJsModule.getProcessActivityKind;
|
|
7
|
+
export const ocsfProcessActivityName = commonJsModule.ocsfProcessActivityName;
|
|
8
|
+
export const readProcessActivityId = commonJsModule.readProcessActivityId;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export interface TranslatableTerm {
|
|
2
|
+
readonly translatableTerm: string;
|
|
3
|
+
readonly inSentence: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface ComposedValue {
|
|
6
|
+
readonly compose: (translator: Translator) => string;
|
|
7
|
+
}
|
|
8
|
+
export type TemplateValue = string | number | TranslatableTerm | ComposedValue;
|
|
9
|
+
export type TemplateValues = Record<string, TemplateValue>;
|
|
10
|
+
export interface PluralTemplate {
|
|
11
|
+
one: string;
|
|
12
|
+
other: string;
|
|
13
|
+
}
|
|
14
|
+
export type TextLookup = (text: string) => string | undefined;
|
|
15
|
+
export interface TermOptions {
|
|
16
|
+
inSentence?: boolean | undefined;
|
|
17
|
+
}
|
|
18
|
+
export declare const translatableTerm: (text: string, options?: TermOptions) => TranslatableTerm;
|
|
19
|
+
export declare const isTranslatableTerm: (value: unknown) => value is TranslatableTerm;
|
|
20
|
+
export declare const composedValue: (compose: (translator: Translator) => string) => ComposedValue;
|
|
21
|
+
export declare const isComposedValue: (value: unknown) => value is ComposedValue;
|
|
22
|
+
export declare const translationKey: <T extends string>(text: T) => T;
|
|
23
|
+
export declare const DEFAULT_LANGUAGE: string;
|
|
24
|
+
export declare const toSentenceTerm: (text: string, language?: string) => string;
|
|
25
|
+
export declare const getPluralCategory: (language: string, count: number) => string;
|
|
26
|
+
export declare const getTemplatePlaceholders: (template: string) => Array<string>;
|
|
27
|
+
export declare const fillTemplate: (template: string, values?: TemplateValues) => string;
|
|
28
|
+
export interface Translator {
|
|
29
|
+
language: string;
|
|
30
|
+
translateText: (text: string | undefined) => string | undefined;
|
|
31
|
+
hasTranslation: (text: string) => boolean;
|
|
32
|
+
translateTemplate: (template: string, values?: TemplateValues) => string;
|
|
33
|
+
translatePlural: (template: PluralTemplate, count: number, values?: TemplateValues) => string;
|
|
34
|
+
translateTerm: (text: string | undefined, options?: TermOptions) => string;
|
|
35
|
+
formatNumber: (value: number) => string;
|
|
36
|
+
}
|
|
37
|
+
export declare const createTranslator: (lookup: TextLookup | undefined, language?: string | undefined) => Translator;
|
|
38
|
+
export declare const getGlobalTranslator: () => Translator;
|
|
39
|
+
export declare const translateText: (text: string | undefined) => string | undefined;
|
|
40
|
+
export declare const translateTerm: (text: string | undefined, options?: TermOptions) => string;
|
|
41
|
+
export declare const translateTemplate: (template: string, values?: TemplateValues) => string;
|
|
42
|
+
export declare const translatePlural: (template: PluralTemplate, count: number, values?: TemplateValues) => string;
|
|
43
|
+
export declare const getSentenceLanguage: (translator: Translator, template: string | PluralTemplate) => string;
|
|
44
|
+
export declare const translateNamedAction: (translator: Translator, data: {
|
|
45
|
+
template: string;
|
|
46
|
+
itemName: string;
|
|
47
|
+
values?: TemplateValues;
|
|
48
|
+
}) => string;
|
|
49
|
+
export type SentencePart = {
|
|
50
|
+
kind: "text";
|
|
51
|
+
text: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: "slot";
|
|
54
|
+
slot: string;
|
|
55
|
+
};
|
|
56
|
+
export interface SentenceParts {
|
|
57
|
+
parts: Array<SentencePart>;
|
|
58
|
+
language: string;
|
|
59
|
+
}
|
|
60
|
+
export interface SentencePartsInput {
|
|
61
|
+
translator: Translator;
|
|
62
|
+
template: string | PluralTemplate;
|
|
63
|
+
slots: ReadonlyArray<string>;
|
|
64
|
+
values?: TemplateValues | undefined;
|
|
65
|
+
count?: number | undefined;
|
|
66
|
+
}
|
|
67
|
+
export declare const getSentenceParts: (data: SentencePartsInput) => Array<SentencePart>;
|
|
68
|
+
export declare const getSentencePartsAndLanguage: (data: SentencePartsInput) => SentenceParts;
|
|
69
|
+
export interface TemplateAround {
|
|
70
|
+
before: string;
|
|
71
|
+
after: string;
|
|
72
|
+
}
|
|
73
|
+
export declare const translateTemplateAround: (template: string, slot: string, values?: TemplateValues) => TemplateAround;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export interface TranslatableTerm {
|
|
2
|
+
readonly translatableTerm: string;
|
|
3
|
+
readonly inSentence: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface ComposedValue {
|
|
6
|
+
readonly compose: (translator: Translator) => string;
|
|
7
|
+
}
|
|
8
|
+
export type TemplateValue = string | number | TranslatableTerm | ComposedValue;
|
|
9
|
+
export type TemplateValues = Record<string, TemplateValue>;
|
|
10
|
+
export interface PluralTemplate {
|
|
11
|
+
one: string;
|
|
12
|
+
other: string;
|
|
13
|
+
}
|
|
14
|
+
export type TextLookup = (text: string) => string | undefined;
|
|
15
|
+
export interface TermOptions {
|
|
16
|
+
inSentence?: boolean | undefined;
|
|
17
|
+
}
|
|
18
|
+
export declare const translatableTerm: (text: string, options?: TermOptions) => TranslatableTerm;
|
|
19
|
+
export declare const isTranslatableTerm: (value: unknown) => value is TranslatableTerm;
|
|
20
|
+
export declare const composedValue: (compose: (translator: Translator) => string) => ComposedValue;
|
|
21
|
+
export declare const isComposedValue: (value: unknown) => value is ComposedValue;
|
|
22
|
+
export declare const translationKey: <T extends string>(text: T) => T;
|
|
23
|
+
export declare const DEFAULT_LANGUAGE: string;
|
|
24
|
+
export declare const toSentenceTerm: (text: string, language?: string) => string;
|
|
25
|
+
export declare const getPluralCategory: (language: string, count: number) => string;
|
|
26
|
+
export declare const getTemplatePlaceholders: (template: string) => Array<string>;
|
|
27
|
+
export declare const fillTemplate: (template: string, values?: TemplateValues) => string;
|
|
28
|
+
export interface Translator {
|
|
29
|
+
language: string;
|
|
30
|
+
translateText: (text: string | undefined) => string | undefined;
|
|
31
|
+
hasTranslation: (text: string) => boolean;
|
|
32
|
+
translateTemplate: (template: string, values?: TemplateValues) => string;
|
|
33
|
+
translatePlural: (template: PluralTemplate, count: number, values?: TemplateValues) => string;
|
|
34
|
+
translateTerm: (text: string | undefined, options?: TermOptions) => string;
|
|
35
|
+
formatNumber: (value: number) => string;
|
|
36
|
+
}
|
|
37
|
+
export declare const createTranslator: (lookup: TextLookup | undefined, language?: string | undefined) => Translator;
|
|
38
|
+
export declare const getGlobalTranslator: () => Translator;
|
|
39
|
+
export declare const translateText: (text: string | undefined) => string | undefined;
|
|
40
|
+
export declare const translateTerm: (text: string | undefined, options?: TermOptions) => string;
|
|
41
|
+
export declare const translateTemplate: (template: string, values?: TemplateValues) => string;
|
|
42
|
+
export declare const translatePlural: (template: PluralTemplate, count: number, values?: TemplateValues) => string;
|
|
43
|
+
export declare const getSentenceLanguage: (translator: Translator, template: string | PluralTemplate) => string;
|
|
44
|
+
export declare const translateNamedAction: (translator: Translator, data: {
|
|
45
|
+
template: string;
|
|
46
|
+
itemName: string;
|
|
47
|
+
values?: TemplateValues;
|
|
48
|
+
}) => string;
|
|
49
|
+
export type SentencePart = {
|
|
50
|
+
kind: "text";
|
|
51
|
+
text: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: "slot";
|
|
54
|
+
slot: string;
|
|
55
|
+
};
|
|
56
|
+
export interface SentenceParts {
|
|
57
|
+
parts: Array<SentencePart>;
|
|
58
|
+
language: string;
|
|
59
|
+
}
|
|
60
|
+
export interface SentencePartsInput {
|
|
61
|
+
translator: Translator;
|
|
62
|
+
template: string | PluralTemplate;
|
|
63
|
+
slots: ReadonlyArray<string>;
|
|
64
|
+
values?: TemplateValues | undefined;
|
|
65
|
+
count?: number | undefined;
|
|
66
|
+
}
|
|
67
|
+
export declare const getSentenceParts: (data: SentencePartsInput) => Array<SentencePart>;
|
|
68
|
+
export declare const getSentencePartsAndLanguage: (data: SentencePartsInput) => SentenceParts;
|
|
69
|
+
export interface TemplateAround {
|
|
70
|
+
before: string;
|
|
71
|
+
after: string;
|
|
72
|
+
}
|
|
73
|
+
export declare const translateTemplateAround: (template: string, slot: string, values?: TemplateValues) => TemplateAround;
|
package/Utils/CronTab.d.mts
CHANGED
|
@@ -45,6 +45,41 @@ export interface CronExpressionFields {
|
|
|
45
45
|
readonly dayOfWeek: CronFieldValues;
|
|
46
46
|
readonly hasSeconds: boolean;
|
|
47
47
|
}
|
|
48
|
+
export type CronScheduleShape = {
|
|
49
|
+
kind: "everyMinute";
|
|
50
|
+
} | {
|
|
51
|
+
kind: "everyMinutes";
|
|
52
|
+
step: number;
|
|
53
|
+
} | {
|
|
54
|
+
kind: "everyHourOnTheHour";
|
|
55
|
+
} | {
|
|
56
|
+
kind: "everyHours";
|
|
57
|
+
step: number;
|
|
58
|
+
minute: number;
|
|
59
|
+
} | {
|
|
60
|
+
kind: "daily";
|
|
61
|
+
hour: number;
|
|
62
|
+
minute: number;
|
|
63
|
+
} | {
|
|
64
|
+
kind: "weekly";
|
|
65
|
+
weekdays: Array<number>;
|
|
66
|
+
hour: number;
|
|
67
|
+
minute: number;
|
|
68
|
+
} | {
|
|
69
|
+
kind: "monthly";
|
|
70
|
+
daysOfMonth: Array<number>;
|
|
71
|
+
monthStep: number;
|
|
72
|
+
hour: number;
|
|
73
|
+
minute: number;
|
|
74
|
+
} | {
|
|
75
|
+
kind: "yearly";
|
|
76
|
+
daysOfMonth: Array<number>;
|
|
77
|
+
months: Array<number>;
|
|
78
|
+
hour: number;
|
|
79
|
+
minute: number;
|
|
80
|
+
} | {
|
|
81
|
+
kind: "fieldByField";
|
|
82
|
+
};
|
|
48
83
|
export default class CronTab {
|
|
49
84
|
/**
|
|
50
85
|
* Curated list of common schedules offered in the picker. Every value here
|
|
@@ -71,6 +106,7 @@ export default class CronTab {
|
|
|
71
106
|
* expression cannot be parsed.
|
|
72
107
|
*/
|
|
73
108
|
static getHumanReadableDescription(expression: string): string | null;
|
|
109
|
+
static getScheduleShape(expression: string): CronScheduleShape | null;
|
|
74
110
|
/**
|
|
75
111
|
* Computes the next `count` fire times (in UTC) at or after `from`
|
|
76
112
|
* (exclusive). Returns fewer than `count` entries only if the pattern has no
|
|
@@ -94,6 +130,8 @@ export default class CronTab {
|
|
|
94
130
|
private static nextAllowed;
|
|
95
131
|
private static startOfNextDay;
|
|
96
132
|
private static advanceToNextMonth;
|
|
133
|
+
private static getShapeOf;
|
|
134
|
+
static describeTimeOfDay(hour: number, minute: number): string;
|
|
97
135
|
private static describe;
|
|
98
136
|
private static describeGeneric;
|
|
99
137
|
private static isDefaultSecond;
|
|
@@ -104,9 +142,9 @@ export default class CronTab {
|
|
|
104
142
|
* Returns the step, or null when the field isn't a clean step.
|
|
105
143
|
*/
|
|
106
144
|
private static detectStep;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
145
|
+
static describeWeekdays(values: Array<number>): string;
|
|
146
|
+
static describeMonths(values: Array<number>): string;
|
|
147
|
+
static describeDaysOfMonth(values: Array<number>): string;
|
|
110
148
|
private static joinList;
|
|
111
149
|
private static ordinal;
|
|
112
150
|
private static pad;
|
package/Utils/CronTab.d.ts
CHANGED
|
@@ -45,6 +45,41 @@ export interface CronExpressionFields {
|
|
|
45
45
|
readonly dayOfWeek: CronFieldValues;
|
|
46
46
|
readonly hasSeconds: boolean;
|
|
47
47
|
}
|
|
48
|
+
export type CronScheduleShape = {
|
|
49
|
+
kind: "everyMinute";
|
|
50
|
+
} | {
|
|
51
|
+
kind: "everyMinutes";
|
|
52
|
+
step: number;
|
|
53
|
+
} | {
|
|
54
|
+
kind: "everyHourOnTheHour";
|
|
55
|
+
} | {
|
|
56
|
+
kind: "everyHours";
|
|
57
|
+
step: number;
|
|
58
|
+
minute: number;
|
|
59
|
+
} | {
|
|
60
|
+
kind: "daily";
|
|
61
|
+
hour: number;
|
|
62
|
+
minute: number;
|
|
63
|
+
} | {
|
|
64
|
+
kind: "weekly";
|
|
65
|
+
weekdays: Array<number>;
|
|
66
|
+
hour: number;
|
|
67
|
+
minute: number;
|
|
68
|
+
} | {
|
|
69
|
+
kind: "monthly";
|
|
70
|
+
daysOfMonth: Array<number>;
|
|
71
|
+
monthStep: number;
|
|
72
|
+
hour: number;
|
|
73
|
+
minute: number;
|
|
74
|
+
} | {
|
|
75
|
+
kind: "yearly";
|
|
76
|
+
daysOfMonth: Array<number>;
|
|
77
|
+
months: Array<number>;
|
|
78
|
+
hour: number;
|
|
79
|
+
minute: number;
|
|
80
|
+
} | {
|
|
81
|
+
kind: "fieldByField";
|
|
82
|
+
};
|
|
48
83
|
export default class CronTab {
|
|
49
84
|
/**
|
|
50
85
|
* Curated list of common schedules offered in the picker. Every value here
|
|
@@ -71,6 +106,7 @@ export default class CronTab {
|
|
|
71
106
|
* expression cannot be parsed.
|
|
72
107
|
*/
|
|
73
108
|
static getHumanReadableDescription(expression: string): string | null;
|
|
109
|
+
static getScheduleShape(expression: string): CronScheduleShape | null;
|
|
74
110
|
/**
|
|
75
111
|
* Computes the next `count` fire times (in UTC) at or after `from`
|
|
76
112
|
* (exclusive). Returns fewer than `count` entries only if the pattern has no
|
|
@@ -94,6 +130,8 @@ export default class CronTab {
|
|
|
94
130
|
private static nextAllowed;
|
|
95
131
|
private static startOfNextDay;
|
|
96
132
|
private static advanceToNextMonth;
|
|
133
|
+
private static getShapeOf;
|
|
134
|
+
static describeTimeOfDay(hour: number, minute: number): string;
|
|
97
135
|
private static describe;
|
|
98
136
|
private static describeGeneric;
|
|
99
137
|
private static isDefaultSecond;
|
|
@@ -104,9 +142,9 @@ export default class CronTab {
|
|
|
104
142
|
* Returns the step, or null when the field isn't a clean step.
|
|
105
143
|
*/
|
|
106
144
|
private static detectStep;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
145
|
+
static describeWeekdays(values: Array<number>): string;
|
|
146
|
+
static describeMonths(values: Array<number>): string;
|
|
147
|
+
static describeDaysOfMonth(values: Array<number>): string;
|
|
110
148
|
private static joinList;
|
|
111
149
|
private static ordinal;
|
|
112
150
|
private static pad;
|