Disallow anchors/aliases to objects when loading config YAML
This commit is contained in:
parent
e8e764c3b7
commit
cb8d914fef
5 changed files with 96 additions and 3 deletions
11
backend/src/utils/loadYamlSafely.ts
Normal file
11
backend/src/utils/loadYamlSafely.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import yaml from "js-yaml";
|
||||
import { validateNoObjectAliases } from "./validateNoObjectAliases";
|
||||
|
||||
/**
|
||||
* Loads a YAML file safely while removing object anchors/aliases (including arrays)
|
||||
*/
|
||||
export function loadYamlSafely(yamlStr: string): any {
|
||||
const loaded = yaml.safeLoad(yamlStr);
|
||||
validateNoObjectAliases(loaded);
|
||||
return loaded;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue