Skip to content

Commit 6b09a1f

Browse files
committed
Add separate config for Rule and Timeline saved objects
We had previously used the savedObjects' config, but those are not currently exposed to us on New Platform. For now, we're going to split this into two sets of values for the SOs we deal with importing/exporting within the SIEM app, with the same defaults as savedObjects.
1 parent a8f272b commit 6b09a1f

6 files changed

Lines changed: 14 additions & 10 deletions

File tree

x-pack/plugins/siem/server/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import { SIGNALS_INDEX_KEY, DEFAULT_SIGNALS_INDEX } from '../common/constants';
1111

1212
export const configSchema = schema.object({
1313
enabled: schema.boolean({ defaultValue: true }),
14-
maxImportPayloadBytes: schema.number({ defaultValue: 10485760 }),
15-
maxImportExportSize: schema.number({ defaultValue: 10000 }),
14+
maxRuleImportExportSize: schema.number({ defaultValue: 10000 }),
15+
maxRuleImportPayloadBytes: schema.number({ defaultValue: 10485760 }),
16+
maxTimelineImportExportSize: schema.number({ defaultValue: 10000 }),
17+
maxTimelineImportPayloadBytes: schema.number({ defaultValue: 10485760 }),
1618
[SIGNALS_INDEX_KEY]: schema.string({ defaultValue: DEFAULT_SIGNALS_INDEX }),
1719
});
1820

x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export { requestMock, requestContextMock, responseMock, serverMock };
1515
export const createMockConfig = () => ({
1616
enabled: true,
1717
[SIGNALS_INDEX_KEY]: DEFAULT_SIGNALS_INDEX,
18-
maxImportPayloadBytes: 10485760,
19-
maxImportExportSize: 10000,
18+
maxRuleImportExportSize: 10000,
19+
maxRuleImportPayloadBytes: 10485760,
20+
maxTimelineImportExportSize: 10000,
21+
maxTimelineImportPayloadBytes: 10485760,
2022
});

x-pack/plugins/siem/server/lib/detection_engine/routes/rules/export_rules_route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const exportRulesRoute = (router: IRouter, config: ConfigType) => {
3535
}
3636

3737
try {
38-
const exportSizeLimit = config.maxImportExportSize;
38+
const exportSizeLimit = config.maxRuleImportExportSize;
3939
if (request.body?.objects != null && request.body.objects.length > exportSizeLimit) {
4040
return siemResponse.error({
4141
statusCode: 400,

x-pack/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const importRulesRoute = (router: IRouter, config: ConfigType) => {
4949
options: {
5050
tags: ['access:siem'],
5151
body: {
52-
maxBytes: config.maxImportPayloadBytes,
52+
maxBytes: config.maxRuleImportPayloadBytes,
5353
output: 'stream',
5454
},
5555
},
@@ -77,7 +77,7 @@ export const importRulesRoute = (router: IRouter, config: ConfigType) => {
7777
});
7878
}
7979

80-
const objectLimit = config.maxImportExportSize;
80+
const objectLimit = config.maxRuleImportExportSize;
8181
const readStream = createRulesStreamFromNdJson(objectLimit);
8282
const parsedObjects = await createPromiseFromStreams<PromiseFromStreams[]>([
8383
request.body.file,

x-pack/plugins/siem/server/lib/timeline/routes/export_timelines_route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const exportTimelinesRoute = (router: IRouter, config: ConfigType) => {
3434
try {
3535
const siemResponse = buildSiemResponse(response);
3636
const savedObjectsClient = context.core.savedObjects.client;
37-
const exportSizeLimit = config.maxImportExportSize;
37+
const exportSizeLimit = config.maxTimelineImportExportSize;
3838

3939
if (request.body?.ids != null && request.body.ids.length > exportSizeLimit) {
4040
return siemResponse.error({

x-pack/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const importTimelinesRoute = (
5656
options: {
5757
tags: ['access:siem'],
5858
body: {
59-
maxBytes: config.maxImportPayloadBytes,
59+
maxBytes: config.maxTimelineImportPayloadBytes,
6060
output: 'stream',
6161
},
6262
},
@@ -81,7 +81,7 @@ export const importTimelinesRoute = (
8181
});
8282
}
8383

84-
const objectLimit = config.maxImportExportSize;
84+
const objectLimit = config.maxTimelineImportExportSize;
8585

8686
const readStream = createTimelinesStreamFromNdJson(objectLimit);
8787
const parsedObjects = await createPromiseFromStreams<PromiseFromStreams[]>([

0 commit comments

Comments
 (0)