@oneuptime/common 12.0.28 → 12.0.29
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/DashboardDomain.ts +43 -0
- package/Models/DatabaseModels/MonitorTemplate.ts +15 -3
- package/Models/DatabaseModels/StatusPageDomain.ts +43 -0
- package/Server/API/DashboardDomainAPI.ts +74 -0
- package/Server/API/MicrosoftTeamsAPI.ts +81 -180
- package/Server/API/StatusPageDomainAPI.ts +74 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1790200000000-AllowNullMonitorNameOnMonitorTemplate.ts +43 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1790300000000-AddCertificateReissueRequestedAtToDomains.ts +40 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
- package/Server/Middleware/ProjectAuthorization.ts +6 -1
- package/Server/Services/DashboardDomainService.ts +131 -0
- package/Server/Services/LogPipelineProcessorService.ts +88 -0
- package/Server/Services/MonitorTemplateService.ts +70 -11
- package/Server/Services/StatusPageDomainService.ts +163 -3
- package/Server/Services/StatusPagePrivateUserSessionService.ts +197 -56
- package/Server/Types/Domain.ts +17 -0
- package/Server/Utils/APIKey/AccessPermission.ts +24 -0
- package/Server/Utils/Greenlock/Greenlock.ts +156 -58
- package/Server/Utils/LogPipelineProcessorValidation.ts +112 -0
- package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.ts +1094 -45
- package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.ts +153 -17
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts +23 -11
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.ts +0 -170
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/Authorization.ts +158 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts +23 -11
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +35 -13
- package/Tests/App/Dashboard/MonitorTemplateColumnAndFacet.test.tsx +505 -0
- package/Tests/App/StatusPage/StatusPageLoginCodeBootstrap.test.ts +106 -0
- package/Tests/App/StatusPage/StatusPageLoginCodeUtil.test.ts +84 -0
- package/Tests/App/StatusPage/StatusPageRedirectSafety.test.ts +119 -0
- package/Tests/Models/MonitorTemplateMonitorNameColumn.test.ts +258 -0
- package/Tests/Server/API/CustomDomainReissueSslAPI.test.ts +469 -0
- package/Tests/Server/API/MicrosoftTeamsBotMessagesEndpoint.test.ts +729 -0
- package/Tests/Server/API/MicrosoftTeamsBotTestEndpoint.test.ts +26 -0
- package/Tests/Server/API/MicrosoftTeamsLegacyWebhookRemoval.test.ts +402 -0
- package/Tests/Server/Middleware/ProjectAuthorizationApiKeyMiddleware.test.ts +4 -0
- package/Tests/Server/Services/AddCertificateReissueRequestedAtToDomainsMigration.test.ts +287 -0
- package/Tests/Server/Services/CustomDomainCertificateReissue.test.ts +477 -0
- package/Tests/Server/Services/LogPipelineProcessorSaveValidation.test.ts +249 -0
- package/Tests/Server/Services/MonitorTemplateServiceBulkSync.test.ts +549 -0
- package/Tests/Server/Services/MonitorTemplateServiceNetworkDeviceSync.test.ts +16 -3
- package/Tests/Server/Services/NetworkDeviceAutoImportRuleEngineService.test.ts +57 -0
- package/Tests/Server/Services/SecurityEventLastErrorColumnWidth.test.ts +151 -15
- package/Tests/Server/Services/StatusPagePrivateUserSessionService.test.ts +587 -0
- package/Tests/Server/Types/Database/Permissions/ApiKeyFileAccess.test.ts +286 -0
- package/Tests/Server/Types/Database/Permissions/MonitorTemplateColumnAccess.test.ts +328 -0
- package/Tests/Server/Types/Database/QueryHelperFindWithSameTextAndIsNull.test.ts +83 -0
- package/Tests/Server/Utils/AI/SRE/ConfidenceSignal.test.ts +377 -0
- package/Tests/Server/Utils/APIKey/AccessPermission.test.ts +16 -1
- package/Tests/Server/Utils/Greenlock/CertificateRenewalSchedule.test.ts +250 -0
- package/Tests/Server/Utils/LogPipelineProcessorValidation.test.ts +198 -0
- package/Tests/Server/Utils/SecurityEvent/ConnectorErrorMessage.test.ts +48 -9
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsAuth.test.ts +726 -0
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsClient.test.ts +74 -11
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsErrorHandling.test.ts +1107 -0
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPoller.test.ts +20 -3
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPollerFailureTaxonomy.test.ts +51 -11
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPollerHardening.test.ts +1246 -0
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsRequestContract.test.ts +961 -0
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsResponseParsing.test.ts +653 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeamsActionAuthorization.test.ts +880 -0
- package/Tests/Types/API/HTTPResponse.test.ts +175 -0
- package/Tests/Types/API/Route.test.ts +36 -4
- package/Tests/Types/Database/DatabaseProperty.test.ts +171 -0
- package/Tests/Types/DateLocalShortDateTimeString.test.ts +518 -0
- package/Tests/Types/DateLocalTimeString.test.ts +259 -0
- package/Tests/Types/DateUserPrefers12HourFormat.test.ts +316 -0
- package/Tests/UI/Components/LogsHistogram.test.tsx +41 -2
- package/Tests/UI/Components/LogsViewerEmptyStateTimeRange.test.tsx +212 -0
- package/Tests/UI/Components/TelemetryChartClockFormat.test.tsx +359 -0
- package/Tests/UI/Components/TimeRangePickerClockFormat.test.tsx +422 -0
- package/Tests/UI/Components/TimeRangePickerDropdown.test.tsx +146 -8
- package/Tests/UI/MicrosoftTeams/MicrosoftTeamsMessagingEndpointGuidance.test.tsx +520 -0
- package/Tests/UI/Utils/Navigation.test.ts +82 -0
- package/Tests/Utils/Array.test.ts +100 -0
- package/Tests/Utils/CertificateReissue.test.ts +225 -0
- package/Tests/Utils/Grok/Grok.test.ts +492 -0
- package/Tests/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.test.ts +181 -13
- package/Types/API/Route.ts +20 -5
- package/Types/Date.ts +143 -13
- package/Types/Rum/SessionReplay.ts +62 -1
- package/UI/Components/Date/TimeRangePickerDropdown.tsx +9 -5
- package/UI/Components/LogsViewer/LogsViewer.tsx +12 -7
- package/UI/Components/LogsViewer/components/HistogramTooltip.tsx +18 -17
- package/UI/Components/LogsViewer/components/LogsAnalyticsView.tsx +21 -28
- package/UI/Components/LogsViewer/components/LogsHistogram.tsx +2 -4
- package/UI/Components/TelemetryViewer/components/TelemetryHistogram.tsx +2 -4
- package/UI/Components/TelemetryViewer/components/TelemetryHistogramTooltip.tsx +17 -16
- package/UI/Utils/Navigation.ts +42 -0
- package/Utils/Array.ts +37 -0
- package/Utils/CertificateReissue.ts +128 -0
- package/Utils/Grok/Grok.ts +461 -0
- package/Utils/Grok/GrokPatterns.ts +118 -0
- package/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.ts +58 -6
- package/build/dist/Models/DatabaseModels/DashboardDomain.js +44 -0
- package/build/dist/Models/DatabaseModels/DashboardDomain.js.map +1 -1
- package/build/dist/Models/DatabaseModels/MonitorTemplate.js +17 -4
- package/build/dist/Models/DatabaseModels/MonitorTemplate.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPageDomain.js +44 -0
- package/build/dist/Models/DatabaseModels/StatusPageDomain.js.map +1 -1
- package/build/dist/Server/API/DashboardDomainAPI.js +43 -1
- package/build/dist/Server/API/DashboardDomainAPI.js.map +1 -1
- package/build/dist/Server/API/MicrosoftTeamsAPI.js +74 -118
- package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
- package/build/dist/Server/API/StatusPageDomainAPI.js +43 -1
- package/build/dist/Server/API/StatusPageDomainAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1790200000000-AllowNullMonitorNameOnMonitorTemplate.js +34 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1790200000000-AllowNullMonitorNameOnMonitorTemplate.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1790300000000-AddCertificateReissueRequestedAtToDomains.js +28 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1790300000000-AddCertificateReissueRequestedAtToDomains.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/ProjectAuthorization.js +6 -1
- package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
- package/build/dist/Server/Services/DashboardDomainService.js +104 -0
- package/build/dist/Server/Services/DashboardDomainService.js.map +1 -1
- package/build/dist/Server/Services/LogPipelineProcessorService.js +65 -0
- package/build/dist/Server/Services/LogPipelineProcessorService.js.map +1 -1
- package/build/dist/Server/Services/MonitorTemplateService.js +57 -11
- package/build/dist/Server/Services/MonitorTemplateService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageDomainService.js +132 -3
- package/build/dist/Server/Services/StatusPageDomainService.js.map +1 -1
- package/build/dist/Server/Services/StatusPagePrivateUserSessionService.js +112 -32
- package/build/dist/Server/Services/StatusPagePrivateUserSessionService.js.map +1 -1
- package/build/dist/Server/Types/Domain.js +16 -0
- package/build/dist/Server/Types/Domain.js.map +1 -1
- package/build/dist/Server/Utils/APIKey/AccessPermission.js +24 -0
- package/build/dist/Server/Utils/APIKey/AccessPermission.js.map +1 -1
- package/build/dist/Server/Utils/Greenlock/Greenlock.js +110 -35
- package/build/dist/Server/Utils/Greenlock/Greenlock.js.map +1 -1
- package/build/dist/Server/Utils/LogPipelineProcessorValidation.js +77 -0
- package/build/dist/Server/Utils/LogPipelineProcessorValidation.js.map +1 -0
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.js +777 -36
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.js +108 -17
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js +17 -6
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js +0 -159
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Authorization.js +128 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Authorization.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js +17 -6
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +25 -13
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Types/API/Route.js +16 -5
- package/build/dist/Types/API/Route.js.map +1 -1
- package/build/dist/Types/Date.js +115 -13
- package/build/dist/Types/Date.js.map +1 -1
- package/build/dist/Types/Rum/SessionReplay.js +38 -0
- package/build/dist/Types/Rum/SessionReplay.js.map +1 -1
- package/build/dist/UI/Components/Date/TimeRangePickerDropdown.js +9 -5
- package/build/dist/UI/Components/Date/TimeRangePickerDropdown.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js +12 -7
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/HistogramTooltip.js +15 -14
- package/build/dist/UI/Components/LogsViewer/components/HistogramTooltip.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsAnalyticsView.js +17 -22
- package/build/dist/UI/Components/LogsViewer/components/LogsAnalyticsView.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsHistogram.js +2 -4
- package/build/dist/UI/Components/LogsViewer/components/LogsHistogram.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js +2 -4
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogramTooltip.js +15 -14
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogramTooltip.js.map +1 -1
- package/build/dist/UI/Utils/Navigation.js +30 -0
- package/build/dist/UI/Utils/Navigation.js.map +1 -1
- package/build/dist/Utils/Array.js +25 -0
- package/build/dist/Utils/Array.js.map +1 -1
- package/build/dist/Utils/CertificateReissue.js +97 -0
- package/build/dist/Utils/CertificateReissue.js.map +1 -0
- package/build/dist/Utils/Grok/Grok.js +324 -0
- package/build/dist/Utils/Grok/Grok.js.map +1 -0
- package/build/dist/Utils/Grok/GrokPatterns.js +112 -0
- package/build/dist/Utils/Grok/GrokPatterns.js.map +1 -0
- package/build/dist/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.js +63 -3
- package/build/dist/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.js.map +1 -1
- package/package.json +1 -1
- package/UI/Utils/JsonWebToken.ts +0 -14
- package/build/dist/UI/Utils/JsonWebToken.js +0 -10
- package/build/dist/UI/Utils/JsonWebToken.js.map +0 -1
|
@@ -21,21 +21,39 @@ import ServerException from "../../../Types/Exception/ServerException";
|
|
|
21
21
|
import Text from "../../../Types/Text";
|
|
22
22
|
import AcmeCertificate from "../../../Models/DatabaseModels/AcmeCertificate";
|
|
23
23
|
import AcmeChallenge from "../../../Models/DatabaseModels/AcmeChallenge";
|
|
24
|
+
import ArrayUtil from "../../../Utils/Array";
|
|
24
25
|
import acme from "acme-client";
|
|
25
26
|
import CaptureSpan from "../Telemetry/CaptureSpan";
|
|
26
|
-
|
|
27
|
+
class GreenlockUtil {
|
|
28
|
+
/*
|
|
29
|
+
* Stable per-domain lead time, somewhere in the range above. Same domain,
|
|
30
|
+
* same answer, on every run and every replica.
|
|
31
|
+
*/
|
|
32
|
+
static getRenewalLeadTimeInDays(domain) {
|
|
33
|
+
const spanInDays = GreenlockUtil.RENEW_LEAD_TIME_MAX_IN_DAYS -
|
|
34
|
+
GreenlockUtil.RENEW_LEAD_TIME_MIN_IN_DAYS;
|
|
35
|
+
let hash = 0;
|
|
36
|
+
for (let i = 0; i < domain.length; i++) {
|
|
37
|
+
hash = (hash * 31 + domain.charCodeAt(i)) % 1000003;
|
|
38
|
+
}
|
|
39
|
+
return (GreenlockUtil.RENEW_LEAD_TIME_MIN_IN_DAYS + (hash % (spanInDays + 1)));
|
|
40
|
+
}
|
|
27
41
|
static async renewAllCertsWhichAreExpiringSoon(data) {
|
|
28
42
|
try {
|
|
29
43
|
logger.debug("Renewing all certificates");
|
|
30
|
-
|
|
44
|
+
/*
|
|
45
|
+
* Read the widest window any domain's lead time can make it due in, then
|
|
46
|
+
* keep only the domains whose own lead time has actually been reached.
|
|
47
|
+
*/
|
|
31
48
|
const certificates = await AcmeCertificateService.findBy({
|
|
32
49
|
query: {
|
|
33
|
-
expiresAt: QueryHelper.lessThanEqualTo(OneUptimeDate.addRemoveDays(OneUptimeDate.getCurrentDate(),
|
|
50
|
+
expiresAt: QueryHelper.lessThanEqualTo(OneUptimeDate.addRemoveDays(OneUptimeDate.getCurrentDate(), GreenlockUtil.RENEW_LEAD_TIME_MAX_IN_DAYS)),
|
|
34
51
|
},
|
|
35
52
|
limit: LIMIT_MAX,
|
|
36
53
|
skip: 0,
|
|
37
54
|
select: {
|
|
38
55
|
domain: true,
|
|
56
|
+
expiresAt: true,
|
|
39
57
|
},
|
|
40
58
|
sort: {
|
|
41
59
|
expiresAt: SortOrder.Ascending,
|
|
@@ -44,40 +62,31 @@ export default class GreenlockUtil {
|
|
|
44
62
|
isRoot: true,
|
|
45
63
|
},
|
|
46
64
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
continue;
|
|
65
|
+
const now = OneUptimeDate.getCurrentDate();
|
|
66
|
+
const dueCertificates = certificates.filter((certificate) => {
|
|
67
|
+
if (!certificate.domain || !certificate.expiresAt) {
|
|
68
|
+
return false;
|
|
52
69
|
}
|
|
53
|
-
const
|
|
70
|
+
const renewAt = OneUptimeDate.addRemoveDays(certificate.expiresAt, -GreenlockUtil.getRenewalLeadTimeInDays(certificate.domain));
|
|
71
|
+
return !OneUptimeDate.isAfter(renewAt, now);
|
|
72
|
+
});
|
|
73
|
+
/*
|
|
74
|
+
* Still sorted by expiry, so a run that cannot take the whole backlog
|
|
75
|
+
* spends itself on the domains closest to expiring and leaves the rest -
|
|
76
|
+
* which by construction still have weeks of lead time - to the next run.
|
|
77
|
+
*/
|
|
78
|
+
const batch = dueCertificates.slice(0, GreenlockUtil.RENEW_MAX_PER_RUN);
|
|
79
|
+
logger.debug(`Found ${dueCertificates.length} certificates due for renewal, renewing ${batch.length} in this run`, {
|
|
80
|
+
dueCount: dueCertificates.length,
|
|
81
|
+
batchCount: batch.length,
|
|
82
|
+
});
|
|
83
|
+
await ArrayUtil.forEachWithConcurrency(batch, GreenlockUtil.RENEW_CONCURRENCY, async (certificate) => {
|
|
84
|
+
await GreenlockUtil.renewCertForDomain({
|
|
54
85
|
domain: certificate.domain,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const isValidCname = await data.validateCname(certificate.domain);
|
|
60
|
-
if (!isValidCname) {
|
|
61
|
-
logger.debug(`CNAME is not valid for domain: ${certificate.domain}`, certLogAttributes);
|
|
62
|
-
// if cname is not valid then remove the domain
|
|
63
|
-
await GreenlockUtil.removeDomain(certificate.domain);
|
|
64
|
-
await data.notifyDomainRemoved(certificate.domain);
|
|
65
|
-
logger.error(`Cname is not valid for domain: ${certificate.domain}`, certLogAttributes);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
logger.debug(`CNAME is valid for domain: ${certificate.domain}`, certLogAttributes);
|
|
69
|
-
await GreenlockUtil.orderCert({
|
|
70
|
-
domain: certificate.domain,
|
|
71
|
-
validateCname: data.validateCname,
|
|
72
|
-
});
|
|
73
|
-
logger.debug(`Certificate renewed for domain: ${certificate.domain}`, certLogAttributes);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
logger.error(`Error renewing certificate for domain: ${certificate.domain}`, certLogAttributes);
|
|
78
|
-
logger.error(e, certLogAttributes);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
86
|
+
validateCname: data.validateCname,
|
|
87
|
+
notifyDomainRemoved: data.notifyDomainRemoved,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
81
90
|
}
|
|
82
91
|
catch (e) {
|
|
83
92
|
logger.error("Error renewing all certificates");
|
|
@@ -85,6 +94,41 @@ export default class GreenlockUtil {
|
|
|
85
94
|
throw e;
|
|
86
95
|
}
|
|
87
96
|
}
|
|
97
|
+
/*
|
|
98
|
+
* Renew one domain. Never throws: one domain that cannot be renewed - a CNAME
|
|
99
|
+
* that no longer points here, a challenge the CA would not accept - must not
|
|
100
|
+
* take down the rest of the run with it.
|
|
101
|
+
*/
|
|
102
|
+
static async renewCertForDomain(data) {
|
|
103
|
+
const { domain } = data;
|
|
104
|
+
const certLogAttributes = {
|
|
105
|
+
domain: domain,
|
|
106
|
+
};
|
|
107
|
+
logger.debug(`Renewing certificate for domain: ${domain}`, certLogAttributes);
|
|
108
|
+
try {
|
|
109
|
+
//validate cname
|
|
110
|
+
const isValidCname = await data.validateCname(domain);
|
|
111
|
+
if (!isValidCname) {
|
|
112
|
+
logger.debug(`CNAME is not valid for domain: ${domain}`, certLogAttributes);
|
|
113
|
+
// if cname is not valid then remove the domain
|
|
114
|
+
await GreenlockUtil.removeDomain(domain);
|
|
115
|
+
await data.notifyDomainRemoved(domain);
|
|
116
|
+
logger.error(`Cname is not valid for domain: ${domain}`, certLogAttributes);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
logger.debug(`CNAME is valid for domain: ${domain}`, certLogAttributes);
|
|
120
|
+
await GreenlockUtil.orderCert({
|
|
121
|
+
domain: domain,
|
|
122
|
+
validateCname: data.validateCname,
|
|
123
|
+
});
|
|
124
|
+
logger.debug(`Certificate renewed for domain: ${domain}`, certLogAttributes);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
logger.error(`Error renewing certificate for domain: ${domain}`, certLogAttributes);
|
|
129
|
+
logger.error(e, certLogAttributes);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
88
132
|
static async removeDomain(domain) {
|
|
89
133
|
try {
|
|
90
134
|
// remove certificate for this domain.
|
|
@@ -252,6 +296,37 @@ export default class GreenlockUtil {
|
|
|
252
296
|
}
|
|
253
297
|
}
|
|
254
298
|
}
|
|
299
|
+
/*
|
|
300
|
+
* How early a certificate is renewed, as a range rather than a single value.
|
|
301
|
+
*
|
|
302
|
+
* Let's Encrypt issues for 90 days, so every domain ordered on the same day
|
|
303
|
+
* expires on the same day. Renewing them all at one fixed lead time keeps
|
|
304
|
+
* that batch together for every cycle that follows, and a single bad day -
|
|
305
|
+
* an upstream outage, a rate limit, a run that does not finish - then expires
|
|
306
|
+
* the whole batch at once instead of one domain.
|
|
307
|
+
*
|
|
308
|
+
* Spreading the lead time across a range pulls the batch apart: domains that
|
|
309
|
+
* expire on the same day come due days apart, and having been renewed days
|
|
310
|
+
* apart they expire days apart next cycle too. The offset is derived from the
|
|
311
|
+
* domain name so it is stable - a domain must not drift in and out of
|
|
312
|
+
* eligibility between two runs, which would leave it renewed by neither.
|
|
313
|
+
*/
|
|
314
|
+
GreenlockUtil.RENEW_LEAD_TIME_MAX_IN_DAYS = 40;
|
|
315
|
+
GreenlockUtil.RENEW_LEAD_TIME_MIN_IN_DAYS = 25;
|
|
316
|
+
/*
|
|
317
|
+
* A run renews at most this many domains, at most this many at a time.
|
|
318
|
+
*
|
|
319
|
+
* Both bound how much of a backlog is dispatched at once. Let's Encrypt
|
|
320
|
+
* allows 300 new orders per account per three hours, and the reactive
|
|
321
|
+
* provisioning sweep spends from the same allowance, so a run that tried to
|
|
322
|
+
* clear a large backlog in one pass would spend the account's budget and get
|
|
323
|
+
* the renewals behind it refused. At the schedule this job runs on the cap
|
|
324
|
+
* still clears far more per day than one sequential daily pass ever did,
|
|
325
|
+
* while leaving room under the limit.
|
|
326
|
+
*/
|
|
327
|
+
GreenlockUtil.RENEW_MAX_PER_RUN = 10;
|
|
328
|
+
GreenlockUtil.RENEW_CONCURRENCY = 5;
|
|
329
|
+
export default GreenlockUtil;
|
|
255
330
|
__decorate([
|
|
256
331
|
CaptureSpan(),
|
|
257
332
|
__metadata("design:type", Function),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Greenlock.js","sourceRoot":"","sources":["../../../../../Server/Utils/Greenlock/Greenlock.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,sBAAsB,MAAM,uCAAuC,CAAC;AAC3E,OAAO,oBAAoB,MAAM,qCAAqC,CAAC;AACvE,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAC3D,OAAO,MAAyB,MAAM,WAAW,CAAC;AAClD,OAAO,SAAS,MAAM,uCAAuC,CAAC;AAC9D,OAAO,SAAS,MAAM,kCAAkC,CAAC;AACzD,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,gBAAgB,MAAM,2CAA2C,CAAC;AACzE,OAAO,SAAS,MAAM,oCAAoC,CAAC;AAC3D,OAAO,eAAe,MAAM,0CAA0C,CAAC;AACvE,OAAO,IAAI,MAAM,qBAAqB,CAAC;AACvC,OAAO,eAAe,MAAM,gDAAgD,CAAC;AAC7E,OAAO,aAAa,MAAM,8CAA8C,CAAC;AACzE,OAAO,IA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BadDataException";
|
|
2
|
+
import LogPipelineProcessorType from "../../Types/Log/LogPipelineProcessorType";
|
|
3
|
+
import { compileGrokPattern } from "../../Utils/Grok/Grok";
|
|
4
|
+
/*
|
|
5
|
+
* Save-time validation for log pipeline processors.
|
|
6
|
+
*
|
|
7
|
+
* A processor that cannot do anything is worse than a rejected one: it
|
|
8
|
+
* sits in the pipeline list looking configured while every log flows
|
|
9
|
+
* past it untouched, and nothing surfaces the fact. That is exactly how
|
|
10
|
+
* GrokParser behaved before it was implemented
|
|
11
|
+
* (OneUptime/oneuptime#2515).
|
|
12
|
+
*
|
|
13
|
+
* The grok pattern is the one field where a typo is both easy and
|
|
14
|
+
* invisible - `%{IPV4:client ip}` or a stray bracket compiles to
|
|
15
|
+
* nothing. Compiling it here is cheap, happens once per human edit, and
|
|
16
|
+
* puts the error in front of the only person who can fix it. The ingest
|
|
17
|
+
* path stays defensive anyway: rows saved before this validation
|
|
18
|
+
* existed still fail closed to "leave the log alone".
|
|
19
|
+
*/
|
|
20
|
+
/*
|
|
21
|
+
* Prefixes become the leading part of an attribute key, so hold them to
|
|
22
|
+
* what an attribute key can sensibly be.
|
|
23
|
+
*/
|
|
24
|
+
const TARGET_PREFIX_REGEX = /^[A-Za-z_][A-Za-z0-9_.@:-]*$/;
|
|
25
|
+
/*
|
|
26
|
+
* `configuration` is a jsonb column, but the dashboard's JSON form field
|
|
27
|
+
* has historically persisted it as a JSON string literal - so both
|
|
28
|
+
* shapes reach here (see LogPipelineService.normalizeProcessorConfig).
|
|
29
|
+
*/
|
|
30
|
+
function readConfiguration(configuration) {
|
|
31
|
+
if (configuration && typeof configuration === "object") {
|
|
32
|
+
return configuration;
|
|
33
|
+
}
|
|
34
|
+
if (typeof configuration === "string") {
|
|
35
|
+
try {
|
|
36
|
+
const parsed = JSON.parse(configuration);
|
|
37
|
+
if (parsed && typeof parsed === "object") {
|
|
38
|
+
return parsed;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (_a) {
|
|
42
|
+
throw new BadDataException("Processor configuration is not valid JSON.");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
export function validateLogPipelineProcessor(candidate) {
|
|
48
|
+
if (candidate.processorType !== LogPipelineProcessorType.GrokParser) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const configuration = readConfiguration(candidate.configuration);
|
|
52
|
+
if (!configuration) {
|
|
53
|
+
throw new BadDataException("A Grok Parser processor needs a configuration with a grok pattern.");
|
|
54
|
+
}
|
|
55
|
+
const config = configuration;
|
|
56
|
+
const pattern = typeof config.pattern === "string" ? config.pattern.trim() : "";
|
|
57
|
+
if (!pattern) {
|
|
58
|
+
throw new BadDataException("A Grok Parser processor needs a grok pattern, for example: %{IPV4:client_ip} %{WORD:verb}");
|
|
59
|
+
}
|
|
60
|
+
// Throws BadDataException with a message written for the person editing.
|
|
61
|
+
compileGrokPattern(pattern);
|
|
62
|
+
if (config.targetPrefix !== undefined && config.targetPrefix !== null) {
|
|
63
|
+
if (typeof config.targetPrefix !== "string") {
|
|
64
|
+
throw new BadDataException("Target prefix must be text.");
|
|
65
|
+
}
|
|
66
|
+
const targetPrefix = config.targetPrefix.trim();
|
|
67
|
+
if (targetPrefix && !TARGET_PREFIX_REGEX.test(targetPrefix)) {
|
|
68
|
+
throw new BadDataException(`"${config.targetPrefix}" is not a valid target prefix. Use letters, digits, and . _ - : @ (starting with a letter or underscore).`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (config.source !== undefined && config.source !== null) {
|
|
72
|
+
if (typeof config.source !== "string") {
|
|
73
|
+
throw new BadDataException("Source field must be text.");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=LogPipelineProcessorValidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogPipelineProcessorValidation.js","sourceRoot":"","sources":["../../../../Server/Utils/LogP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