@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.
Files changed (182) hide show
  1. package/Models/DatabaseModels/DashboardDomain.ts +43 -0
  2. package/Models/DatabaseModels/MonitorTemplate.ts +15 -3
  3. package/Models/DatabaseModels/StatusPageDomain.ts +43 -0
  4. package/Server/API/DashboardDomainAPI.ts +74 -0
  5. package/Server/API/MicrosoftTeamsAPI.ts +81 -180
  6. package/Server/API/StatusPageDomainAPI.ts +74 -0
  7. package/Server/Infrastructure/Postgres/SchemaMigrations/1790200000000-AllowNullMonitorNameOnMonitorTemplate.ts +43 -0
  8. package/Server/Infrastructure/Postgres/SchemaMigrations/1790300000000-AddCertificateReissueRequestedAtToDomains.ts +40 -0
  9. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
  10. package/Server/Middleware/ProjectAuthorization.ts +6 -1
  11. package/Server/Services/DashboardDomainService.ts +131 -0
  12. package/Server/Services/LogPipelineProcessorService.ts +88 -0
  13. package/Server/Services/MonitorTemplateService.ts +70 -11
  14. package/Server/Services/StatusPageDomainService.ts +163 -3
  15. package/Server/Services/StatusPagePrivateUserSessionService.ts +197 -56
  16. package/Server/Types/Domain.ts +17 -0
  17. package/Server/Utils/APIKey/AccessPermission.ts +24 -0
  18. package/Server/Utils/Greenlock/Greenlock.ts +156 -58
  19. package/Server/Utils/LogPipelineProcessorValidation.ts +112 -0
  20. package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.ts +1094 -45
  21. package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.ts +153 -17
  22. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts +23 -11
  23. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.ts +0 -170
  24. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Authorization.ts +158 -0
  25. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts +23 -11
  26. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +35 -13
  27. package/Tests/App/Dashboard/MonitorTemplateColumnAndFacet.test.tsx +505 -0
  28. package/Tests/App/StatusPage/StatusPageLoginCodeBootstrap.test.ts +106 -0
  29. package/Tests/App/StatusPage/StatusPageLoginCodeUtil.test.ts +84 -0
  30. package/Tests/App/StatusPage/StatusPageRedirectSafety.test.ts +119 -0
  31. package/Tests/Models/MonitorTemplateMonitorNameColumn.test.ts +258 -0
  32. package/Tests/Server/API/CustomDomainReissueSslAPI.test.ts +469 -0
  33. package/Tests/Server/API/MicrosoftTeamsBotMessagesEndpoint.test.ts +729 -0
  34. package/Tests/Server/API/MicrosoftTeamsBotTestEndpoint.test.ts +26 -0
  35. package/Tests/Server/API/MicrosoftTeamsLegacyWebhookRemoval.test.ts +402 -0
  36. package/Tests/Server/Middleware/ProjectAuthorizationApiKeyMiddleware.test.ts +4 -0
  37. package/Tests/Server/Services/AddCertificateReissueRequestedAtToDomainsMigration.test.ts +287 -0
  38. package/Tests/Server/Services/CustomDomainCertificateReissue.test.ts +477 -0
  39. package/Tests/Server/Services/LogPipelineProcessorSaveValidation.test.ts +249 -0
  40. package/Tests/Server/Services/MonitorTemplateServiceBulkSync.test.ts +549 -0
  41. package/Tests/Server/Services/MonitorTemplateServiceNetworkDeviceSync.test.ts +16 -3
  42. package/Tests/Server/Services/NetworkDeviceAutoImportRuleEngineService.test.ts +57 -0
  43. package/Tests/Server/Services/SecurityEventLastErrorColumnWidth.test.ts +151 -15
  44. package/Tests/Server/Services/StatusPagePrivateUserSessionService.test.ts +587 -0
  45. package/Tests/Server/Types/Database/Permissions/ApiKeyFileAccess.test.ts +286 -0
  46. package/Tests/Server/Types/Database/Permissions/MonitorTemplateColumnAccess.test.ts +328 -0
  47. package/Tests/Server/Types/Database/QueryHelperFindWithSameTextAndIsNull.test.ts +83 -0
  48. package/Tests/Server/Utils/AI/SRE/ConfidenceSignal.test.ts +377 -0
  49. package/Tests/Server/Utils/APIKey/AccessPermission.test.ts +16 -1
  50. package/Tests/Server/Utils/Greenlock/CertificateRenewalSchedule.test.ts +250 -0
  51. package/Tests/Server/Utils/LogPipelineProcessorValidation.test.ts +198 -0
  52. package/Tests/Server/Utils/SecurityEvent/ConnectorErrorMessage.test.ts +48 -9
  53. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsAuth.test.ts +726 -0
  54. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsClient.test.ts +74 -11
  55. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsErrorHandling.test.ts +1107 -0
  56. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPoller.test.ts +20 -3
  57. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPollerFailureTaxonomy.test.ts +51 -11
  58. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPollerHardening.test.ts +1246 -0
  59. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsRequestContract.test.ts +961 -0
  60. package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsResponseParsing.test.ts +653 -0
  61. package/Tests/Server/Utils/Workspace/MicrosoftTeamsActionAuthorization.test.ts +880 -0
  62. package/Tests/Types/API/HTTPResponse.test.ts +175 -0
  63. package/Tests/Types/API/Route.test.ts +36 -4
  64. package/Tests/Types/Database/DatabaseProperty.test.ts +171 -0
  65. package/Tests/Types/DateLocalShortDateTimeString.test.ts +518 -0
  66. package/Tests/Types/DateLocalTimeString.test.ts +259 -0
  67. package/Tests/Types/DateUserPrefers12HourFormat.test.ts +316 -0
  68. package/Tests/UI/Components/LogsHistogram.test.tsx +41 -2
  69. package/Tests/UI/Components/LogsViewerEmptyStateTimeRange.test.tsx +212 -0
  70. package/Tests/UI/Components/TelemetryChartClockFormat.test.tsx +359 -0
  71. package/Tests/UI/Components/TimeRangePickerClockFormat.test.tsx +422 -0
  72. package/Tests/UI/Components/TimeRangePickerDropdown.test.tsx +146 -8
  73. package/Tests/UI/MicrosoftTeams/MicrosoftTeamsMessagingEndpointGuidance.test.tsx +520 -0
  74. package/Tests/UI/Utils/Navigation.test.ts +82 -0
  75. package/Tests/Utils/Array.test.ts +100 -0
  76. package/Tests/Utils/CertificateReissue.test.ts +225 -0
  77. package/Tests/Utils/Grok/Grok.test.ts +492 -0
  78. package/Tests/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.test.ts +181 -13
  79. package/Types/API/Route.ts +20 -5
  80. package/Types/Date.ts +143 -13
  81. package/Types/Rum/SessionReplay.ts +62 -1
  82. package/UI/Components/Date/TimeRangePickerDropdown.tsx +9 -5
  83. package/UI/Components/LogsViewer/LogsViewer.tsx +12 -7
  84. package/UI/Components/LogsViewer/components/HistogramTooltip.tsx +18 -17
  85. package/UI/Components/LogsViewer/components/LogsAnalyticsView.tsx +21 -28
  86. package/UI/Components/LogsViewer/components/LogsHistogram.tsx +2 -4
  87. package/UI/Components/TelemetryViewer/components/TelemetryHistogram.tsx +2 -4
  88. package/UI/Components/TelemetryViewer/components/TelemetryHistogramTooltip.tsx +17 -16
  89. package/UI/Utils/Navigation.ts +42 -0
  90. package/Utils/Array.ts +37 -0
  91. package/Utils/CertificateReissue.ts +128 -0
  92. package/Utils/Grok/Grok.ts +461 -0
  93. package/Utils/Grok/GrokPatterns.ts +118 -0
  94. package/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.ts +58 -6
  95. package/build/dist/Models/DatabaseModels/DashboardDomain.js +44 -0
  96. package/build/dist/Models/DatabaseModels/DashboardDomain.js.map +1 -1
  97. package/build/dist/Models/DatabaseModels/MonitorTemplate.js +17 -4
  98. package/build/dist/Models/DatabaseModels/MonitorTemplate.js.map +1 -1
  99. package/build/dist/Models/DatabaseModels/StatusPageDomain.js +44 -0
  100. package/build/dist/Models/DatabaseModels/StatusPageDomain.js.map +1 -1
  101. package/build/dist/Server/API/DashboardDomainAPI.js +43 -1
  102. package/build/dist/Server/API/DashboardDomainAPI.js.map +1 -1
  103. package/build/dist/Server/API/MicrosoftTeamsAPI.js +74 -118
  104. package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
  105. package/build/dist/Server/API/StatusPageDomainAPI.js +43 -1
  106. package/build/dist/Server/API/StatusPageDomainAPI.js.map +1 -1
  107. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1790200000000-AllowNullMonitorNameOnMonitorTemplate.js +34 -0
  108. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1790200000000-AllowNullMonitorNameOnMonitorTemplate.js.map +1 -0
  109. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1790300000000-AddCertificateReissueRequestedAtToDomains.js +28 -0
  110. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1790300000000-AddCertificateReissueRequestedAtToDomains.js.map +1 -0
  111. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
  112. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  113. package/build/dist/Server/Middleware/ProjectAuthorization.js +6 -1
  114. package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
  115. package/build/dist/Server/Services/DashboardDomainService.js +104 -0
  116. package/build/dist/Server/Services/DashboardDomainService.js.map +1 -1
  117. package/build/dist/Server/Services/LogPipelineProcessorService.js +65 -0
  118. package/build/dist/Server/Services/LogPipelineProcessorService.js.map +1 -1
  119. package/build/dist/Server/Services/MonitorTemplateService.js +57 -11
  120. package/build/dist/Server/Services/MonitorTemplateService.js.map +1 -1
  121. package/build/dist/Server/Services/StatusPageDomainService.js +132 -3
  122. package/build/dist/Server/Services/StatusPageDomainService.js.map +1 -1
  123. package/build/dist/Server/Services/StatusPagePrivateUserSessionService.js +112 -32
  124. package/build/dist/Server/Services/StatusPagePrivateUserSessionService.js.map +1 -1
  125. package/build/dist/Server/Types/Domain.js +16 -0
  126. package/build/dist/Server/Types/Domain.js.map +1 -1
  127. package/build/dist/Server/Utils/APIKey/AccessPermission.js +24 -0
  128. package/build/dist/Server/Utils/APIKey/AccessPermission.js.map +1 -1
  129. package/build/dist/Server/Utils/Greenlock/Greenlock.js +110 -35
  130. package/build/dist/Server/Utils/Greenlock/Greenlock.js.map +1 -1
  131. package/build/dist/Server/Utils/LogPipelineProcessorValidation.js +77 -0
  132. package/build/dist/Server/Utils/LogPipelineProcessorValidation.js.map +1 -0
  133. package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.js +777 -36
  134. package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.js.map +1 -1
  135. package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.js +108 -17
  136. package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.js.map +1 -1
  137. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js +17 -6
  138. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js.map +1 -1
  139. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js +0 -159
  140. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js.map +1 -1
  141. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Authorization.js +128 -0
  142. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Authorization.js.map +1 -0
  143. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js +17 -6
  144. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js.map +1 -1
  145. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +25 -13
  146. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  147. package/build/dist/Types/API/Route.js +16 -5
  148. package/build/dist/Types/API/Route.js.map +1 -1
  149. package/build/dist/Types/Date.js +115 -13
  150. package/build/dist/Types/Date.js.map +1 -1
  151. package/build/dist/Types/Rum/SessionReplay.js +38 -0
  152. package/build/dist/Types/Rum/SessionReplay.js.map +1 -1
  153. package/build/dist/UI/Components/Date/TimeRangePickerDropdown.js +9 -5
  154. package/build/dist/UI/Components/Date/TimeRangePickerDropdown.js.map +1 -1
  155. package/build/dist/UI/Components/LogsViewer/LogsViewer.js +12 -7
  156. package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
  157. package/build/dist/UI/Components/LogsViewer/components/HistogramTooltip.js +15 -14
  158. package/build/dist/UI/Components/LogsViewer/components/HistogramTooltip.js.map +1 -1
  159. package/build/dist/UI/Components/LogsViewer/components/LogsAnalyticsView.js +17 -22
  160. package/build/dist/UI/Components/LogsViewer/components/LogsAnalyticsView.js.map +1 -1
  161. package/build/dist/UI/Components/LogsViewer/components/LogsHistogram.js +2 -4
  162. package/build/dist/UI/Components/LogsViewer/components/LogsHistogram.js.map +1 -1
  163. package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js +2 -4
  164. package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js.map +1 -1
  165. package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogramTooltip.js +15 -14
  166. package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogramTooltip.js.map +1 -1
  167. package/build/dist/UI/Utils/Navigation.js +30 -0
  168. package/build/dist/UI/Utils/Navigation.js.map +1 -1
  169. package/build/dist/Utils/Array.js +25 -0
  170. package/build/dist/Utils/Array.js.map +1 -1
  171. package/build/dist/Utils/CertificateReissue.js +97 -0
  172. package/build/dist/Utils/CertificateReissue.js.map +1 -0
  173. package/build/dist/Utils/Grok/Grok.js +324 -0
  174. package/build/dist/Utils/Grok/Grok.js.map +1 -0
  175. package/build/dist/Utils/Grok/GrokPatterns.js +112 -0
  176. package/build/dist/Utils/Grok/GrokPatterns.js.map +1 -0
  177. package/build/dist/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.js +63 -3
  178. package/build/dist/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.js.map +1 -1
  179. package/package.json +1 -1
  180. package/UI/Utils/JsonWebToken.ts +0 -14
  181. package/build/dist/UI/Utils/JsonWebToken.js +0 -10
  182. package/build/dist/UI/Utils/JsonWebToken.js.map +0 -1
@@ -0,0 +1,249 @@
1
+ import LogPipelineProcessorService from "../../../Server/Services/LogPipelineProcessorService";
2
+ import LogPipelineProcessor from "../../../Models/DatabaseModels/LogPipelineProcessor";
3
+ import BadDataException from "../../../Types/Exception/BadDataException";
4
+ import LogPipelineProcessorType from "../../../Types/Log/LogPipelineProcessorType";
5
+ import ObjectID from "../../../Types/ObjectID";
6
+ import { JSONObject } from "../../../Types/JSON";
7
+ import CreateBy from "../../../Server/Types/Database/CreateBy";
8
+ import UpdateBy from "../../../Server/Types/Database/UpdateBy";
9
+ import { afterEach, describe, expect, it, jest } from "@jest/globals";
10
+
11
+ /*
12
+ * Contract under test — the create/update hooks on
13
+ * LogPipelineProcessorService.
14
+ *
15
+ * `processorType` is a free-text column, so the API has always accepted
16
+ * a GrokParser processor with any configuration at all. Before the
17
+ * processor was implemented that meant a silent no-op
18
+ * (OneUptime/oneuptime#2515); now it means an unparsable pattern would
19
+ * be a silent no-op instead, which is the same failure wearing a
20
+ * different hat. The hooks compile the pattern while a human is still
21
+ * looking at the form.
22
+ *
23
+ * Update is the harder half: a request need not name both fields, so
24
+ * switching `processorType` to GrokParser over a stored severity-remap
25
+ * configuration, or replacing the pattern on a row that is already a
26
+ * GrokParser, both have to be caught by validating the MERGED row.
27
+ */
28
+
29
+ const PROCESSOR_ID: ObjectID = new ObjectID(
30
+ "33333333-3333-4333-8333-333333333333",
31
+ );
32
+
33
+ const service: any = LogPipelineProcessorService as any;
34
+
35
+ function createBy(data: {
36
+ processorType?: string | undefined;
37
+ configuration?: JSONObject | string | undefined;
38
+ }): CreateBy<LogPipelineProcessor> {
39
+ const model: any = new LogPipelineProcessor();
40
+ model.name = "Parse nginx access logs";
41
+ model.processorType = data.processorType;
42
+ model.configuration = data.configuration;
43
+
44
+ return {
45
+ data: model,
46
+ props: { isRoot: true },
47
+ } as CreateBy<LogPipelineProcessor>;
48
+ }
49
+
50
+ function updateBy(
51
+ patch: Record<string, unknown>,
52
+ ): UpdateBy<LogPipelineProcessor> {
53
+ return {
54
+ query: { _id: PROCESSOR_ID.toString() },
55
+ data: patch,
56
+ props: { isRoot: true },
57
+ } as unknown as UpdateBy<LogPipelineProcessor>;
58
+ }
59
+
60
+ /*
61
+ * The update hook reads the rows the update matches so it can merge the
62
+ * patch over them. This stands in for that read.
63
+ */
64
+ function mockStoredRow(row: {
65
+ processorType: string;
66
+ configuration: JSONObject | string;
67
+ }): void {
68
+ const model: any = new LogPipelineProcessor();
69
+ model._id = PROCESSOR_ID.toString();
70
+ model.processorType = row.processorType;
71
+ model.configuration = row.configuration;
72
+
73
+ jest
74
+ .spyOn(service, "findBy")
75
+ .mockImplementation(async (): Promise<Array<LogPipelineProcessor>> => {
76
+ return [model];
77
+ });
78
+ }
79
+
80
+ describe("LogPipelineProcessorService — on create", () => {
81
+ afterEach(() => {
82
+ jest.restoreAllMocks();
83
+ });
84
+
85
+ it("accepts a grok processor with a pattern that compiles", async () => {
86
+ await expect(
87
+ service.onBeforeCreate(
88
+ createBy({
89
+ processorType: LogPipelineProcessorType.GrokParser,
90
+ configuration: {
91
+ source: "body",
92
+ pattern: "%{IPV4:client_ip} %{WORD:verb}",
93
+ },
94
+ }),
95
+ ),
96
+ ).resolves.toBeDefined();
97
+ });
98
+
99
+ it("rejects a grok processor whose pattern does not compile", async () => {
100
+ await expect(
101
+ service.onBeforeCreate(
102
+ createBy({
103
+ processorType: LogPipelineProcessorType.GrokParser,
104
+ configuration: { source: "body", pattern: "%{NOSUCHTHING:x}" },
105
+ }),
106
+ ),
107
+ ).rejects.toThrow(BadDataException);
108
+ });
109
+
110
+ it("rejects a grok processor created with no pattern at all", async () => {
111
+ await expect(
112
+ service.onBeforeCreate(
113
+ createBy({
114
+ processorType: LogPipelineProcessorType.GrokParser,
115
+ configuration: { source: "body" },
116
+ }),
117
+ ),
118
+ ).rejects.toThrow(BadDataException);
119
+ });
120
+
121
+ it("accepts the other processor types unchanged", async () => {
122
+ await expect(
123
+ service.onBeforeCreate(
124
+ createBy({
125
+ processorType: LogPipelineProcessorType.SeverityRemapper,
126
+ configuration: {
127
+ sourceKey: "level",
128
+ mappings: [
129
+ {
130
+ matchValue: "warn",
131
+ severityText: "Warning",
132
+ severityNumber: 13,
133
+ },
134
+ ],
135
+ },
136
+ }),
137
+ ),
138
+ ).resolves.toBeDefined();
139
+ });
140
+ });
141
+
142
+ describe("LogPipelineProcessorService — on update", () => {
143
+ afterEach(() => {
144
+ jest.restoreAllMocks();
145
+ });
146
+
147
+ it("accepts a new pattern that compiles", async () => {
148
+ mockStoredRow({
149
+ processorType: LogPipelineProcessorType.GrokParser,
150
+ configuration: { source: "body", pattern: "%{WORD:verb}" },
151
+ });
152
+
153
+ await expect(
154
+ service.onBeforeUpdate(
155
+ updateBy({
156
+ configuration: { source: "body", pattern: "%{IPV4:client_ip}" },
157
+ }),
158
+ ),
159
+ ).resolves.toBeDefined();
160
+ });
161
+
162
+ it("rejects a new pattern that does not compile", async () => {
163
+ mockStoredRow({
164
+ processorType: LogPipelineProcessorType.GrokParser,
165
+ configuration: { source: "body", pattern: "%{WORD:verb}" },
166
+ });
167
+
168
+ await expect(
169
+ service.onBeforeUpdate(
170
+ updateBy({
171
+ configuration: { source: "body", pattern: "%{NOSUCHTHING:x}" },
172
+ }),
173
+ ),
174
+ ).rejects.toThrow(BadDataException);
175
+ });
176
+
177
+ it("catches a type switch to GrokParser over an unrelated stored configuration", async () => {
178
+ mockStoredRow({
179
+ processorType: LogPipelineProcessorType.SeverityRemapper,
180
+ configuration: { sourceKey: "level", mappings: [] },
181
+ });
182
+
183
+ await expect(
184
+ service.onBeforeUpdate(
185
+ updateBy({ processorType: LogPipelineProcessorType.GrokParser }),
186
+ ),
187
+ ).rejects.toThrow(BadDataException);
188
+ });
189
+
190
+ it("catches a broken pattern written onto a row that is already a GrokParser", async () => {
191
+ mockStoredRow({
192
+ processorType: LogPipelineProcessorType.GrokParser,
193
+ configuration: { source: "body", pattern: "%{WORD:verb}" },
194
+ });
195
+
196
+ await expect(
197
+ service.onBeforeUpdate(
198
+ updateBy({ configuration: { source: "body", pattern: "%{WORD:a b}" } }),
199
+ ),
200
+ ).rejects.toThrow(BadDataException);
201
+ });
202
+
203
+ it("does not read the stored row when the update touches neither field", async () => {
204
+ const findBySpy: any = jest
205
+ .spyOn(service, "findBy")
206
+ .mockImplementation(async (): Promise<Array<LogPipelineProcessor>> => {
207
+ return [];
208
+ });
209
+
210
+ await expect(
211
+ service.onBeforeUpdate(updateBy({ name: "renamed" })),
212
+ ).resolves.toBeDefined();
213
+
214
+ expect(findBySpy).not.toHaveBeenCalled();
215
+ });
216
+
217
+ it("skips validation for a raw SQL expression it cannot evaluate", async () => {
218
+ const findBySpy: any = jest
219
+ .spyOn(service, "findBy")
220
+ .mockImplementation(async (): Promise<Array<LogPipelineProcessor>> => {
221
+ return [];
222
+ });
223
+
224
+ await expect(
225
+ service.onBeforeUpdate(
226
+ updateBy({
227
+ configuration: () => {
228
+ return "some_sql_expression";
229
+ },
230
+ }),
231
+ ),
232
+ ).resolves.toBeDefined();
233
+
234
+ expect(findBySpy).not.toHaveBeenCalled();
235
+ });
236
+
237
+ it("leaves a non-grok processor's configuration alone", async () => {
238
+ mockStoredRow({
239
+ processorType: LogPipelineProcessorType.AttributeRemapper,
240
+ configuration: { sourceKey: "src_ip", targetKey: "source_ip" },
241
+ });
242
+
243
+ await expect(
244
+ service.onBeforeUpdate(
245
+ updateBy({ configuration: { sourceKey: "a", targetKey: "b" } }),
246
+ ),
247
+ ).resolves.toBeDefined();
248
+ });
249
+ });