Changing load/dump in source files (#190641)

## Summary

Updates usage of `js-yaml` `load` and `dump` to `safeLoad` and
`safeDump`, in preparation for a major version update of dependency,
where the default behavior will be that of the safe function variants.


## Note to reviewers
`safeDump` will throw if it encounters invalid types (e.g. `undefined`),
whereas the `dump` function will still write the file including the
invalid types. This may have an affect within your use cases - if
throwing is not acceptable or is unhandled. To avoid this the
`skipInvalid` option can be used (see
https://github.com/nodeca/js-yaml#dump-object---options-) - this will
write the file, stripping out any invalid types from the input.

Please consider this when reviewing the changes to your code. If the
`skipInvalid` option is needed, please add it, or let us know to make
the change.

---------

Co-authored-by: Sid <siddharthmantri1@gmail.com>
Co-authored-by: “jeramysoucy” <jeramy.soucy@elastic.co>
Co-authored-by: Elena Shostak <elena.shostak@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
This commit is contained in:
Kurt 2024-08-21 07:29:36 -04:00 committed by GitHub
parent 5acd638327
commit bcc46b60e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 265 additions and 57 deletions

View file

@ -19,7 +19,7 @@ var allManifestPaths = Object.values(manifestsSource).flat();
try {
for (var manifestRelPath of allManifestPaths) {
var manifest = yaml.load(fs.readFileSync(manifestRelPath, 'utf8'));
var manifest = yaml.safeLoad(fs.readFileSync(manifestRelPath, 'utf8'));
if (manifest.enabled) {
manifest.enabled.forEach(function (x) {
console.log(x);