@oneuptime/common 14.0.96 → 14.0.98
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/AnalyticsModels/NetworkFlow.d.mts +4 -0
- package/Models/AnalyticsModels/NetworkFlow.d.ts +4 -0
- package/Models/AnalyticsModels/NetworkFlow.js +50 -0
- package/Models/DatabaseModels/Alert.d.mts +2 -0
- package/Models/DatabaseModels/Alert.d.ts +2 -0
- package/Models/DatabaseModels/Alert.js +63 -0
- package/Models/DatabaseModels/CodeRepository.d.mts +3 -0
- package/Models/DatabaseModels/CodeRepository.d.ts +3 -0
- package/Models/DatabaseModels/CodeRepository.js +104 -0
- package/Models/DatabaseModels/Incident.d.mts +2 -0
- package/Models/DatabaseModels/Incident.d.ts +2 -0
- package/Models/DatabaseModels/Incident.js +63 -0
- package/Models/DatabaseModels/Index.js +12 -0
- package/Models/DatabaseModels/NetworkAddressName.d.mts +14 -0
- package/Models/DatabaseModels/NetworkAddressName.d.ts +14 -0
- package/Models/DatabaseModels/NetworkAddressName.js +300 -0
- package/Models/DatabaseModels/NetworkAddressName.mjs +2 -0
- package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
- package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
- package/Models/DatabaseModels/NetworkDevice.js +38 -0
- package/Models/DatabaseModels/SecurityCase.d.mts +8 -0
- package/Models/DatabaseModels/SecurityCase.d.ts +8 -0
- package/Models/DatabaseModels/SecurityCase.js +145 -0
- package/Models/DatabaseModels/SecurityCaseEvidence.d.mts +32 -0
- package/Models/DatabaseModels/SecurityCaseEvidence.d.ts +32 -0
- package/Models/DatabaseModels/SecurityCaseEvidence.js +548 -0
- package/Models/DatabaseModels/SecurityCaseEvidence.mjs +2 -0
- package/Models/DatabaseModels/SecurityCaseFeed.d.mts +4 -1
- package/Models/DatabaseModels/SecurityCaseFeed.d.ts +4 -1
- package/Models/DatabaseModels/SecurityCaseFeed.js +6 -0
- package/Models/DatabaseModels/SecurityCasePriority.d.mts +2 -0
- package/Models/DatabaseModels/SecurityCasePriority.d.ts +2 -0
- package/Models/DatabaseModels/SecurityCasePriority.js +44 -0
- package/Models/DatabaseModels/SecurityCaseTask.d.mts +22 -0
- package/Models/DatabaseModels/SecurityCaseTask.d.ts +22 -0
- package/Models/DatabaseModels/SecurityCaseTask.js +467 -0
- package/Models/DatabaseModels/SecurityCaseTask.mjs +2 -0
- package/Models/DatabaseModels/SecurityHunt.d.mts +34 -0
- package/Models/DatabaseModels/SecurityHunt.d.ts +34 -0
- package/Models/DatabaseModels/SecurityHunt.js +608 -0
- package/Models/DatabaseModels/SecurityHunt.mjs +2 -0
- package/Models/DatabaseModels/SecurityWatchlist.d.mts +22 -0
- package/Models/DatabaseModels/SecurityWatchlist.d.ts +22 -0
- package/Models/DatabaseModels/SecurityWatchlist.js +411 -0
- package/Models/DatabaseModels/SecurityWatchlist.mjs +2 -0
- package/Models/DatabaseModels/SecurityWatchlistItem.d.mts +17 -0
- package/Models/DatabaseModels/SecurityWatchlistItem.d.ts +17 -0
- package/Models/DatabaseModels/SecurityWatchlistItem.js +321 -0
- package/Models/DatabaseModels/SecurityWatchlistItem.mjs +2 -0
- package/Types/AI/AIChatTypes.d.mts +1 -0
- package/Types/AI/AIChatTypes.d.ts +1 -0
- package/Types/AI/AIRunEventType.d.mts +1 -0
- package/Types/AI/AIRunEventType.d.ts +1 -0
- package/Types/AI/AIRunEventType.js +8 -0
- package/Types/AI/AiAffectedResources.d.mts +2 -1
- package/Types/AI/AiAffectedResources.d.ts +2 -1
- package/Types/AI/AiAffectedResources.js +12 -1
- package/Types/AI/AiTokenCount.d.mts +22 -1
- package/Types/AI/AiTokenCount.d.ts +22 -1
- package/Types/AI/AiTokenCount.js +126 -57
- package/Types/AI/AiTokenCount.mjs +2 -0
- package/Types/AI/CodeFixTaskContext.d.mts +1 -0
- package/Types/AI/CodeFixTaskContext.d.ts +1 -0
- package/Types/AffectedResources/AffectedResourceSearch.d.mts +53 -0
- package/Types/AffectedResources/AffectedResourceSearch.d.ts +53 -0
- package/Types/AffectedResources/AffectedResourceSearch.js +224 -0
- package/Types/AffectedResources/AffectedResourceSearch.mjs +11 -0
- package/Types/ArchivableValue/ArchivableValueUsage.d.mts +21 -2
- package/Types/ArchivableValue/ArchivableValueUsage.d.ts +21 -2
- package/Types/ArchivableValue/ArchivableValueUsage.js +91 -12
- package/Types/ArchivableValue/ArchivableValueUsage.mjs +1 -0
- package/Types/CodeRepository/CodeRepositorySetting.d.mts +1 -0
- package/Types/CodeRepository/CodeRepositorySetting.d.ts +1 -0
- package/Types/CodeRepository/CodeRepositorySetting.js +2 -0
- package/Types/Color.d.mts +0 -2
- package/Types/Color.d.ts +0 -2
- package/Types/Color.js +0 -14
- package/Types/Database/DatabaseProperty.d.mts +0 -2
- package/Types/Database/DatabaseProperty.d.ts +0 -2
- package/Types/Database/DatabaseProperty.js +0 -3
- package/Types/Date.d.mts +0 -2
- package/Types/Date.d.ts +0 -2
- package/Types/Date.js +0 -23
- package/Types/Domain.d.mts +0 -2
- package/Types/Domain.d.ts +0 -2
- package/Types/Domain.js +0 -14
- package/Types/Email/EmailTemplateType.d.mts +3 -0
- package/Types/Email/EmailTemplateType.d.ts +3 -0
- package/Types/Email/EmailTemplateType.js +4 -0
- package/Types/Email.d.mts +0 -2
- package/Types/Email.d.ts +0 -2
- package/Types/Email.js +0 -15
- package/Types/IP/IP.d.mts +0 -2
- package/Types/IP/IP.d.ts +0 -2
- package/Types/IP/IP.js +0 -14
- package/Types/Link.d.mts +1 -0
- package/Types/Link.d.ts +1 -0
- package/Types/Monitor/CriteriaAlert.d.mts +0 -2
- package/Types/Monitor/CriteriaAlert.d.ts +0 -2
- package/Types/Monitor/CriteriaAlert.js +0 -18
- package/Types/Monitor/CriteriaAlert.mjs +1 -2
- package/Types/Monitor/CriteriaFilter.d.mts +0 -2
- package/Types/Monitor/CriteriaFilter.d.ts +0 -2
- package/Types/Monitor/CriteriaFilter.js +1 -42
- package/Types/Monitor/CriteriaFilter.mjs +0 -1
- package/Types/Monitor/CriteriaIncident.d.mts +0 -2
- package/Types/Monitor/CriteriaIncident.d.ts +0 -2
- package/Types/Monitor/CriteriaIncident.js +0 -23
- package/Types/Monitor/CriteriaIncident.mjs +1 -2
- package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.d.mts +0 -2
- package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.d.ts +0 -2
- package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.js +0 -11
- package/Types/Monitor/IncomingMonitor/IncidentGroupingConfig.mjs +1 -2
- package/Types/Monitor/MonitorCriteria.d.mts +0 -2
- package/Types/Monitor/MonitorCriteria.d.ts +0 -2
- package/Types/Monitor/MonitorCriteria.js +0 -21
- package/Types/Monitor/MonitorCriteriaInstance.d.mts +0 -2
- package/Types/Monitor/MonitorCriteriaInstance.d.ts +0 -2
- package/Types/Monitor/MonitorCriteriaInstance.js +0 -54
- package/Types/Monitor/MonitorStep.d.mts +0 -2
- package/Types/Monitor/MonitorStep.d.ts +0 -2
- package/Types/Monitor/MonitorStep.js +0 -80
- package/Types/Monitor/MonitorSteps.d.mts +0 -2
- package/Types/Monitor/MonitorSteps.d.ts +0 -2
- package/Types/Monitor/MonitorSteps.js +0 -31
- package/Types/Name.d.mts +0 -2
- package/Types/Name.d.ts +0 -2
- package/Types/Name.js +0 -14
- package/Types/NetFlow/NetworkAddressName.d.mts +30 -0
- package/Types/NetFlow/NetworkAddressName.d.ts +30 -0
- package/Types/NetFlow/NetworkAddressName.js +149 -0
- package/Types/NetFlow/NetworkAddressName.mjs +6 -0
- package/Types/NetFlow/NetworkTraffic.d.mts +20 -0
- package/Types/NetFlow/NetworkTraffic.d.ts +20 -0
- package/Types/NetFlow/NetworkTraffic.js +5 -1
- package/Types/NetFlow/NetworkTraffic.mjs +2 -0
- package/Types/NetworkController/NetworkControllerReadSummary.d.mts +2 -0
- package/Types/NetworkController/NetworkControllerReadSummary.d.ts +2 -0
- package/Types/NetworkController/NetworkControllerReadSummary.js +7 -1
- package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.d.mts +47 -1
- package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.d.ts +47 -1
- package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.js +173 -8
- package/Types/NetworkDevice/NetworkDeviceDiscoveredDetails.mjs +7 -0
- package/Types/NotificationSetting/NotificationEmailRollupCategory.d.mts +1 -0
- package/Types/NotificationSetting/NotificationEmailRollupCategory.d.ts +1 -0
- package/Types/NotificationSetting/NotificationEmailRollupCategory.js +12 -0
- package/Types/NotificationSetting/NotificationEmailRollupPolicy.js +6 -0
- package/Types/NotificationSetting/NotificationSettingEventType.d.mts +3 -0
- package/Types/NotificationSetting/NotificationSettingEventType.d.ts +3 -0
- package/Types/NotificationSetting/NotificationSettingEventType.js +15 -0
- package/Types/ObjectID.d.mts +0 -1
- package/Types/ObjectID.d.ts +0 -1
- package/Types/ObjectID.js +0 -9
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.d.mts +4 -0
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.d.ts +4 -0
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.js +25 -1
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRunEnding.mjs +4 -0
- package/Types/OnCallDutyPolicy/OnCallEmptyLevel.d.mts +15 -0
- package/Types/OnCallDutyPolicy/OnCallEmptyLevel.d.ts +15 -0
- package/Types/OnCallDutyPolicy/OnCallEmptyLevel.js +118 -0
- package/Types/OnCallDutyPolicy/OnCallEmptyLevel.mjs +9 -0
- package/Types/Permission.d.mts +8 -0
- package/Types/Permission.d.ts +8 -0
- package/Types/Permission.js +87 -3
- package/Types/Phone.d.mts +0 -2
- package/Types/Phone.d.ts +0 -2
- package/Types/Phone.js +0 -14
- package/Types/Port.d.mts +0 -2
- package/Types/Port.d.ts +0 -2
- package/Types/Port.js +0 -14
- package/Types/ProviderLogo/ProviderLogo.d.mts +8 -1
- package/Types/ProviderLogo/ProviderLogo.d.ts +8 -1
- package/Types/ProviderLogo/ProviderLogo.js +14 -0
- package/Types/SecurityCase/SecurityCaseEventEvidence.d.mts +67 -0
- package/Types/SecurityCase/SecurityCaseEventEvidence.d.ts +67 -0
- package/Types/SecurityCase/SecurityCaseEventEvidence.js +271 -0
- package/Types/SecurityCase/SecurityCaseEventEvidence.mjs +13 -0
- package/Types/SecurityCase/SecurityCaseEvidenceKind.d.mts +8 -0
- package/Types/SecurityCase/SecurityCaseEvidenceKind.d.ts +8 -0
- package/Types/SecurityCase/SecurityCaseEvidenceKind.js +34 -0
- package/Types/SecurityCase/SecurityCaseEvidenceKind.mjs +4 -0
- package/Types/SecurityEvent/SecurityHunt.d.mts +122 -0
- package/Types/SecurityEvent/SecurityHunt.d.ts +122 -0
- package/Types/SecurityEvent/SecurityHunt.js +391 -0
- package/Types/SecurityEvent/SecurityHunt.mjs +32 -0
- package/Types/SecurityEvent/SecurityWatchlist.d.mts +167 -0
- package/Types/SecurityEvent/SecurityWatchlist.d.ts +167 -0
- package/Types/SecurityEvent/SecurityWatchlist.js +648 -0
- package/Types/SecurityEvent/SecurityWatchlist.mjs +51 -0
- package/Types/SecurityEvent/SigmaRule.d.mts +2 -0
- package/Types/SecurityEvent/SigmaRule.d.ts +2 -0
- package/Types/SecurityEvent/SigmaRule.js +5 -0
- package/Types/Telemetry/OpenTelemetryGuides.js +177 -5
- package/Types/Version.d.mts +0 -2
- package/Types/Version.d.ts +0 -2
- package/Types/Version.js +0 -14
- package/Types/Workflow/AffectedResourcesSetting.d.mts +13 -0
- package/Types/Workflow/AffectedResourcesSetting.d.ts +13 -0
- package/Types/Workflow/AffectedResourcesSetting.js +120 -0
- package/Types/Workflow/AffectedResourcesSetting.mjs +8 -0
- package/Types/Workflow/Components/BaseModel.js +15 -3
- package/Types/Workflow/Documentation/DatabaseDocumentation.js +36 -0
- package/Types/Workflow/RunRecord.d.mts +3 -14
- package/Types/Workflow/RunRecord.d.ts +3 -14
- package/Types/Workflow/RunRecord.js +10 -51
- package/Utils/AI/InvestigationLogStall.d.mts +38 -0
- package/Utils/AI/InvestigationLogStall.d.ts +38 -0
- package/Utils/AI/InvestigationLogStall.js +163 -0
- package/Utils/AI/InvestigationLogStall.mjs +11 -0
- package/Utils/Inventory/AssetFactSource.d.mts +6 -2
- package/Utils/Inventory/AssetFactSource.d.ts +6 -2
- package/Utils/Inventory/AssetFactSource.js +18 -1
- package/Utils/Inventory/AssetFactSource.mjs +1 -0
- package/Utils/Markdown/FeedLead.d.mts +10 -0
- package/Utils/Markdown/FeedLead.d.ts +10 -0
- package/Utils/Markdown/FeedLead.js +198 -0
- package/Utils/Markdown/FeedLead.mjs +8 -0
- package/Utils/NetworkDevice/NetworkDeviceAssetFacts.d.mts +9 -1
- package/Utils/NetworkDevice/NetworkDeviceAssetFacts.d.ts +9 -1
- package/Utils/NetworkDevice/NetworkDeviceAssetFacts.js +139 -18
- package/Utils/NetworkDevice/NetworkDeviceAssetFacts.mjs +1 -0
- package/Utils/NetworkDevice/NetworkDeviceRefresh.d.mts +88 -0
- package/Utils/NetworkDevice/NetworkDeviceRefresh.d.ts +88 -0
- package/Utils/NetworkDevice/NetworkDeviceRefresh.js +232 -0
- package/Utils/NetworkDevice/NetworkDeviceRefresh.mjs +16 -0
- package/Utils/NetworkTraffic/NetworkAddressBlock.d.mts +20 -0
- package/Utils/NetworkTraffic/NetworkAddressBlock.d.ts +20 -0
- package/Utils/NetworkTraffic/NetworkAddressBlock.js +264 -0
- package/Utils/NetworkTraffic/NetworkAddressBlock.mjs +3 -0
- package/Utils/Project/RecordNumber.d.mts +43 -0
- package/Utils/Project/RecordNumber.d.ts +43 -0
- package/Utils/Project/RecordNumber.js +151 -0
- package/Utils/Project/RecordNumber.mjs +6 -0
- package/Utils/Schema/MonitorSchemas.d.mts +9 -0
- package/Utils/Schema/MonitorSchemas.d.ts +9 -0
- package/Utils/Schema/MonitorSchemas.js +291 -0
- package/Utils/Schema/MonitorSchemas.mjs +9 -0
- package/Utils/Schema/TypeSchemas.d.mts +12 -0
- package/Utils/Schema/TypeSchemas.d.ts +12 -0
- package/Utils/Schema/TypeSchemas.js +176 -0
- package/Utils/Schema/TypeSchemas.mjs +11 -0
- package/Utils/Schema/Zod.js +17 -17
- package/Utils/SecurityCase/SecurityCaseMarkdown.d.mts +43 -0
- package/Utils/SecurityCase/SecurityCaseMarkdown.d.ts +43 -0
- package/Utils/SecurityCase/SecurityCaseMarkdown.js +89 -0
- package/Utils/SecurityCase/SecurityCaseMarkdown.mjs +11 -0
- package/Utils/SecurityCase/SecurityCasePriorities.d.mts +2 -0
- package/Utils/SecurityCase/SecurityCasePriorities.d.ts +2 -0
- package/Utils/SecurityCase/SecurityCasePriorities.js +15 -1
- package/Utils/SecurityCase/SecurityCaseTargets.d.mts +128 -0
- package/Utils/SecurityCase/SecurityCaseTargets.d.ts +128 -0
- package/Utils/SecurityCase/SecurityCaseTargets.js +482 -0
- package/Utils/SecurityCase/SecurityCaseTargets.mjs +28 -0
- package/Utils/SecurityEvent/SecurityEventSearch.d.mts +56 -0
- package/Utils/SecurityEvent/SecurityEventSearch.d.ts +56 -0
- package/Utils/SecurityEvent/SecurityEventSearch.js +422 -0
- package/Utils/SecurityEvent/SecurityEventSearch.mjs +21 -0
- package/Utils/SecurityEvent/SecurityHuntSearch.d.mts +12 -0
- package/Utils/SecurityEvent/SecurityHuntSearch.d.ts +12 -0
- package/Utils/SecurityEvent/SecurityHuntSearch.js +51 -0
- package/Utils/SecurityEvent/SecurityHuntSearch.mjs +3 -0
- package/Utils/SecurityEvent/Sigma/SigmaRuleParser.js +22 -0
- package/Utils/SecurityEvent/Sigma/SigmaWatchlists.d.mts +24 -0
- package/Utils/SecurityEvent/Sigma/SigmaWatchlists.d.ts +24 -0
- package/Utils/SecurityEvent/Sigma/SigmaWatchlists.js +183 -0
- package/Utils/SecurityEvent/Sigma/SigmaWatchlists.mjs +9 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.d.mts +9 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.d.ts +9 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.js +69 -1
- package/Utils/Suggestions/TracePerformanceFixSuggestion.mjs +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export declare enum SecurityCaseTarget {
|
|
2
|
+
Acknowledge = "Acknowledge",
|
|
3
|
+
Contain = "Contain"
|
|
4
|
+
}
|
|
5
|
+
export declare const SECURITY_CASE_TARGETS: ReadonlyArray<SecurityCaseTarget>;
|
|
6
|
+
export declare const SECURITY_CASE_TARGET_AT_RISK_FRACTION: number;
|
|
7
|
+
export declare const MAX_SECURITY_CASE_TARGET_IN_MINUTES: number;
|
|
8
|
+
export interface SecurityCasePriorityTargets {
|
|
9
|
+
acknowledgeWithinInMinutes?: number | null | undefined;
|
|
10
|
+
containWithinInMinutes?: number | null | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface SecurityCaseTargetMoments {
|
|
13
|
+
createdAt?: Date | null | undefined;
|
|
14
|
+
acknowledgedAt?: Date | null | undefined;
|
|
15
|
+
containedAt?: Date | null | undefined;
|
|
16
|
+
closedAt?: Date | null | undefined;
|
|
17
|
+
acknowledgeDueAt?: Date | null | undefined;
|
|
18
|
+
containDueAt?: Date | null | undefined;
|
|
19
|
+
acknowledgeWarnedAt?: Date | null | undefined;
|
|
20
|
+
acknowledgeMissedAt?: Date | null | undefined;
|
|
21
|
+
containWarnedAt?: Date | null | undefined;
|
|
22
|
+
containMissedAt?: Date | null | undefined;
|
|
23
|
+
}
|
|
24
|
+
export interface SecurityCaseTargetColumns {
|
|
25
|
+
priorityColumn: keyof SecurityCasePriorityTargets;
|
|
26
|
+
dueColumn: "acknowledgeDueAt" | "containDueAt";
|
|
27
|
+
warnedColumn: "acknowledgeWarnedAt" | "containWarnedAt";
|
|
28
|
+
missedColumn: "acknowledgeMissedAt" | "containMissedAt";
|
|
29
|
+
}
|
|
30
|
+
export declare const SECURITY_CASE_TARGET_COLUMNS: Readonly<Record<SecurityCaseTarget, SecurityCaseTargetColumns>>;
|
|
31
|
+
export declare enum SecurityCaseTargetState {
|
|
32
|
+
None = "None",
|
|
33
|
+
OnTrack = "OnTrack",
|
|
34
|
+
AtRisk = "AtRisk",
|
|
35
|
+
Missed = "Missed",
|
|
36
|
+
Met = "Met",
|
|
37
|
+
MetLate = "MetLate"
|
|
38
|
+
}
|
|
39
|
+
export interface SecurityCaseTargetReading {
|
|
40
|
+
target: SecurityCaseTarget;
|
|
41
|
+
state: SecurityCaseTargetState;
|
|
42
|
+
dueAt: Date | null;
|
|
43
|
+
atRiskAt: Date | null;
|
|
44
|
+
metAt: Date | null;
|
|
45
|
+
targetInMinutes: number | null;
|
|
46
|
+
minutes: number | null;
|
|
47
|
+
}
|
|
48
|
+
export type SecurityCaseTargetWrite = Partial<Record<"acknowledgeDueAt" | "containDueAt" | "acknowledgeWarnedAt" | "acknowledgeMissedAt" | "containWarnedAt" | "containMissedAt" | "nextDueAt" | "nextTargetCheckAt", Date | null>>;
|
|
49
|
+
export declare function readTargetMinutes(value: unknown): number | null;
|
|
50
|
+
export declare function getTargetMinutes(priority: SecurityCasePriorityTargets | null | undefined, target: SecurityCaseTarget): number | null;
|
|
51
|
+
export declare function hasTargets(priority: SecurityCasePriorityTargets | null | undefined): boolean;
|
|
52
|
+
export declare function getTargetMetAt(securityCase: SecurityCaseTargetMoments, target: SecurityCaseTarget): Date | null;
|
|
53
|
+
export declare function getAtRiskAt(data: {
|
|
54
|
+
dueAt: Date | null;
|
|
55
|
+
targetInMinutes: number | null;
|
|
56
|
+
openedAt?: Date | null | undefined;
|
|
57
|
+
}): Date | null;
|
|
58
|
+
export declare function readSecurityCaseTarget(data: {
|
|
59
|
+
securityCase: SecurityCaseTargetMoments;
|
|
60
|
+
target: SecurityCaseTarget;
|
|
61
|
+
priority: SecurityCasePriorityTargets | null | undefined;
|
|
62
|
+
now: Date;
|
|
63
|
+
}): SecurityCaseTargetReading;
|
|
64
|
+
export declare function readSecurityCaseTargets(data: {
|
|
65
|
+
securityCase: SecurityCaseTargetMoments;
|
|
66
|
+
priority: SecurityCasePriorityTargets | null | undefined;
|
|
67
|
+
now: Date;
|
|
68
|
+
}): Array<SecurityCaseTargetReading>;
|
|
69
|
+
export declare function isPendingTarget(reading: SecurityCaseTargetReading): boolean;
|
|
70
|
+
export declare function getNextPendingTarget(readings: ReadonlyArray<SecurityCaseTargetReading>): SecurityCaseTargetReading | null;
|
|
71
|
+
export declare function getDueTimesForNewCase(data: {
|
|
72
|
+
openedAt: Date;
|
|
73
|
+
priority: SecurityCasePriorityTargets | null | undefined;
|
|
74
|
+
acknowledgedAt?: Date | null | undefined;
|
|
75
|
+
containedAt?: Date | null | undefined;
|
|
76
|
+
closedAt?: Date | null | undefined;
|
|
77
|
+
}): {
|
|
78
|
+
acknowledgeDueAt: Date | null;
|
|
79
|
+
containDueAt: Date | null;
|
|
80
|
+
};
|
|
81
|
+
export declare function getDueTimeAfterPriorityChange(data: {
|
|
82
|
+
dueAt: Date | null;
|
|
83
|
+
isSettled: boolean;
|
|
84
|
+
isRising: boolean;
|
|
85
|
+
newTargetInMinutes: number | null;
|
|
86
|
+
openedAt: Date;
|
|
87
|
+
now: Date;
|
|
88
|
+
}): Date | null | undefined;
|
|
89
|
+
export declare function getDueTimesAfterPriorityChange(data: {
|
|
90
|
+
securityCase: SecurityCaseTargetMoments;
|
|
91
|
+
newPriority: SecurityCasePriorityTargets | null | undefined;
|
|
92
|
+
isRising: boolean;
|
|
93
|
+
now: Date;
|
|
94
|
+
}): SecurityCaseTargetWrite;
|
|
95
|
+
export declare function getContainTargetAfterReopen(data: {
|
|
96
|
+
priority: SecurityCasePriorityTargets | null | undefined;
|
|
97
|
+
now: Date;
|
|
98
|
+
}): SecurityCaseTargetWrite;
|
|
99
|
+
export declare function getNextDueAt(securityCase: SecurityCaseTargetMoments): Date | null;
|
|
100
|
+
export declare function getNextTargetCheckAt(data: {
|
|
101
|
+
securityCase: SecurityCaseTargetMoments;
|
|
102
|
+
priority: SecurityCasePriorityTargets | null | undefined;
|
|
103
|
+
}): Date | null;
|
|
104
|
+
export declare function getTargetBookkeeping(data: {
|
|
105
|
+
securityCase: SecurityCaseTargetMoments;
|
|
106
|
+
priority: SecurityCasePriorityTargets | null | undefined;
|
|
107
|
+
}): {
|
|
108
|
+
nextDueAt: Date | null;
|
|
109
|
+
nextTargetCheckAt: Date | null;
|
|
110
|
+
};
|
|
111
|
+
export declare enum SecurityCaseTargetAlertKind {
|
|
112
|
+
AtRisk = "AtRisk",
|
|
113
|
+
Missed = "Missed"
|
|
114
|
+
}
|
|
115
|
+
export interface SecurityCaseTargetAlert {
|
|
116
|
+
target: SecurityCaseTarget;
|
|
117
|
+
kind: SecurityCaseTargetAlertKind;
|
|
118
|
+
dueAt: Date;
|
|
119
|
+
targetInMinutes: number | null;
|
|
120
|
+
}
|
|
121
|
+
export declare function getTargetAlertsDue(data: {
|
|
122
|
+
securityCase: SecurityCaseTargetMoments;
|
|
123
|
+
priority: SecurityCasePriorityTargets | null | undefined;
|
|
124
|
+
now: Date;
|
|
125
|
+
}): Array<SecurityCaseTargetAlert>;
|
|
126
|
+
export declare function getAlertStamps(alerts: ReadonlyArray<SecurityCaseTargetAlert>, now: Date): SecurityCaseTargetWrite;
|
|
127
|
+
export declare function describeTargetDuration(minutes: number): string;
|
|
128
|
+
export declare function getTargetVerb(target: SecurityCaseTarget): string;
|
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* A SECURITY CASE'S RESPONSE TARGETS - ONE RULE, EVERYWHERE.
|
|
4
|
+
*
|
|
5
|
+
* A project's case priorities each say how fast a case at them must be
|
|
6
|
+
* taken on and contained (SecurityCasePriority.acknowledgeWithinInMinutes
|
|
7
|
+
* and containWithinInMinutes, Security Events > Settings > Response
|
|
8
|
+
* Targets). From them a case gets two due times (SecurityCase.
|
|
9
|
+
* acknowledgeDueAt, containDueAt), and everything that reads them - the
|
|
10
|
+
* case's service as it writes them, the every-minute check that tells
|
|
11
|
+
* people, the case's header, its Overview's figures and the case lists -
|
|
12
|
+
* asks here:
|
|
13
|
+
*
|
|
14
|
+
* - As a case opens, each target is due that long from now. A target the
|
|
15
|
+
* case meets as it opens (opened assigned to somebody, or straight into
|
|
16
|
+
* a status that acknowledges or closes it) gets no due time.
|
|
17
|
+
* - Acknowledge is met when the case is acknowledged (acknowledgedAt:
|
|
18
|
+
* assigned to a person, or moved to a status that counts as
|
|
19
|
+
* acknowledged). Contain is met when it is contained, or closed: a case
|
|
20
|
+
* closed without being contained - a false positive - has nothing left
|
|
21
|
+
* to contain.
|
|
22
|
+
* - When its priority changes, a target not met and not missed follows
|
|
23
|
+
* the new priority: a rise brings its due time closer - the new
|
|
24
|
+
* priority's target from the moment it rose, never later than it was -
|
|
25
|
+
* and a fall moves it out to the new priority's target counted from
|
|
26
|
+
* when the case opened, never sooner than it was. A target the case had
|
|
27
|
+
* no due time for gets the new priority's from the moment of the change.
|
|
28
|
+
* A priority without a target leaves a rise as it was and takes the due
|
|
29
|
+
* time away on a fall. A target met or missed stays as it is: a missed
|
|
30
|
+
* target is a record of what happened.
|
|
31
|
+
* - Reopening a case starts its contain target again, from the moment it
|
|
32
|
+
* is reopened: it is new work.
|
|
33
|
+
* - In the last fifth of a target's time the case is at risk, and the
|
|
34
|
+
* people on it are told once; when the due time passes, it has missed
|
|
35
|
+
* the target, and they are told again (SecurityCaseTargetCheck).
|
|
36
|
+
*
|
|
37
|
+
* Pure: no database and no React, so the server, the dashboard and the
|
|
38
|
+
* tests read one rule.
|
|
39
|
+
*/
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.SecurityCaseTargetAlertKind = exports.SecurityCaseTargetState = exports.SECURITY_CASE_TARGET_COLUMNS = exports.MAX_SECURITY_CASE_TARGET_IN_MINUTES = exports.SECURITY_CASE_TARGET_AT_RISK_FRACTION = exports.SECURITY_CASE_TARGETS = exports.SecurityCaseTarget = void 0;
|
|
42
|
+
exports.readTargetMinutes = readTargetMinutes;
|
|
43
|
+
exports.getTargetMinutes = getTargetMinutes;
|
|
44
|
+
exports.hasTargets = hasTargets;
|
|
45
|
+
exports.getTargetMetAt = getTargetMetAt;
|
|
46
|
+
exports.getAtRiskAt = getAtRiskAt;
|
|
47
|
+
exports.readSecurityCaseTarget = readSecurityCaseTarget;
|
|
48
|
+
exports.readSecurityCaseTargets = readSecurityCaseTargets;
|
|
49
|
+
exports.isPendingTarget = isPendingTarget;
|
|
50
|
+
exports.getNextPendingTarget = getNextPendingTarget;
|
|
51
|
+
exports.getDueTimesForNewCase = getDueTimesForNewCase;
|
|
52
|
+
exports.getDueTimeAfterPriorityChange = getDueTimeAfterPriorityChange;
|
|
53
|
+
exports.getDueTimesAfterPriorityChange = getDueTimesAfterPriorityChange;
|
|
54
|
+
exports.getContainTargetAfterReopen = getContainTargetAfterReopen;
|
|
55
|
+
exports.getNextDueAt = getNextDueAt;
|
|
56
|
+
exports.getNextTargetCheckAt = getNextTargetCheckAt;
|
|
57
|
+
exports.getTargetBookkeeping = getTargetBookkeeping;
|
|
58
|
+
exports.getTargetAlertsDue = getTargetAlertsDue;
|
|
59
|
+
exports.getAlertStamps = getAlertStamps;
|
|
60
|
+
exports.describeTargetDuration = describeTargetDuration;
|
|
61
|
+
exports.getTargetVerb = getTargetVerb;
|
|
62
|
+
var SecurityCaseTarget;
|
|
63
|
+
(function (SecurityCaseTarget) {
|
|
64
|
+
SecurityCaseTarget["Acknowledge"] = "Acknowledge";
|
|
65
|
+
SecurityCaseTarget["Contain"] = "Contain";
|
|
66
|
+
})(SecurityCaseTarget || (exports.SecurityCaseTarget = SecurityCaseTarget = {}));
|
|
67
|
+
// In the order a case meets them.
|
|
68
|
+
exports.SECURITY_CASE_TARGETS = [
|
|
69
|
+
SecurityCaseTarget.Acknowledge,
|
|
70
|
+
SecurityCaseTarget.Contain,
|
|
71
|
+
];
|
|
72
|
+
/*
|
|
73
|
+
* At risk for the last fifth of a target's time: three minutes of a
|
|
74
|
+
* 15-minute target, 48 of a 4-hour one - enough to act on, and late enough
|
|
75
|
+
* that it is not every case.
|
|
76
|
+
*/
|
|
77
|
+
exports.SECURITY_CASE_TARGET_AT_RISK_FRACTION = 0.2;
|
|
78
|
+
// The longest target a priority takes: a year.
|
|
79
|
+
exports.MAX_SECURITY_CASE_TARGET_IN_MINUTES = 365 * 24 * 60;
|
|
80
|
+
const MINUTE_IN_MS = 60 * 1000;
|
|
81
|
+
exports.SECURITY_CASE_TARGET_COLUMNS = {
|
|
82
|
+
[SecurityCaseTarget.Acknowledge]: {
|
|
83
|
+
priorityColumn: "acknowledgeWithinInMinutes",
|
|
84
|
+
dueColumn: "acknowledgeDueAt",
|
|
85
|
+
warnedColumn: "acknowledgeWarnedAt",
|
|
86
|
+
missedColumn: "acknowledgeMissedAt",
|
|
87
|
+
},
|
|
88
|
+
[SecurityCaseTarget.Contain]: {
|
|
89
|
+
priorityColumn: "containWithinInMinutes",
|
|
90
|
+
dueColumn: "containDueAt",
|
|
91
|
+
warnedColumn: "containWarnedAt",
|
|
92
|
+
missedColumn: "containMissedAt",
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
// Where a case stands against one target.
|
|
96
|
+
var SecurityCaseTargetState;
|
|
97
|
+
(function (SecurityCaseTargetState) {
|
|
98
|
+
// No due time: the priority has no target, or it was met as the case opened.
|
|
99
|
+
SecurityCaseTargetState["None"] = "None";
|
|
100
|
+
SecurityCaseTargetState["OnTrack"] = "OnTrack";
|
|
101
|
+
// In the target's last fifth, not met yet.
|
|
102
|
+
SecurityCaseTargetState["AtRisk"] = "AtRisk";
|
|
103
|
+
// Past its due time, not met yet.
|
|
104
|
+
SecurityCaseTargetState["Missed"] = "Missed";
|
|
105
|
+
// Met by its due time.
|
|
106
|
+
SecurityCaseTargetState["Met"] = "Met";
|
|
107
|
+
// Met, but after its due time.
|
|
108
|
+
SecurityCaseTargetState["MetLate"] = "MetLate";
|
|
109
|
+
})(SecurityCaseTargetState || (exports.SecurityCaseTargetState = SecurityCaseTargetState = {}));
|
|
110
|
+
function toDate(value) {
|
|
111
|
+
if (value === null || value === undefined || value === "") {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
115
|
+
return Number.isFinite(date.getTime()) ? date : null;
|
|
116
|
+
}
|
|
117
|
+
function addMinutes(date, minutes) {
|
|
118
|
+
return new Date(date.getTime() + minutes * MINUTE_IN_MS);
|
|
119
|
+
}
|
|
120
|
+
function earliest(dates) {
|
|
121
|
+
let found = null;
|
|
122
|
+
for (const date of dates) {
|
|
123
|
+
if (date && (!found || date.getTime() < found.getTime())) {
|
|
124
|
+
found = date;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return found;
|
|
128
|
+
}
|
|
129
|
+
/*
|
|
130
|
+
* A target as a priority may hold it: a whole number of minutes from 1 to
|
|
131
|
+
* a year. Anything else - empty, zero, negative, fractional, too long, not
|
|
132
|
+
* a number - is no target.
|
|
133
|
+
*/
|
|
134
|
+
function readTargetMinutes(value) {
|
|
135
|
+
const minutes = typeof value === "string" && value.trim() !== ""
|
|
136
|
+
? Number(value)
|
|
137
|
+
: typeof value === "number"
|
|
138
|
+
? value
|
|
139
|
+
: Number.NaN;
|
|
140
|
+
if (!Number.isFinite(minutes) ||
|
|
141
|
+
!Number.isInteger(minutes) ||
|
|
142
|
+
minutes < 1 ||
|
|
143
|
+
minutes > exports.MAX_SECURITY_CASE_TARGET_IN_MINUTES) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return minutes;
|
|
147
|
+
}
|
|
148
|
+
// A priority's target for one of the two, in minutes, or null for none.
|
|
149
|
+
function getTargetMinutes(priority, target) {
|
|
150
|
+
if (!priority) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
return readTargetMinutes(priority[exports.SECURITY_CASE_TARGET_COLUMNS[target].priorityColumn]);
|
|
154
|
+
}
|
|
155
|
+
// Whether a priority has either target.
|
|
156
|
+
function hasTargets(priority) {
|
|
157
|
+
return exports.SECURITY_CASE_TARGETS.some((target) => {
|
|
158
|
+
return getTargetMinutes(priority, target) !== null;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// When a target was met: acknowledged; contained, or closed.
|
|
162
|
+
function getTargetMetAt(securityCase, target) {
|
|
163
|
+
if (target === SecurityCaseTarget.Acknowledge) {
|
|
164
|
+
return toDate(securityCase.acknowledgedAt);
|
|
165
|
+
}
|
|
166
|
+
return earliest([
|
|
167
|
+
toDate(securityCase.containedAt),
|
|
168
|
+
toDate(securityCase.closedAt),
|
|
169
|
+
]);
|
|
170
|
+
}
|
|
171
|
+
function getDueAt(securityCase, target) {
|
|
172
|
+
return toDate(securityCase[exports.SECURITY_CASE_TARGET_COLUMNS[target].dueColumn]);
|
|
173
|
+
}
|
|
174
|
+
function getWarnedAt(securityCase, target) {
|
|
175
|
+
return toDate(securityCase[exports.SECURITY_CASE_TARGET_COLUMNS[target].warnedColumn]);
|
|
176
|
+
}
|
|
177
|
+
function getMissedAt(securityCase, target) {
|
|
178
|
+
return toDate(securityCase[exports.SECURITY_CASE_TARGET_COLUMNS[target].missedColumn]);
|
|
179
|
+
}
|
|
180
|
+
/*
|
|
181
|
+
* When a target is at risk from: its due time less the last fifth of the
|
|
182
|
+
* priority's target. Null without a due time or a target to take the fifth
|
|
183
|
+
* of; never before the case opened.
|
|
184
|
+
*/
|
|
185
|
+
function getAtRiskAt(data) {
|
|
186
|
+
if (!data.dueAt || data.targetInMinutes === null) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
const atRiskAt = new Date(data.dueAt.getTime() -
|
|
190
|
+
Math.round(data.targetInMinutes *
|
|
191
|
+
exports.SECURITY_CASE_TARGET_AT_RISK_FRACTION *
|
|
192
|
+
MINUTE_IN_MS));
|
|
193
|
+
const openedAt = toDate(data.openedAt);
|
|
194
|
+
return openedAt && atRiskAt.getTime() < openedAt.getTime()
|
|
195
|
+
? openedAt
|
|
196
|
+
: atRiskAt;
|
|
197
|
+
}
|
|
198
|
+
// Where a case stands against one target at `now`.
|
|
199
|
+
function readSecurityCaseTarget(data) {
|
|
200
|
+
const { securityCase, target, now } = data;
|
|
201
|
+
const dueAt = getDueAt(securityCase, target);
|
|
202
|
+
const metAt = getTargetMetAt(securityCase, target);
|
|
203
|
+
const targetInMinutes = getTargetMinutes(data.priority, target);
|
|
204
|
+
const atRiskAt = getAtRiskAt({
|
|
205
|
+
dueAt,
|
|
206
|
+
targetInMinutes,
|
|
207
|
+
openedAt: toDate(securityCase.createdAt),
|
|
208
|
+
});
|
|
209
|
+
const reading = {
|
|
210
|
+
target,
|
|
211
|
+
state: SecurityCaseTargetState.None,
|
|
212
|
+
dueAt,
|
|
213
|
+
atRiskAt,
|
|
214
|
+
metAt,
|
|
215
|
+
targetInMinutes,
|
|
216
|
+
minutes: null,
|
|
217
|
+
};
|
|
218
|
+
if (!dueAt) {
|
|
219
|
+
return reading;
|
|
220
|
+
}
|
|
221
|
+
const minutesBetween = (from, to) => {
|
|
222
|
+
return Math.max(0, (to.getTime() - from.getTime()) / MINUTE_IN_MS);
|
|
223
|
+
};
|
|
224
|
+
if (metAt) {
|
|
225
|
+
const isLate = metAt.getTime() > dueAt.getTime();
|
|
226
|
+
return Object.assign(Object.assign({}, reading), { state: isLate
|
|
227
|
+
? SecurityCaseTargetState.MetLate
|
|
228
|
+
: SecurityCaseTargetState.Met, minutes: isLate
|
|
229
|
+
? minutesBetween(dueAt, metAt)
|
|
230
|
+
: minutesBetween(metAt, dueAt) });
|
|
231
|
+
}
|
|
232
|
+
if (now.getTime() >= dueAt.getTime() ||
|
|
233
|
+
getMissedAt(securityCase, target) !== null) {
|
|
234
|
+
return Object.assign(Object.assign({}, reading), { state: SecurityCaseTargetState.Missed, minutes: minutesBetween(dueAt, now) });
|
|
235
|
+
}
|
|
236
|
+
return Object.assign(Object.assign({}, reading), { state: atRiskAt && now.getTime() >= atRiskAt.getTime()
|
|
237
|
+
? SecurityCaseTargetState.AtRisk
|
|
238
|
+
: SecurityCaseTargetState.OnTrack, minutes: minutesBetween(now, dueAt) });
|
|
239
|
+
}
|
|
240
|
+
// Both targets of a case, acknowledge first.
|
|
241
|
+
function readSecurityCaseTargets(data) {
|
|
242
|
+
return exports.SECURITY_CASE_TARGETS.map((target) => {
|
|
243
|
+
return readSecurityCaseTarget(Object.assign(Object.assign({}, data), { target }));
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
// Whether a reading is a target the case still has to meet.
|
|
247
|
+
function isPendingTarget(reading) {
|
|
248
|
+
return (reading.state === SecurityCaseTargetState.OnTrack ||
|
|
249
|
+
reading.state === SecurityCaseTargetState.AtRisk ||
|
|
250
|
+
reading.state === SecurityCaseTargetState.Missed);
|
|
251
|
+
}
|
|
252
|
+
/*
|
|
253
|
+
* The target a case is working against now: of those not met yet, the one
|
|
254
|
+
* due first - a missed one before any other. What the case's header and the
|
|
255
|
+
* case lists show. Null when nothing is pending.
|
|
256
|
+
*/
|
|
257
|
+
function getNextPendingTarget(readings) {
|
|
258
|
+
let next = null;
|
|
259
|
+
for (const reading of readings) {
|
|
260
|
+
if (!isPendingTarget(reading) || !reading.dueAt) {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (!next || reading.dueAt.getTime() < next.dueAt.getTime()) {
|
|
264
|
+
next = reading;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return next;
|
|
268
|
+
}
|
|
269
|
+
// ---------- What the case's service writes ----------
|
|
270
|
+
/*
|
|
271
|
+
* The due times of a case opening at `openedAt` at `priority`: each target
|
|
272
|
+
* from now, unless the case meets it as it opens.
|
|
273
|
+
*/
|
|
274
|
+
function getDueTimesForNewCase(data) {
|
|
275
|
+
const moments = {
|
|
276
|
+
acknowledgedAt: data.acknowledgedAt || null,
|
|
277
|
+
containedAt: data.containedAt || null,
|
|
278
|
+
closedAt: data.closedAt || null,
|
|
279
|
+
};
|
|
280
|
+
const dueFor = (target) => {
|
|
281
|
+
const minutes = getTargetMinutes(data.priority, target);
|
|
282
|
+
if (minutes === null || getTargetMetAt(moments, target)) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
return addMinutes(data.openedAt, minutes);
|
|
286
|
+
};
|
|
287
|
+
return {
|
|
288
|
+
acknowledgeDueAt: dueFor(SecurityCaseTarget.Acknowledge),
|
|
289
|
+
containDueAt: dueFor(SecurityCaseTarget.Contain),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
/*
|
|
293
|
+
* One target's due time after the case's priority changed: undefined when
|
|
294
|
+
* it stays as it is, null when it is taken away. See the rules at the top.
|
|
295
|
+
*/
|
|
296
|
+
function getDueTimeAfterPriorityChange(data) {
|
|
297
|
+
if (data.isSettled) {
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
300
|
+
if (!data.dueAt) {
|
|
301
|
+
return data.newTargetInMinutes === null
|
|
302
|
+
? undefined
|
|
303
|
+
: addMinutes(data.now, data.newTargetInMinutes);
|
|
304
|
+
}
|
|
305
|
+
if (data.newTargetInMinutes === null) {
|
|
306
|
+
return data.isRising ? undefined : null;
|
|
307
|
+
}
|
|
308
|
+
if (data.isRising) {
|
|
309
|
+
const fromNow = addMinutes(data.now, data.newTargetInMinutes);
|
|
310
|
+
return fromNow.getTime() < data.dueAt.getTime() ? fromNow : undefined;
|
|
311
|
+
}
|
|
312
|
+
const fromOpening = addMinutes(data.openedAt, data.newTargetInMinutes);
|
|
313
|
+
return fromOpening.getTime() > data.dueAt.getTime() ? fromOpening : undefined;
|
|
314
|
+
}
|
|
315
|
+
// Both targets' due times after a priority change; only what changes.
|
|
316
|
+
function getDueTimesAfterPriorityChange(data) {
|
|
317
|
+
const write = {};
|
|
318
|
+
const openedAt = toDate(data.securityCase.createdAt) || data.now;
|
|
319
|
+
for (const target of exports.SECURITY_CASE_TARGETS) {
|
|
320
|
+
const columns = exports.SECURITY_CASE_TARGET_COLUMNS[target];
|
|
321
|
+
const next = getDueTimeAfterPriorityChange({
|
|
322
|
+
dueAt: getDueAt(data.securityCase, target),
|
|
323
|
+
isSettled: getTargetMetAt(data.securityCase, target) !== null ||
|
|
324
|
+
getMissedAt(data.securityCase, target) !== null,
|
|
325
|
+
isRising: data.isRising,
|
|
326
|
+
newTargetInMinutes: getTargetMinutes(data.newPriority, target),
|
|
327
|
+
openedAt,
|
|
328
|
+
now: data.now,
|
|
329
|
+
});
|
|
330
|
+
if (next === undefined) {
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
write[columns.dueColumn] = next;
|
|
334
|
+
// A due time that moved has not been warned about yet.
|
|
335
|
+
write[columns.warnedColumn] = null;
|
|
336
|
+
}
|
|
337
|
+
return write;
|
|
338
|
+
}
|
|
339
|
+
/*
|
|
340
|
+
* A reopened case's contain target, started again from `now`, with nothing
|
|
341
|
+
* said about it yet. Null due time for a priority without one.
|
|
342
|
+
*/
|
|
343
|
+
function getContainTargetAfterReopen(data) {
|
|
344
|
+
const minutes = getTargetMinutes(data.priority, SecurityCaseTarget.Contain);
|
|
345
|
+
return {
|
|
346
|
+
containDueAt: minutes === null ? null : addMinutes(data.now, minutes),
|
|
347
|
+
containWarnedAt: null,
|
|
348
|
+
containMissedAt: null,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
/*
|
|
352
|
+
* The earliest due time of a target the case has not met, a missed one
|
|
353
|
+
* among them: what the case lists sort by. Null when none is left.
|
|
354
|
+
*/
|
|
355
|
+
function getNextDueAt(securityCase) {
|
|
356
|
+
return earliest(exports.SECURITY_CASE_TARGETS.map((target) => {
|
|
357
|
+
return getTargetMetAt(securityCase, target)
|
|
358
|
+
? null
|
|
359
|
+
: getDueAt(securityCase, target);
|
|
360
|
+
}));
|
|
361
|
+
}
|
|
362
|
+
/*
|
|
363
|
+
* When the every-minute check must next look at the case: for each target
|
|
364
|
+
* not met and not missed, its at-risk moment until it has been warned
|
|
365
|
+
* about, then its due time. Null when there is nothing left to say.
|
|
366
|
+
*/
|
|
367
|
+
function getNextTargetCheckAt(data) {
|
|
368
|
+
const moments = [];
|
|
369
|
+
for (const target of exports.SECURITY_CASE_TARGETS) {
|
|
370
|
+
const dueAt = getDueAt(data.securityCase, target);
|
|
371
|
+
if (!dueAt ||
|
|
372
|
+
getTargetMetAt(data.securityCase, target) ||
|
|
373
|
+
getMissedAt(data.securityCase, target)) {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
const atRiskAt = getAtRiskAt({
|
|
377
|
+
dueAt,
|
|
378
|
+
targetInMinutes: getTargetMinutes(data.priority, target),
|
|
379
|
+
openedAt: toDate(data.securityCase.createdAt),
|
|
380
|
+
});
|
|
381
|
+
moments.push(atRiskAt && !getWarnedAt(data.securityCase, target) ? atRiskAt : dueAt);
|
|
382
|
+
}
|
|
383
|
+
return earliest(moments);
|
|
384
|
+
}
|
|
385
|
+
// The case's two bookkeeping columns, from what it holds.
|
|
386
|
+
function getTargetBookkeeping(data) {
|
|
387
|
+
return {
|
|
388
|
+
nextDueAt: getNextDueAt(data.securityCase),
|
|
389
|
+
nextTargetCheckAt: getNextTargetCheckAt(data),
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
// ---------- What the every-minute check says ----------
|
|
393
|
+
var SecurityCaseTargetAlertKind;
|
|
394
|
+
(function (SecurityCaseTargetAlertKind) {
|
|
395
|
+
SecurityCaseTargetAlertKind["AtRisk"] = "AtRisk";
|
|
396
|
+
SecurityCaseTargetAlertKind["Missed"] = "Missed";
|
|
397
|
+
})(SecurityCaseTargetAlertKind || (exports.SecurityCaseTargetAlertKind = SecurityCaseTargetAlertKind = {}));
|
|
398
|
+
/*
|
|
399
|
+
* What is to be said about a case at `now`: a target past its due time and
|
|
400
|
+
* not missed yet, missed; one in its last fifth and not warned about yet,
|
|
401
|
+
* at risk. A target already past its due time is only ever missed - a
|
|
402
|
+
* warning that comes too late is not sent.
|
|
403
|
+
*/
|
|
404
|
+
function getTargetAlertsDue(data) {
|
|
405
|
+
const alerts = [];
|
|
406
|
+
for (const target of exports.SECURITY_CASE_TARGETS) {
|
|
407
|
+
const dueAt = getDueAt(data.securityCase, target);
|
|
408
|
+
if (!dueAt ||
|
|
409
|
+
getTargetMetAt(data.securityCase, target) ||
|
|
410
|
+
getMissedAt(data.securityCase, target)) {
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
const targetInMinutes = getTargetMinutes(data.priority, target);
|
|
414
|
+
if (data.now.getTime() >= dueAt.getTime()) {
|
|
415
|
+
alerts.push({
|
|
416
|
+
target,
|
|
417
|
+
kind: SecurityCaseTargetAlertKind.Missed,
|
|
418
|
+
dueAt,
|
|
419
|
+
targetInMinutes,
|
|
420
|
+
});
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
const atRiskAt = getAtRiskAt({
|
|
424
|
+
dueAt,
|
|
425
|
+
targetInMinutes,
|
|
426
|
+
openedAt: toDate(data.securityCase.createdAt),
|
|
427
|
+
});
|
|
428
|
+
if (atRiskAt &&
|
|
429
|
+
data.now.getTime() >= atRiskAt.getTime() &&
|
|
430
|
+
!getWarnedAt(data.securityCase, target)) {
|
|
431
|
+
alerts.push({
|
|
432
|
+
target,
|
|
433
|
+
kind: SecurityCaseTargetAlertKind.AtRisk,
|
|
434
|
+
dueAt,
|
|
435
|
+
targetInMinutes,
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return alerts;
|
|
440
|
+
}
|
|
441
|
+
// The stamps that record alerts said at `now`.
|
|
442
|
+
function getAlertStamps(alerts, now) {
|
|
443
|
+
const write = {};
|
|
444
|
+
for (const alert of alerts) {
|
|
445
|
+
const columns = exports.SECURITY_CASE_TARGET_COLUMNS[alert.target];
|
|
446
|
+
write[alert.kind === SecurityCaseTargetAlertKind.Missed
|
|
447
|
+
? columns.missedColumn
|
|
448
|
+
: columns.warnedColumn] = now;
|
|
449
|
+
}
|
|
450
|
+
return write;
|
|
451
|
+
}
|
|
452
|
+
// ---------- Words ----------
|
|
453
|
+
/*
|
|
454
|
+
* A duration in English, by its two largest units: "15 minutes", "1 hour",
|
|
455
|
+
* "1 hour 30 minutes", "3 days", "1 day 4 hours". For the server's
|
|
456
|
+
* messages; the dashboard says durations in the reader's language.
|
|
457
|
+
*/
|
|
458
|
+
function describeTargetDuration(minutes) {
|
|
459
|
+
const total = Math.max(0, Math.round(minutes));
|
|
460
|
+
const unit = (count, word) => {
|
|
461
|
+
return `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
462
|
+
};
|
|
463
|
+
if (total < 60) {
|
|
464
|
+
return unit(total, "minute");
|
|
465
|
+
}
|
|
466
|
+
const hours = Math.floor(total / 60);
|
|
467
|
+
const restMinutes = total % 60;
|
|
468
|
+
if (hours < 24) {
|
|
469
|
+
return restMinutes > 0
|
|
470
|
+
? `${unit(hours, "hour")} ${unit(restMinutes, "minute")}`
|
|
471
|
+
: unit(hours, "hour");
|
|
472
|
+
}
|
|
473
|
+
const days = Math.floor(hours / 24);
|
|
474
|
+
const restHours = hours % 24;
|
|
475
|
+
return restHours > 0
|
|
476
|
+
? `${unit(days, "day")} ${unit(restHours, "hour")}`
|
|
477
|
+
: unit(days, "day");
|
|
478
|
+
}
|
|
479
|
+
// A target's verb, in the server's messages: "acknowledge", "contain".
|
|
480
|
+
function getTargetVerb(target) {
|
|
481
|
+
return target === SecurityCaseTarget.Acknowledge ? "acknowledge" : "contain";
|
|
482
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import commonJsModule from "./SecurityCaseTargets.js";
|
|
2
|
+
export const MAX_SECURITY_CASE_TARGET_IN_MINUTES = commonJsModule.MAX_SECURITY_CASE_TARGET_IN_MINUTES;
|
|
3
|
+
export const SECURITY_CASE_TARGETS = commonJsModule.SECURITY_CASE_TARGETS;
|
|
4
|
+
export const SECURITY_CASE_TARGET_AT_RISK_FRACTION = commonJsModule.SECURITY_CASE_TARGET_AT_RISK_FRACTION;
|
|
5
|
+
export const SECURITY_CASE_TARGET_COLUMNS = commonJsModule.SECURITY_CASE_TARGET_COLUMNS;
|
|
6
|
+
export const SecurityCaseTarget = commonJsModule.SecurityCaseTarget;
|
|
7
|
+
export const SecurityCaseTargetAlertKind = commonJsModule.SecurityCaseTargetAlertKind;
|
|
8
|
+
export const SecurityCaseTargetState = commonJsModule.SecurityCaseTargetState;
|
|
9
|
+
export const describeTargetDuration = commonJsModule.describeTargetDuration;
|
|
10
|
+
export const getAlertStamps = commonJsModule.getAlertStamps;
|
|
11
|
+
export const getAtRiskAt = commonJsModule.getAtRiskAt;
|
|
12
|
+
export const getContainTargetAfterReopen = commonJsModule.getContainTargetAfterReopen;
|
|
13
|
+
export const getDueTimeAfterPriorityChange = commonJsModule.getDueTimeAfterPriorityChange;
|
|
14
|
+
export const getDueTimesAfterPriorityChange = commonJsModule.getDueTimesAfterPriorityChange;
|
|
15
|
+
export const getDueTimesForNewCase = commonJsModule.getDueTimesForNewCase;
|
|
16
|
+
export const getNextDueAt = commonJsModule.getNextDueAt;
|
|
17
|
+
export const getNextPendingTarget = commonJsModule.getNextPendingTarget;
|
|
18
|
+
export const getNextTargetCheckAt = commonJsModule.getNextTargetCheckAt;
|
|
19
|
+
export const getTargetAlertsDue = commonJsModule.getTargetAlertsDue;
|
|
20
|
+
export const getTargetBookkeeping = commonJsModule.getTargetBookkeeping;
|
|
21
|
+
export const getTargetMetAt = commonJsModule.getTargetMetAt;
|
|
22
|
+
export const getTargetMinutes = commonJsModule.getTargetMinutes;
|
|
23
|
+
export const getTargetVerb = commonJsModule.getTargetVerb;
|
|
24
|
+
export const hasTargets = commonJsModule.hasTargets;
|
|
25
|
+
export const isPendingTarget = commonJsModule.isPendingTarget;
|
|
26
|
+
export const readSecurityCaseTarget = commonJsModule.readSecurityCaseTarget;
|
|
27
|
+
export const readSecurityCaseTargets = commonJsModule.readSecurityCaseTargets;
|
|
28
|
+
export const readTargetMinutes = commonJsModule.readTargetMinutes;
|