mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Integration Assistant] Prevent wrongly formatted pipelines (#190626)
## Summary This PR resolves certain scenarios causing the ingest pipeline to be malformed when generated.
This commit is contained in:
parent
c2fc468638
commit
c00a06164a
4 changed files with 6 additions and 6 deletions
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { load } from 'js-yaml';
|
||||
import { safeLoad } from 'js-yaml';
|
||||
import { Environment, FileSystemLoader } from 'nunjucks';
|
||||
import { join as joinPath } from 'path';
|
||||
import type { EcsMappingState } from '../../types';
|
||||
|
@ -185,6 +185,6 @@ export function createPipeline(state: EcsMappingState): IngestPipeline {
|
|||
});
|
||||
const template = env.getTemplate('pipeline.yml.njk');
|
||||
const renderedTemplate = template.render(mappedValues);
|
||||
const ingestPipeline = load(renderedTemplate) as IngestPipeline;
|
||||
const ingestPipeline = safeLoad(renderedTemplate) as IngestPipeline;
|
||||
return ingestPipeline;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@ import { createSync } from '../util';
|
|||
|
||||
export function createPipeline(specificDataStreamDir: string, pipeline: object): void {
|
||||
const filePath = joinPath(specificDataStreamDir, 'elasticsearch/ingest_pipeline/default.yml');
|
||||
const yamlContent = `---\n${yaml.dump(pipeline, { sortKeys: false })}`;
|
||||
const yamlContent = `---\n${yaml.safeDump(pipeline, { sortKeys: false })}`;
|
||||
createSync(filePath, yamlContent);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { load } from 'js-yaml';
|
||||
import { safeLoad } from 'js-yaml';
|
||||
import { join as joinPath } from 'path';
|
||||
import { Environment, FileSystemLoader } from 'nunjucks';
|
||||
import { deepCopy } from './util';
|
||||
|
@ -43,6 +43,6 @@ function createAppendProcessors(processors: SimplifiedProcessors): ESProcessorIt
|
|||
});
|
||||
const template = env.getTemplate('append.yml.njk');
|
||||
const renderedTemplate = template.render({ processors });
|
||||
const appendProcessors = load(renderedTemplate) as ESProcessorItem[];
|
||||
const appendProcessors = safeLoad(renderedTemplate) as ESProcessorItem[];
|
||||
return appendProcessors;
|
||||
}
|
||||
|
|
|
@ -203,5 +203,5 @@ export function generateFields(mergedDocs: string): string {
|
|||
.filter((key) => !ecsTopKeysSet.has(key))
|
||||
.map((key) => recursiveParse(doc[key], [key]));
|
||||
|
||||
return yaml.dump(fieldsStructure, { sortKeys: false });
|
||||
return yaml.safeDump(fieldsStructure, { sortKeys: false });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue