@oneuptime/common 14.0.93 → 14.0.94
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/Alert.d.mts +2 -0
- package/Models/DatabaseModels/Alert.d.ts +2 -0
- package/Models/DatabaseModels/Alert.js +54 -0
- package/Models/DatabaseModels/CloudAccount.d.mts +29 -0
- package/Models/DatabaseModels/CloudAccount.d.ts +29 -0
- package/Models/DatabaseModels/CloudAccount.js +546 -0
- package/Models/DatabaseModels/CloudAccount.mjs +2 -0
- package/Models/DatabaseModels/CloudResource.d.mts +8 -0
- package/Models/DatabaseModels/CloudResource.d.ts +8 -0
- package/Models/DatabaseModels/CloudResource.js +169 -0
- package/Models/DatabaseModels/CloudResourceLabelRule.d.mts +1 -0
- package/Models/DatabaseModels/CloudResourceLabelRule.d.ts +1 -0
- package/Models/DatabaseModels/CloudResourceLabelRule.js +40 -0
- package/Models/DatabaseModels/CloudResourceOwnerRule.d.mts +1 -0
- package/Models/DatabaseModels/CloudResourceOwnerRule.d.ts +1 -0
- package/Models/DatabaseModels/CloudResourceOwnerRule.js +40 -0
- package/Models/DatabaseModels/Incident.d.mts +2 -0
- package/Models/DatabaseModels/Incident.d.ts +2 -0
- package/Models/DatabaseModels/Incident.js +54 -0
- package/Models/DatabaseModels/Index.js +2 -0
- package/Models/DatabaseModels/Monitor.d.mts +2 -0
- package/Models/DatabaseModels/Monitor.d.ts +2 -0
- package/Models/DatabaseModels/Monitor.js +54 -0
- package/Models/DatabaseModels/OpenSourceDeployment.d.mts +1 -0
- package/Models/DatabaseModels/OpenSourceDeployment.d.ts +1 -0
- package/Models/DatabaseModels/OpenSourceDeployment.js +25 -6
- package/Models/DatabaseModels/ScheduledMaintenance.d.mts +1 -0
- package/Models/DatabaseModels/ScheduledMaintenance.d.ts +1 -0
- package/Models/DatabaseModels/ScheduledMaintenance.js +50 -0
- package/Types/AI/AiAffectedResources.d.mts +40 -0
- package/Types/AI/AiAffectedResources.d.ts +40 -0
- package/Types/AI/AiAffectedResources.js +292 -0
- package/Types/AI/AiAffectedResources.mjs +10 -0
- package/Types/Cloud/CloudAccountSummary.d.mts +25 -0
- package/Types/Cloud/CloudAccountSummary.d.ts +25 -0
- package/Types/Cloud/CloudAccountSummary.js +114 -0
- package/Types/Cloud/CloudAccountSummary.mjs +5 -0
- package/Types/Cloud/CloudEndpointMatch.d.mts +26 -0
- package/Types/Cloud/CloudEndpointMatch.d.ts +26 -0
- package/Types/Cloud/CloudEndpointMatch.js +134 -0
- package/Types/Cloud/CloudEndpointMatch.mjs +5 -0
- package/Types/Cloud/CloudInventory.d.mts +34 -0
- package/Types/Cloud/CloudInventory.d.ts +34 -0
- package/Types/Cloud/CloudInventory.js +362 -0
- package/Types/Cloud/CloudInventory.mjs +22 -0
- package/Types/Cloud/CloudResourceCatalog.d.mts +2 -0
- package/Types/Cloud/CloudResourceCatalog.d.ts +2 -0
- package/Types/Cloud/CloudResourceCatalog.js +29 -1
- package/Types/Cloud/CloudResourceCatalog.mjs +2 -0
- package/Types/Cloud/CloudResourceIndex.d.mts +44 -0
- package/Types/Cloud/CloudResourceIndex.d.ts +44 -0
- package/Types/Cloud/CloudResourceIndex.js +191 -0
- package/Types/Cloud/CloudResourceIndex.mjs +4 -0
- package/Types/CloudConnection/CloudConnectionCatalog.d.mts +3 -0
- package/Types/CloudConnection/CloudConnectionCatalog.d.ts +3 -0
- package/Types/CloudConnection/CloudConnectionCatalog.js +70 -12
- package/Types/CloudConnection/CloudConnectionCatalog.mjs +2 -0
- package/Types/CloudConnection/CloudConnectionPaste.js +7 -1
- package/Types/CloudConnection/CloudConnectionSetupCommands.d.mts +43 -3
- package/Types/CloudConnection/CloudConnectionSetupCommands.d.ts +43 -3
- package/Types/CloudConnection/CloudConnectionSetupCommands.js +280 -30
- package/Types/CloudConnection/CloudConnectionSetupCommands.mjs +14 -0
- package/Types/CloudConnection/CloudConnectionTest.d.mts +1 -0
- package/Types/CloudConnection/CloudConnectionTest.d.ts +1 -0
- package/Types/CloudConnection/CloudConnectionTest.js +1 -0
- package/Types/Dashboard/DashboardComponents/DashboardTableComponent.d.mts +19 -0
- package/Types/Dashboard/DashboardComponents/DashboardTableComponent.d.ts +19 -0
- package/Types/Dashboard/DashboardComponents/DashboardTableComponent.js +27 -1
- package/Types/Dashboard/DashboardComponents/DashboardTableComponent.mjs +3 -0
- package/Types/Date.d.mts +1 -0
- package/Types/Date.d.ts +1 -0
- package/Types/Date.js +32 -6
- package/Types/DateLanguage.d.mts +2 -0
- package/Types/DateLanguage.d.ts +2 -0
- package/Types/DateLanguage.js +67 -12
- package/Types/DateLanguage.mjs +2 -0
- package/Types/Domain.d.mts +2 -0
- package/Types/Domain.d.ts +2 -0
- package/Types/Domain.js +27 -0
- package/Types/Email/EmailTemplateType.d.mts +1 -0
- package/Types/Email/EmailTemplateType.d.ts +1 -0
- package/Types/Email/EmailTemplateType.js +1 -0
- package/Types/Email.d.mts +1 -0
- package/Types/Email.d.ts +1 -0
- package/Types/Email.js +16 -0
- package/Types/Monitor/ExternalStatusPageMonitor/ExternalStatusPageMonitorResponse.d.mts +4 -0
- package/Types/Monitor/ExternalStatusPageMonitor/ExternalStatusPageMonitorResponse.d.ts +4 -0
- package/Types/Monitor/MonitorStepExternalStatusPageMonitor.d.mts +3 -0
- package/Types/Monitor/MonitorStepExternalStatusPageMonitor.d.ts +3 -0
- package/Types/Monitor/MonitorStepExternalStatusPageMonitor.js +35 -0
- package/Types/Monitor/MonitorTemplateSyncField.js +6 -1
- package/Types/Monitor/UptimeBarTooltipMaintenance.d.mts +15 -0
- package/Types/Monitor/UptimeBarTooltipMaintenance.d.ts +15 -0
- package/Types/Monitor/UptimeBarTooltipMaintenance.js +2 -0
- package/Types/Monitor/UptimeBarTooltipMaintenance.mjs +1 -0
- package/Types/Monitor/UptimeHistoryLabels.d.mts +5 -0
- package/Types/Monitor/UptimeHistoryLabels.d.ts +5 -0
- package/Types/Monitor/UptimeHistoryLabels.js +5 -0
- package/Types/ReadingDirection.d.mts +10 -0
- package/Types/ReadingDirection.d.ts +10 -0
- package/Types/ReadingDirection.js +171 -0
- package/Types/ReadingDirection.mjs +10 -0
- package/Types/Rules/RuleCriteriaFieldRegistry.js +2 -0
- package/Types/Runbook/HttpStepVariables.d.mts +8 -0
- package/Types/Runbook/HttpStepVariables.d.ts +8 -0
- package/Types/Runbook/HttpStepVariables.js +109 -0
- package/Types/Runbook/HttpStepVariables.mjs +5 -0
- package/Types/Runbook/RunbookStep.d.mts +1 -0
- package/Types/Runbook/RunbookStep.d.ts +1 -0
- package/Types/Runbook/RunnerFeatures.d.mts +1 -0
- package/Types/Runbook/RunnerFeatures.d.ts +1 -0
- package/Types/Runbook/RunnerFeatures.js +15 -3
- package/Types/Runbook/RunnerFeatures.mjs +1 -0
- package/Types/Runbook/SshHostKey.d.mts +22 -0
- package/Types/Runbook/SshHostKey.d.ts +22 -0
- package/Types/Runbook/SshHostKey.js +201 -0
- package/Types/Runbook/SshHostKey.mjs +10 -0
- package/Types/Runner/CodeRepositoryRunner.js +2 -3
- package/Types/Runner/GlobalAIAgentsGone.d.mts +1 -0
- package/Types/Runner/GlobalAIAgentsGone.d.ts +1 -0
- package/Types/Runner/GlobalAIAgentsGone.js +19 -0
- package/Types/Runner/GlobalAIAgentsGone.mjs +2 -0
- package/Types/Runner/GlobalRunnerWork.d.mts +1 -0
- package/Types/Runner/GlobalRunnerWork.d.ts +1 -0
- package/Types/Runner/GlobalRunnerWork.js +21 -1
- package/Types/Runner/GlobalRunnerWork.mjs +1 -0
- package/Types/SSO/SignInMethods.d.mts +31 -0
- package/Types/SSO/SignInMethods.d.ts +31 -0
- package/Types/SSO/SignInMethods.js +160 -0
- package/Types/SSO/SignInMethods.mjs +8 -0
- package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.d.mts +24 -0
- package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.d.ts +24 -0
- package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.js +159 -0
- package/Types/ScheduledMaintenance/ScheduledMaintenancePublication.mjs +8 -0
- package/Types/StatusPage/StatusPageLanguage.d.mts +6 -0
- package/Types/StatusPage/StatusPageLanguage.d.ts +6 -0
- package/Types/StatusPage/StatusPageLanguage.js +17 -1
- package/Types/StatusPage/StatusPageLanguage.mjs +1 -0
- package/Types/Workflow/WorkflowPlan.d.mts +7 -0
- package/Types/Workflow/WorkflowPlan.d.ts +7 -0
- package/Types/Workflow/WorkflowPlan.js +39 -0
- package/Types/Workflow/WorkflowPlan.mjs +3 -0
- package/Types/Workspace/WorkspaceMessagePayload.d.mts +11 -0
- package/Types/Workspace/WorkspaceMessagePayload.d.ts +11 -0
- package/Utils/Dashboard/TableThresholds.d.mts +44 -0
- package/Utils/Dashboard/TableThresholds.d.ts +44 -0
- package/Utils/Dashboard/TableThresholds.js +288 -0
- package/Utils/Dashboard/TableThresholds.mjs +17 -0
- package/Utils/Dashboard/ValueWidgetSeries.d.mts +6 -0
- package/Utils/Dashboard/ValueWidgetSeries.d.ts +6 -0
- package/Utils/Dashboard/ValueWidgetSeries.js +70 -1
- package/Utils/Dashboard/ValueWidgetSeries.mjs +2 -0
- package/Utils/DeveloperDocs/ResourceProfiles.js +16 -0
- package/Utils/DeveloperDocs/TerraformSchema.d.mts +1 -0
- package/Utils/DeveloperDocs/TerraformSchema.d.ts +1 -0
- package/Utils/DeveloperDocs/TerraformSchema.js +17 -0
- package/Utils/DeveloperDocs/TerraformSchema.mjs +1 -0
- package/Utils/Monitor/ExternalStatusPageComponentNames.d.mts +17 -0
- package/Utils/Monitor/ExternalStatusPageComponentNames.d.ts +17 -0
- package/Utils/Monitor/ExternalStatusPageComponentNames.js +274 -0
- package/Utils/Monitor/ExternalStatusPageComponentNames.mjs +6 -0
- package/Utils/Monitor/ExternalStatusPageReading.d.mts +35 -0
- package/Utils/Monitor/ExternalStatusPageReading.d.ts +35 -0
- package/Utils/Monitor/ExternalStatusPageReading.js +380 -0
- package/Utils/Monitor/ExternalStatusPageReading.mjs +6 -0
- package/Utils/Monitor/ExternalStatusPageScope.d.mts +43 -0
- package/Utils/Monitor/ExternalStatusPageScope.d.ts +43 -0
- package/Utils/Monitor/ExternalStatusPageScope.js +213 -0
- package/Utils/Monitor/ExternalStatusPageScope.mjs +4 -0
- package/Utils/Runbook/SshHostKeyFingerprint.d.mts +8 -0
- package/Utils/Runbook/SshHostKeyFingerprint.d.ts +8 -0
- package/Utils/Runbook/SshHostKeyFingerprint.js +83 -0
- package/Utils/Runbook/SshHostKeyFingerprint.mjs +5 -0
- package/Utils/ScheduledMaintenanceStart.d.mts +6 -0
- package/Utils/ScheduledMaintenanceStart.d.ts +6 -0
- package/Utils/ScheduledMaintenanceStart.js +15 -0
- package/Utils/StatusPage/HistoryChartBarColors.d.mts +2 -0
- package/Utils/StatusPage/HistoryChartBarColors.d.ts +2 -0
- package/Utils/StatusPage/HistoryChartBarColors.js +12 -1
- package/Utils/StatusPage/HistoryChartBarColors.mjs +2 -0
- package/Utils/Telemetry/ChangeEventFields.d.mts +19 -1
- package/Utils/Telemetry/ChangeEventFields.d.ts +19 -1
- package/Utils/Telemetry/ChangeEventFields.js +52 -1
- package/Utils/Uptime/DayUptimeGraphUtil.d.mts +6 -0
- package/Utils/Uptime/DayUptimeGraphUtil.d.ts +6 -0
- package/Utils/Uptime/DayUptimeGraphUtil.js +37 -6
- package/Utils/Uptime/UptimeMaintenanceUtil.d.mts +60 -0
- package/Utils/Uptime/UptimeMaintenanceUtil.d.ts +60 -0
- package/Utils/Uptime/UptimeMaintenanceUtil.js +295 -0
- package/Utils/Uptime/UptimeMaintenanceUtil.mjs +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* WHICH WAY A LANGUAGE IS READ.
|
|
4
|
+
*
|
|
5
|
+
* Persian - the one such language OneUptime is translated into today - is
|
|
6
|
+
* written from right to left, like Arabic, Hebrew and Urdu; every other
|
|
7
|
+
* language of the product from left to right. A page says which on <html
|
|
8
|
+
* dir> (Common/UI/Utils/PageLanguage), and its layout follows: rows and
|
|
9
|
+
* grids run from the right, and Tailwind's left and right utilities mean
|
|
10
|
+
* the start and the end of the line (Common/UI/Styles/
|
|
11
|
+
* TailwindReadingDirection.js).
|
|
12
|
+
*
|
|
13
|
+
* Read from the language tag alone, so a server, a test and every frontend
|
|
14
|
+
* agree without Intl: the script when the tag names one ("az-Arab",
|
|
15
|
+
* "ku-Latn"), the language otherwise.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.getTextReadingDirection = exports.getTextReadingDirectionByMostLetters = exports.TEXT_DIRECTION_SCAN_LENGTH = exports.isRightToLeftLanguage = exports.getReadingDirection = exports.RIGHT_TO_LEFT_SCRIPTS = exports.RIGHT_TO_LEFT_LANGUAGES = exports.RIGHT_TO_LEFT = exports.LEFT_TO_RIGHT = void 0;
|
|
19
|
+
exports.LEFT_TO_RIGHT = "ltr";
|
|
20
|
+
exports.RIGHT_TO_LEFT = "rtl";
|
|
21
|
+
// Languages written from right to left, by their primary subtag.
|
|
22
|
+
exports.RIGHT_TO_LEFT_LANGUAGES = [
|
|
23
|
+
"ar", // Arabic
|
|
24
|
+
"arc", // Aramaic
|
|
25
|
+
"azb", // South Azerbaijani
|
|
26
|
+
"ckb", // Central Kurdish (Sorani)
|
|
27
|
+
"dv", // Dhivehi
|
|
28
|
+
"fa", // Persian
|
|
29
|
+
"glk", // Gilaki
|
|
30
|
+
"he", // Hebrew
|
|
31
|
+
"iw", // Hebrew, the old code
|
|
32
|
+
"ks", // Kashmiri
|
|
33
|
+
"lrc", // Northern Luri
|
|
34
|
+
"mzn", // Mazanderani
|
|
35
|
+
"nqo", // N'Ko
|
|
36
|
+
"prs", // Dari
|
|
37
|
+
"ps", // Pashto
|
|
38
|
+
"sd", // Sindhi
|
|
39
|
+
"syr", // Syriac
|
|
40
|
+
"ug", // Uyghur
|
|
41
|
+
"ur", // Urdu
|
|
42
|
+
"yi", // Yiddish
|
|
43
|
+
];
|
|
44
|
+
// Scripts written from right to left, by their ISO 15924 code.
|
|
45
|
+
exports.RIGHT_TO_LEFT_SCRIPTS = [
|
|
46
|
+
"adlm", // Adlam
|
|
47
|
+
"arab", // Arabic
|
|
48
|
+
"hebr", // Hebrew
|
|
49
|
+
"mand", // Mandaic
|
|
50
|
+
"nkoo", // N'Ko
|
|
51
|
+
"rohg", // Hanifi Rohingya
|
|
52
|
+
"samr", // Samaritan
|
|
53
|
+
"syrc", // Syriac
|
|
54
|
+
"thaa", // Thaana
|
|
55
|
+
];
|
|
56
|
+
const SUBTAG_SEPARATOR_REGEX = /[-_]/;
|
|
57
|
+
// A script subtag is four letters ("Arab", "Latn").
|
|
58
|
+
const SCRIPT_SUBTAG_REGEX = /^[a-z]{4}$/;
|
|
59
|
+
// "fa", "fa-IR", "fa_IR", "az-Arab-IR": a language's subtags, lowercased.
|
|
60
|
+
const getSubtags = (language) => {
|
|
61
|
+
return language
|
|
62
|
+
.trim()
|
|
63
|
+
.toLowerCase()
|
|
64
|
+
.split(SUBTAG_SEPARATOR_REGEX)
|
|
65
|
+
.filter((subtag) => {
|
|
66
|
+
return subtag.length > 0;
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
// Which way `language` is read: left to right unless it is written from the right.
|
|
70
|
+
const getReadingDirection = (language) => {
|
|
71
|
+
if (!language) {
|
|
72
|
+
return exports.LEFT_TO_RIGHT;
|
|
73
|
+
}
|
|
74
|
+
const subtags = getSubtags(language);
|
|
75
|
+
const primary = subtags[0];
|
|
76
|
+
if (!primary) {
|
|
77
|
+
return exports.LEFT_TO_RIGHT;
|
|
78
|
+
}
|
|
79
|
+
// A script subtag, right after the language, decides.
|
|
80
|
+
const script = subtags[1];
|
|
81
|
+
if (script && SCRIPT_SUBTAG_REGEX.test(script)) {
|
|
82
|
+
return exports.RIGHT_TO_LEFT_SCRIPTS.includes(script)
|
|
83
|
+
? exports.RIGHT_TO_LEFT
|
|
84
|
+
: exports.LEFT_TO_RIGHT;
|
|
85
|
+
}
|
|
86
|
+
return exports.RIGHT_TO_LEFT_LANGUAGES.includes(primary)
|
|
87
|
+
? exports.RIGHT_TO_LEFT
|
|
88
|
+
: exports.LEFT_TO_RIGHT;
|
|
89
|
+
};
|
|
90
|
+
exports.getReadingDirection = getReadingDirection;
|
|
91
|
+
const isRightToLeftLanguage = (language) => {
|
|
92
|
+
return (0, exports.getReadingDirection)(language) === exports.RIGHT_TO_LEFT;
|
|
93
|
+
};
|
|
94
|
+
exports.isRightToLeftLanguage = isRightToLeftLanguage;
|
|
95
|
+
/*
|
|
96
|
+
* WHICH WAY A TEXT SOMEONE WROTE IS READ.
|
|
97
|
+
*
|
|
98
|
+
* A team's note, a description or an answer from OneUptime AI is written
|
|
99
|
+
* in whatever language its author wrote it in - an English note on a
|
|
100
|
+
* Persian page, a Persian one on an English page. While it is being typed
|
|
101
|
+
* it reads the way its first letter does, as a browser decides
|
|
102
|
+
* dir="auto": a letter of a right-to-left script makes it right to left,
|
|
103
|
+
* any other letter left to right, and the line does not turn round as the
|
|
104
|
+
* words come. Digits, punctuation and Markdown's own marks ("## ", "- ",
|
|
105
|
+
* "**") decide nothing. Null when there is no letter to go by, so the text
|
|
106
|
+
* follows the page.
|
|
107
|
+
*
|
|
108
|
+
* Only the start of the text is read (TEXT_DIRECTION_SCAN_LENGTH): a log
|
|
109
|
+
* of megabytes is decided by its first letter, not scanned to its end.
|
|
110
|
+
*/
|
|
111
|
+
exports.TEXT_DIRECTION_SCAN_LENGTH = 4096;
|
|
112
|
+
const FIRST_LETTER_REGEX = /\p{L}/u;
|
|
113
|
+
const RIGHT_TO_LEFT_LETTER_REGEX = /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Adlam}\p{Script=Hanifi_Rohingya}\p{Script=Mandaic}\p{Script=Samaritan}]/u;
|
|
114
|
+
// One letter, of any script.
|
|
115
|
+
const LETTER_REGEX = /^\p{L}$/u;
|
|
116
|
+
/*
|
|
117
|
+
* WHICH WAY A TEXT SHOWN ON A PAGE IS READ: the way most of its letters
|
|
118
|
+
* read. A name, a description or a paragraph of a note is shown, not typed,
|
|
119
|
+
* so it can be read as a whole: "`kubectl` را اجرا کنید" and "API پرداخت از
|
|
120
|
+
* کار افتاده" are Persian sentences that start with an English word, and
|
|
121
|
+
* laid out from that first letter their Persian words came out in the
|
|
122
|
+
* wrong order. "Checkout API (EU)" and "Rolled back v2.4.1." read left to
|
|
123
|
+
* right, their full stop at their end. A tie goes to the first letter.
|
|
124
|
+
* Null when there is no letter, so the text follows the page; only the
|
|
125
|
+
* first TEXT_DIRECTION_SCAN_LENGTH characters are read.
|
|
126
|
+
*/
|
|
127
|
+
const getTextReadingDirectionByMostLetters = (text) => {
|
|
128
|
+
if (!text) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
let rightToLeftLetters = 0;
|
|
132
|
+
let leftToRightLetters = 0;
|
|
133
|
+
let firstLetterDirection = null;
|
|
134
|
+
// By code point, so a letter outside the Basic Multilingual Plane counts once.
|
|
135
|
+
for (const character of text.slice(0, exports.TEXT_DIRECTION_SCAN_LENGTH)) {
|
|
136
|
+
if (!LETTER_REGEX.test(character)) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const direction = RIGHT_TO_LEFT_LETTER_REGEX.test(character)
|
|
140
|
+
? exports.RIGHT_TO_LEFT
|
|
141
|
+
: exports.LEFT_TO_RIGHT;
|
|
142
|
+
if (direction === exports.RIGHT_TO_LEFT) {
|
|
143
|
+
rightToLeftLetters++;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
leftToRightLetters++;
|
|
147
|
+
}
|
|
148
|
+
firstLetterDirection = firstLetterDirection || direction;
|
|
149
|
+
}
|
|
150
|
+
if (rightToLeftLetters === leftToRightLetters) {
|
|
151
|
+
return firstLetterDirection;
|
|
152
|
+
}
|
|
153
|
+
return rightToLeftLetters > leftToRightLetters
|
|
154
|
+
? exports.RIGHT_TO_LEFT
|
|
155
|
+
: exports.LEFT_TO_RIGHT;
|
|
156
|
+
};
|
|
157
|
+
exports.getTextReadingDirectionByMostLetters = getTextReadingDirectionByMostLetters;
|
|
158
|
+
const getTextReadingDirection = (text) => {
|
|
159
|
+
if (!text) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const start = text.slice(0, exports.TEXT_DIRECTION_SCAN_LENGTH);
|
|
163
|
+
const letter = FIRST_LETTER_REGEX.exec(start);
|
|
164
|
+
if (!letter) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
return RIGHT_TO_LEFT_LETTER_REGEX.test(letter[0])
|
|
168
|
+
? exports.RIGHT_TO_LEFT
|
|
169
|
+
: exports.LEFT_TO_RIGHT;
|
|
170
|
+
};
|
|
171
|
+
exports.getTextReadingDirection = getTextReadingDirection;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import commonJsModule from "./ReadingDirection.js";
|
|
2
|
+
export const LEFT_TO_RIGHT = commonJsModule.LEFT_TO_RIGHT;
|
|
3
|
+
export const RIGHT_TO_LEFT = commonJsModule.RIGHT_TO_LEFT;
|
|
4
|
+
export const RIGHT_TO_LEFT_LANGUAGES = commonJsModule.RIGHT_TO_LEFT_LANGUAGES;
|
|
5
|
+
export const RIGHT_TO_LEFT_SCRIPTS = commonJsModule.RIGHT_TO_LEFT_SCRIPTS;
|
|
6
|
+
export const TEXT_DIRECTION_SCAN_LENGTH = commonJsModule.TEXT_DIRECTION_SCAN_LENGTH;
|
|
7
|
+
export const getReadingDirection = commonJsModule.getReadingDirection;
|
|
8
|
+
export const getTextReadingDirection = commonJsModule.getTextReadingDirection;
|
|
9
|
+
export const getTextReadingDirectionByMostLetters = commonJsModule.getTextReadingDirectionByMostLetters;
|
|
10
|
+
export const isRightToLeftLanguage = commonJsModule.isRightToLeftLanguage;
|
|
@@ -129,11 +129,13 @@ exports.RULE_CRITERIA_FIELDS_BY_MODEL = {
|
|
|
129
129
|
"matchLabels",
|
|
130
130
|
"nameRegexPattern",
|
|
131
131
|
"descriptionRegexPattern",
|
|
132
|
+
"cloudTagPattern",
|
|
132
133
|
],
|
|
133
134
|
CloudResourceOwnerRule: [
|
|
134
135
|
"matchLabels",
|
|
135
136
|
"nameRegexPattern",
|
|
136
137
|
"descriptionRegexPattern",
|
|
138
|
+
"cloudTagPattern",
|
|
137
139
|
],
|
|
138
140
|
DashboardLabelRule: [
|
|
139
141
|
"dashboardLabels",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HttpRequestStepConfig } from "./RunbookStep.mjs";
|
|
2
|
+
import { RunbookVariableReference } from "./RunbookVariableReference.mjs";
|
|
3
|
+
export declare function getHttpStepVariableTexts(config: Pick<HttpRequestStepConfig, "url" | "headersJson" | "body">): Array<string>;
|
|
4
|
+
type GetValueFunction = (reference: RunbookVariableReference) => string | undefined;
|
|
5
|
+
export declare function fillHttpStepJsonText(text: string, getValue: GetValueFunction): string;
|
|
6
|
+
export declare function fillHttpStepConfig<T extends HttpRequestStepConfig>(config: T, getValue: GetValueFunction): T;
|
|
7
|
+
export declare function redactHttpStepSecrets(text: string, secretValues: Array<string>): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HttpRequestStepConfig } from "./RunbookStep";
|
|
2
|
+
import { RunbookVariableReference } from "./RunbookVariableReference";
|
|
3
|
+
export declare function getHttpStepVariableTexts(config: Pick<HttpRequestStepConfig, "url" | "headersJson" | "body">): Array<string>;
|
|
4
|
+
type GetValueFunction = (reference: RunbookVariableReference) => string | undefined;
|
|
5
|
+
export declare function fillHttpStepJsonText(text: string, getValue: GetValueFunction): string;
|
|
6
|
+
export declare function fillHttpStepConfig<T extends HttpRequestStepConfig>(config: T, getValue: GetValueFunction): T;
|
|
7
|
+
export declare function redactHttpStepSecrets(text: string, secretValues: Array<string>): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHttpStepVariableTexts = getHttpStepVariableTexts;
|
|
4
|
+
exports.fillHttpStepJsonText = fillHttpStepJsonText;
|
|
5
|
+
exports.fillHttpStepConfig = fillHttpStepConfig;
|
|
6
|
+
exports.redactHttpStepSecrets = redactHttpStepSecrets;
|
|
7
|
+
const RunbookVariableReference_1 = require("./RunbookVariableReference");
|
|
8
|
+
const SecretOutputRedaction_1 = require("./SecretOutputRedaction");
|
|
9
|
+
/*
|
|
10
|
+
* AN HTTP REQUEST STEP FILLS IN THE RUNBOOK VARIABLES IT NAMES.
|
|
11
|
+
*
|
|
12
|
+
* Bash, JavaScript, SSH and kubectl steps had variables; an HTTP request
|
|
13
|
+
* step - calling PagerDuty, Slack or a service of your own, usually with a
|
|
14
|
+
* token - did not, so a token had to be typed into the step, where
|
|
15
|
+
* everyone who may read the runbook reads it. Now its URL, headers and body
|
|
16
|
+
* name variables the way scripts do ({{global.variables.NAME}},
|
|
17
|
+
* {{local.variables.NAME}}), and OneUptime fills them in when the step runs.
|
|
18
|
+
*
|
|
19
|
+
* Who gets a secret: an HTTP request step is sent by OneUptime itself, from
|
|
20
|
+
* its own servers - which keep the secret already, encrypted, and decrypt it
|
|
21
|
+
* for every Runner that takes a step. No Runner is involved, so a secret's
|
|
22
|
+
* Runners do not apply: the step gets every variable of its project (and of
|
|
23
|
+
* its runbook) that it names, plain or secret. The secret is filled in only
|
|
24
|
+
* in the request as it is sent, never stored, and hidden in what the step
|
|
25
|
+
* records (the response's status, headers and body, and any error).
|
|
26
|
+
*
|
|
27
|
+
* How a value is placed, so a value is never read as JSON it was not:
|
|
28
|
+
*
|
|
29
|
+
* - the URL: as written - a reference may stand for a whole base URL, so
|
|
30
|
+
* nothing is escaped;
|
|
31
|
+
* - the headers and the body, when they are JSON as written: each string
|
|
32
|
+
* in them (names included) is filled in, and the JSON written again, so
|
|
33
|
+
* a value with a quote or a line break in it stays one string;
|
|
34
|
+
* - otherwise (a reference standing where a number goes, or a body that is
|
|
35
|
+
* plain text): the text is filled in as written, and read as before.
|
|
36
|
+
*
|
|
37
|
+
* Pure, so the step's executor and the tests read the same rules.
|
|
38
|
+
*/
|
|
39
|
+
// The step's fields that may name variables, as stored.
|
|
40
|
+
function getHttpStepVariableTexts(config) {
|
|
41
|
+
return [config.url || "", config.headersJson || "", config.body || ""];
|
|
42
|
+
}
|
|
43
|
+
// Every string in a JSON value, keys included, with references filled in.
|
|
44
|
+
function fillJsonValue(value, getValue) {
|
|
45
|
+
if (typeof value === "string") {
|
|
46
|
+
return (0, RunbookVariableReference_1.replaceRunbookVariableReferences)(value, getValue);
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
return value.map((item) => {
|
|
50
|
+
return fillJsonValue(item, getValue);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (value && typeof value === "object") {
|
|
54
|
+
const filled = {};
|
|
55
|
+
for (const [key, item] of Object.entries(value)) {
|
|
56
|
+
filled[(0, RunbookVariableReference_1.replaceRunbookVariableReferences)(key, getValue)] = fillJsonValue(item, getValue);
|
|
57
|
+
}
|
|
58
|
+
return filled;
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
/*
|
|
63
|
+
* A header or body text with its references filled in: within the JSON's
|
|
64
|
+
* strings when the text is JSON as written, else as plain text.
|
|
65
|
+
*/
|
|
66
|
+
function fillHttpStepJsonText(text, getValue) {
|
|
67
|
+
if (typeof text !== "string" || text.indexOf("{{") === -1) {
|
|
68
|
+
return text;
|
|
69
|
+
}
|
|
70
|
+
let parsed = undefined;
|
|
71
|
+
try {
|
|
72
|
+
parsed = JSON.parse(text);
|
|
73
|
+
}
|
|
74
|
+
catch (_a) {
|
|
75
|
+
return (0, RunbookVariableReference_1.replaceRunbookVariableReferences)(text, getValue);
|
|
76
|
+
}
|
|
77
|
+
// A JSON string, number or the like holds nothing to fill but itself.
|
|
78
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
79
|
+
return (0, RunbookVariableReference_1.replaceRunbookVariableReferences)(text, getValue);
|
|
80
|
+
}
|
|
81
|
+
return JSON.stringify(fillJsonValue(parsed, getValue));
|
|
82
|
+
}
|
|
83
|
+
// The step's URL, headers and body with the variables it names filled in.
|
|
84
|
+
function fillHttpStepConfig(config, getValue) {
|
|
85
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, config), { url: (0, RunbookVariableReference_1.replaceRunbookVariableReferences)(config.url || "", getValue) }), (config.headersJson
|
|
86
|
+
? { headersJson: fillHttpStepJsonText(config.headersJson, getValue) }
|
|
87
|
+
: {})), (config.body
|
|
88
|
+
? { body: fillHttpStepJsonText(config.body, getValue) }
|
|
89
|
+
: {}));
|
|
90
|
+
}
|
|
91
|
+
/*
|
|
92
|
+
* What the step records, with every secret it was given hidden - as each
|
|
93
|
+
* one was given, and as a URL carries it (percent-encoded), since the
|
|
94
|
+
* request's own URL comes back in errors and in echoing responses.
|
|
95
|
+
*/
|
|
96
|
+
function redactHttpStepSecrets(text, secretValues) {
|
|
97
|
+
if (!secretValues.length || typeof text !== "string" || !text) {
|
|
98
|
+
return text;
|
|
99
|
+
}
|
|
100
|
+
const forms = [];
|
|
101
|
+
for (const value of secretValues) {
|
|
102
|
+
forms.push(value);
|
|
103
|
+
const encoded = encodeURIComponent(value);
|
|
104
|
+
if (encoded !== value) {
|
|
105
|
+
forms.push(encoded);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return (0, SecretOutputRedaction_1.redactSecretValues)(text, forms);
|
|
109
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import commonJsModule from "./HttpStepVariables.js";
|
|
2
|
+
export const fillHttpStepConfig = commonJsModule.fillHttpStepConfig;
|
|
3
|
+
export const fillHttpStepJsonText = commonJsModule.fillHttpStepJsonText;
|
|
4
|
+
export const getHttpStepVariableTexts = commonJsModule.getHttpStepVariableTexts;
|
|
5
|
+
export const redactHttpStepSecrets = commonJsModule.redactHttpStepSecrets;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const RUNNER_FEATURE_KUBECTL_SCRIPT: string;
|
|
2
|
+
export declare const RUNNER_FEATURE_SSH_HOST_KEY: string;
|
|
2
3
|
export declare const SSH_CREDENTIAL_TYPE: string;
|
|
3
4
|
export declare const KUBECONFIG_CREDENTIAL_TYPE: string;
|
|
4
5
|
export declare const RUNNER_FEATURES: ReadonlyArray<string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const RUNNER_FEATURE_KUBECTL_SCRIPT: string;
|
|
2
|
+
export declare const RUNNER_FEATURE_SSH_HOST_KEY: string;
|
|
2
3
|
export declare const SSH_CREDENTIAL_TYPE: string;
|
|
3
4
|
export declare const KUBECONFIG_CREDENTIAL_TYPE: string;
|
|
4
5
|
export declare const RUNNER_FEATURES: ReadonlyArray<string>;
|
|
@@ -14,20 +14,31 @@
|
|
|
14
14
|
* step is failed on a Runner that does not name "kubectl-script", saying to
|
|
15
15
|
* update the Runner - the Kubernetes steps the data migration moved from an
|
|
16
16
|
* action included: the runbook credential they kept for such a Runner went
|
|
17
|
-
* with runbook credentials.
|
|
17
|
+
* with runbook credentials. An SSH step that names the machine's host keys
|
|
18
|
+
* is failed on a Runner that does not name "ssh-host-key": an older Runner
|
|
19
|
+
* would sign in without checking them, which is what naming them prevents.
|
|
18
20
|
*/
|
|
19
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.RUNNER_FEATURES = exports.KUBECONFIG_CREDENTIAL_TYPE = exports.SSH_CREDENTIAL_TYPE = exports.RUNNER_FEATURE_KUBECTL_SCRIPT = void 0;
|
|
22
|
+
exports.RUNNER_FEATURES = exports.KUBECONFIG_CREDENTIAL_TYPE = exports.SSH_CREDENTIAL_TYPE = exports.RUNNER_FEATURE_SSH_HOST_KEY = exports.RUNNER_FEATURE_KUBECTL_SCRIPT = void 0;
|
|
21
23
|
exports.readRunnerFeatures = readRunnerFeatures;
|
|
22
24
|
// A kubectl step that takes a script and a kubeconfig (RunbookStepType.Kubernetes).
|
|
23
25
|
exports.RUNNER_FEATURE_KUBECTL_SCRIPT = "kubectl-script";
|
|
26
|
+
/*
|
|
27
|
+
* An SSH step that names the machine's host keys (SSHStepConfig.hostKey):
|
|
28
|
+
* the Runner signs in only when the machine presents one of them
|
|
29
|
+
* (credential.hostKeys).
|
|
30
|
+
*/
|
|
31
|
+
exports.RUNNER_FEATURE_SSH_HOST_KEY = "ssh-host-key";
|
|
24
32
|
/*
|
|
25
33
|
* How a claim's `credential` says what it holds: { credentialType, ... }.
|
|
26
34
|
*
|
|
27
35
|
* An SSH step's sign-in is sent as { credentialType: "SSH", hostname, port,
|
|
28
36
|
* username, privateKey (and passphrase) or password }, filled in from its
|
|
29
37
|
* secret runbook variables (RunbookJobVariables) - the shape every Runner
|
|
30
|
-
* reads, an older one included, since runbook credentials were sent in it
|
|
38
|
+
* reads, an older one included, since runbook credentials were sent in it -
|
|
39
|
+
* and, when the step names the machine's host keys, hostKeys: [{
|
|
40
|
+
* fingerprint, keyType }], which only a Runner that names "ssh-host-key"
|
|
41
|
+
* is handed.
|
|
31
42
|
* A kubectl step's kubeconfig is sent as { credentialType: "Kubeconfig",
|
|
32
43
|
* kubeconfig }. ("Kubernetes", an API server URL and a token, is what a
|
|
33
44
|
* runbook credential was sent as; OneUptime sends it no more.)
|
|
@@ -37,6 +48,7 @@ exports.KUBECONFIG_CREDENTIAL_TYPE = "Kubeconfig";
|
|
|
37
48
|
// Every feature this build of the Runner has.
|
|
38
49
|
exports.RUNNER_FEATURES = [
|
|
39
50
|
exports.RUNNER_FEATURE_KUBECTL_SCRIPT,
|
|
51
|
+
exports.RUNNER_FEATURE_SSH_HOST_KEY,
|
|
40
52
|
];
|
|
41
53
|
// The features a claim body names, read defensively: only known strings.
|
|
42
54
|
function readRunnerFeatures(raw) {
|
|
@@ -2,5 +2,6 @@ import commonJsModule from "./RunnerFeatures.js";
|
|
|
2
2
|
export const KUBECONFIG_CREDENTIAL_TYPE = commonJsModule.KUBECONFIG_CREDENTIAL_TYPE;
|
|
3
3
|
export const RUNNER_FEATURES = commonJsModule.RUNNER_FEATURES;
|
|
4
4
|
export const RUNNER_FEATURE_KUBECTL_SCRIPT = commonJsModule.RUNNER_FEATURE_KUBECTL_SCRIPT;
|
|
5
|
+
export const RUNNER_FEATURE_SSH_HOST_KEY = commonJsModule.RUNNER_FEATURE_SSH_HOST_KEY;
|
|
5
6
|
export const SSH_CREDENTIAL_TYPE = commonJsModule.SSH_CREDENTIAL_TYPE;
|
|
6
7
|
export const readRunnerFeatures = commonJsModule.readRunnerFeatures;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const SSH_HOST_KEY_TYPES: ReadonlyArray<string>;
|
|
2
|
+
export declare const MAX_SSH_HOST_KEYS: number;
|
|
3
|
+
export declare const MAX_SSH_HOST_KEY_TEXT_LENGTH: number;
|
|
4
|
+
export declare const SSH_FINGERPRINT_PREFIX: string;
|
|
5
|
+
export type SshHostKeyEntry = {
|
|
6
|
+
kind: "fingerprint";
|
|
7
|
+
fingerprint: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "publicKey";
|
|
10
|
+
keyType: string;
|
|
11
|
+
keyBase64: string;
|
|
12
|
+
};
|
|
13
|
+
export interface ParsedSshHostKeys {
|
|
14
|
+
entries: Array<SshHostKeyEntry>;
|
|
15
|
+
invalidLines: Array<string>;
|
|
16
|
+
isTooLong: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function decodeSshBase64(text: string): Uint8Array | null;
|
|
19
|
+
export declare function readSshKeyBlobType(blob: Uint8Array): string | null;
|
|
20
|
+
export declare function parseSshHostKeys(text: string | undefined): ParsedSshHostKeys;
|
|
21
|
+
export declare function hasSshHostKeys(text: string | undefined): boolean;
|
|
22
|
+
export declare function getSshHostKeyProblem(text: string | undefined): string | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const SSH_HOST_KEY_TYPES: ReadonlyArray<string>;
|
|
2
|
+
export declare const MAX_SSH_HOST_KEYS: number;
|
|
3
|
+
export declare const MAX_SSH_HOST_KEY_TEXT_LENGTH: number;
|
|
4
|
+
export declare const SSH_FINGERPRINT_PREFIX: string;
|
|
5
|
+
export type SshHostKeyEntry = {
|
|
6
|
+
kind: "fingerprint";
|
|
7
|
+
fingerprint: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "publicKey";
|
|
10
|
+
keyType: string;
|
|
11
|
+
keyBase64: string;
|
|
12
|
+
};
|
|
13
|
+
export interface ParsedSshHostKeys {
|
|
14
|
+
entries: Array<SshHostKeyEntry>;
|
|
15
|
+
invalidLines: Array<string>;
|
|
16
|
+
isTooLong: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function decodeSshBase64(text: string): Uint8Array | null;
|
|
19
|
+
export declare function readSshKeyBlobType(blob: Uint8Array): string | null;
|
|
20
|
+
export declare function parseSshHostKeys(text: string | undefined): ParsedSshHostKeys;
|
|
21
|
+
export declare function hasSshHostKeys(text: string | undefined): boolean;
|
|
22
|
+
export declare function getSshHostKeyProblem(text: string | undefined): string | null;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* AN SSH STEP'S HOST KEYS: the keys the machine it signs in to may present.
|
|
4
|
+
*
|
|
5
|
+
* An SSH step signed in to whatever answered at its host, without asking
|
|
6
|
+
* whether it was that machine: someone between the Runner and the machine
|
|
7
|
+
* could have taken the step's password, or run its script elsewhere. A step
|
|
8
|
+
* may now name the machine's host keys (SSHStepConfig.hostKey), and the
|
|
9
|
+
* Runner signs in only when the machine presents one of them - after
|
|
10
|
+
* proving it holds that key, which ssh2 checks during the key exchange.
|
|
11
|
+
*
|
|
12
|
+
* Each line names one key, written as people copy it:
|
|
13
|
+
*
|
|
14
|
+
* - its SHA256 fingerprint, as `ssh-keygen -l` and ssh's own "the
|
|
15
|
+
* fingerprint is" print it - "SHA256:" and 43 characters of base64,
|
|
16
|
+
* anywhere in the line, so a whole `ssh-keygen -l` line reads too;
|
|
17
|
+
* - or its public key, as a .pub file, `ssh-keyscan` or a known_hosts
|
|
18
|
+
* line has it: the key's type, then its base64, with anything before
|
|
19
|
+
* (the host names) or after (a comment) left out.
|
|
20
|
+
*
|
|
21
|
+
* Blank lines and lines that start with "#" (what `ssh-keyscan` prints
|
|
22
|
+
* about the server) are skipped. An MD5 fingerprint is not read: ssh has
|
|
23
|
+
* shown SHA256 by default since OpenSSH 6.8.
|
|
24
|
+
*
|
|
25
|
+
* React-free and Node-free: the Steps page reads it to say what is wrong
|
|
26
|
+
* with a line, and the server and the Runner read it before they work out
|
|
27
|
+
* a public key's fingerprint (Common/Utils/Runbook/SshHostKeyFingerprint,
|
|
28
|
+
* which uses Node's crypto).
|
|
29
|
+
*/
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.SSH_FINGERPRINT_PREFIX = exports.MAX_SSH_HOST_KEY_TEXT_LENGTH = exports.MAX_SSH_HOST_KEYS = exports.SSH_HOST_KEY_TYPES = void 0;
|
|
32
|
+
exports.decodeSshBase64 = decodeSshBase64;
|
|
33
|
+
exports.readSshKeyBlobType = readSshKeyBlobType;
|
|
34
|
+
exports.parseSshHostKeys = parseSshHostKeys;
|
|
35
|
+
exports.hasSshHostKeys = hasSshHostKeys;
|
|
36
|
+
exports.getSshHostKeyProblem = getSshHostKeyProblem;
|
|
37
|
+
// The host key types a machine presents, as OpenSSH writes them.
|
|
38
|
+
exports.SSH_HOST_KEY_TYPES = [
|
|
39
|
+
"ssh-ed25519",
|
|
40
|
+
"ecdsa-sha2-nistp256",
|
|
41
|
+
"ecdsa-sha2-nistp384",
|
|
42
|
+
"ecdsa-sha2-nistp521",
|
|
43
|
+
"ssh-rsa",
|
|
44
|
+
];
|
|
45
|
+
// The most host keys a step names: a machine has one of each type, at most.
|
|
46
|
+
exports.MAX_SSH_HOST_KEYS = 16;
|
|
47
|
+
// The most text the field holds: a 16384-bit RSA key is under 3 KB a line.
|
|
48
|
+
exports.MAX_SSH_HOST_KEY_TEXT_LENGTH = 50000;
|
|
49
|
+
exports.SSH_FINGERPRINT_PREFIX = "SHA256:";
|
|
50
|
+
/*
|
|
51
|
+
* A SHA-256 fingerprint: "SHA256:" and the 32 bytes' base64 - 43
|
|
52
|
+
* characters, and the one "=" of padding OpenSSH leaves out. Only base64
|
|
53
|
+
* characters around it, so it is read out of a whole `ssh-keygen -l` line.
|
|
54
|
+
*/
|
|
55
|
+
const FINGERPRINT = /^SHA256:([A-Za-z0-9+/]{42}[AEIMQUYcgkosw048])=?$/;
|
|
56
|
+
const BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
57
|
+
// Base64 without the "=" that pads its end (a loop: no pattern backtracks).
|
|
58
|
+
function withoutPadding(text) {
|
|
59
|
+
let end = text.length;
|
|
60
|
+
while (end > 0 && text[end - 1] === "=") {
|
|
61
|
+
end--;
|
|
62
|
+
}
|
|
63
|
+
return text.slice(0, end);
|
|
64
|
+
}
|
|
65
|
+
/*
|
|
66
|
+
* Base64 to bytes, or null when it is not base64. Written out rather than
|
|
67
|
+
* read from atob or Buffer, so the browser and Node read it alike.
|
|
68
|
+
*/
|
|
69
|
+
function decodeSshBase64(text) {
|
|
70
|
+
const trimmed = withoutPadding(text);
|
|
71
|
+
if (trimmed.length === 0 || trimmed.length % 4 === 1) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const bytes = [];
|
|
75
|
+
let buffer = 0;
|
|
76
|
+
let bits = 0;
|
|
77
|
+
for (const character of trimmed) {
|
|
78
|
+
const value = BASE64_ALPHABET.indexOf(character);
|
|
79
|
+
if (value < 0) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
buffer = (buffer << 6) | value;
|
|
83
|
+
bits += 6;
|
|
84
|
+
if (bits >= 8) {
|
|
85
|
+
bits -= 8;
|
|
86
|
+
bytes.push((buffer >> bits) & 0xff);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return Uint8Array.from(bytes);
|
|
90
|
+
}
|
|
91
|
+
/*
|
|
92
|
+
* The key type the SSH wire format of a public key starts with: a 4-byte
|
|
93
|
+
* length, then that many bytes of name. Null when it does not.
|
|
94
|
+
*/
|
|
95
|
+
function readSshKeyBlobType(blob) {
|
|
96
|
+
if (blob.length < 4) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
const length = ((blob[0] << 24) | (blob[1] << 16) | (blob[2] << 8) | blob[3]) >>> 0;
|
|
100
|
+
if (length === 0 || length > 64 || blob.length < 4 + length) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
let name = "";
|
|
104
|
+
for (let index = 4; index < 4 + length; index++) {
|
|
105
|
+
const code = blob[index];
|
|
106
|
+
// A key type is printable ASCII.
|
|
107
|
+
if (code < 0x21 || code > 0x7e) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
name += String.fromCharCode(code);
|
|
111
|
+
}
|
|
112
|
+
return name;
|
|
113
|
+
}
|
|
114
|
+
// The fingerprint a line names, or null.
|
|
115
|
+
function readFingerprint(tokens) {
|
|
116
|
+
for (const token of tokens) {
|
|
117
|
+
const match = FINGERPRINT.exec(token);
|
|
118
|
+
if (match) {
|
|
119
|
+
return `${exports.SSH_FINGERPRINT_PREFIX}${match[1]}`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
// The public key a line holds, or null.
|
|
125
|
+
function readPublicKey(tokens) {
|
|
126
|
+
var _a;
|
|
127
|
+
// A known_hosts marker (@cert-authority, @revoked) is not a host key.
|
|
128
|
+
if ((_a = tokens[0]) === null || _a === void 0 ? void 0 : _a.startsWith("@")) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
for (let index = 0; index < tokens.length - 1; index++) {
|
|
132
|
+
const keyType = tokens[index];
|
|
133
|
+
if (!exports.SSH_HOST_KEY_TYPES.includes(keyType)) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const keyBase64 = tokens[index + 1];
|
|
137
|
+
const blob = decodeSshBase64(keyBase64);
|
|
138
|
+
// The key says its own type: it must be the one the line says.
|
|
139
|
+
if (!blob || readSshKeyBlobType(blob) !== keyType) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return { keyType, keyBase64: withoutPadding(keyBase64) };
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
// The host keys a step's Host key field names, read line by line.
|
|
147
|
+
function parseSshHostKeys(text) {
|
|
148
|
+
const parsed = {
|
|
149
|
+
entries: [],
|
|
150
|
+
invalidLines: [],
|
|
151
|
+
isTooLong: false,
|
|
152
|
+
};
|
|
153
|
+
if (!text) {
|
|
154
|
+
return parsed;
|
|
155
|
+
}
|
|
156
|
+
if (text.length > exports.MAX_SSH_HOST_KEY_TEXT_LENGTH) {
|
|
157
|
+
parsed.isTooLong = true;
|
|
158
|
+
return parsed;
|
|
159
|
+
}
|
|
160
|
+
for (const rawLine of text.split(/\r?\n/)) {
|
|
161
|
+
const line = rawLine.trim();
|
|
162
|
+
if (!line || line.startsWith("#")) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const tokens = line.split(/\s+/);
|
|
166
|
+
const fingerprint = readFingerprint(tokens);
|
|
167
|
+
if (fingerprint) {
|
|
168
|
+
parsed.entries.push({ kind: "fingerprint", fingerprint });
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const publicKey = readPublicKey(tokens);
|
|
172
|
+
if (publicKey) {
|
|
173
|
+
parsed.entries.push(Object.assign({ kind: "publicKey" }, publicKey));
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
parsed.invalidLines.push(line);
|
|
177
|
+
}
|
|
178
|
+
if (parsed.entries.length > exports.MAX_SSH_HOST_KEYS) {
|
|
179
|
+
parsed.isTooLong = true;
|
|
180
|
+
}
|
|
181
|
+
return parsed;
|
|
182
|
+
}
|
|
183
|
+
// Whether a step names host keys at all - a line that is not one counts.
|
|
184
|
+
function hasSshHostKeys(text) {
|
|
185
|
+
return Boolean(text && text.trim());
|
|
186
|
+
}
|
|
187
|
+
/*
|
|
188
|
+
* Why a step's Host key field cannot be used, or null when every line names
|
|
189
|
+
* a key (or it is empty). Said by the server, in English, when it refuses
|
|
190
|
+
* the step; the Steps page says its own words.
|
|
191
|
+
*/
|
|
192
|
+
function getSshHostKeyProblem(text) {
|
|
193
|
+
const parsed = parseSshHostKeys(text);
|
|
194
|
+
if (parsed.isTooLong) {
|
|
195
|
+
return `This SSH step's Host key names more than ${exports.MAX_SSH_HOST_KEYS} keys, so it was not run. A machine has one key of each type: name those.`;
|
|
196
|
+
}
|
|
197
|
+
if (parsed.invalidLines.length > 0) {
|
|
198
|
+
return "This SSH step's Host key has a line that is neither a SHA256 fingerprint nor a public key, so it was not run. Open the step and put the machine's SHA256 fingerprint, or its public key as ssh-keyscan prints it, one per line.";
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|