Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] add an excess validation instead of the exact match #76472

Merged
merged 8 commits into from
Sep 3, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import path, { join, resolve } from 'path';
import * as rt from 'io-ts';
import stream from 'stream';

import {
TIMELINE_DRAFT_URL,
Expand All @@ -20,8 +21,8 @@ import { requestMock } from '../../../detection_engine/routes/__mocks__';
import { updateTimelineSchema } from '../schemas/update_timelines_schema';
import { createTimelineSchema } from '../schemas/create_timelines_schema';
import { GetTimelineByIdSchemaQuery } from '../schemas/get_timeline_by_id_schema';
import { getReadables } from '../utils/common';

const readable = new stream.Readable();
export const getExportTimelinesRequest = () =>
requestMock.create({
method: 'get',
Expand All @@ -34,15 +35,20 @@ export const getExportTimelinesRequest = () =>
},
});

export const getImportTimelinesRequest = (filename?: string) =>
requestMock.create({
export const getImportTimelinesRequest = async (fileName?: string) => {
const dir = resolve(join(__dirname, '../../../detection_engine/rules/prepackaged_timelines'));
const file = fileName ?? 'index.ndjson';
const dataPath = path.join(dir, file);
const readable = await getReadables(dataPath);
return requestMock.create({
method: 'post',
path: TIMELINE_IMPORT_URL,
query: { overwrite: false },
body: {
file: { ...readable, hapi: { filename: filename ?? 'filename.ndjson' } },
file: { ...readable, hapi: { filename: file } },
},
});
};

export const inputTimeline: SavedTimeline = {
columns: [
Expand Down
Loading