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

Support !import and !include in awx import -f yaml command #8136

Conversation

neoaggelos
Copy link
Contributor

@neoaggelos neoaggelos commented Sep 13, 2020

SUMMARY

Closes #8135

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
  • API
AWX VERSION
awx: 14.1.0
ADDITIONAL INFORMATION

The description in #8135 should be enough, let me know if something is not clear.


@neoaggelos
Copy link
Contributor Author

This is a proposal solution, keeping the diff as small as possible. I can update/change as required if something more complex may be needed.

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@@ -140,7 +140,7 @@ def handle(self, client, parser):
if fmt == 'json':
data = json.load(client.stdin)
elif fmt == 'yaml':
data = yaml.safe_load(client.stdin)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some alarm bells going off for me for the security implications here:

https://pyyaml.org/wiki/PyYAMLDocumentation

Warning: It is not safe to call yaml.load with any data received from an untrusted source! yaml.load is as powerful as pickle.load and so may call any Python function. Check the yaml.safe_load function though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am aware of load vs safe_load, but this is not an issue here, since we do specify a "safe" loader.

The safety implications of yaml.load() stem from the fact that yaml.Loader is unsafe. Here, we use awxkit.yaml_file.Loader which inherits from yaml.SafeLoader, so to me it seems equivalent from a safety standpoint.

Also, yaml.safe_load() is simply an alias for yaml.load(..., loader=SafeLoader).

Copy link
Contributor

@ryanpetrello ryanpetrello Sep 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yep!

Sorry, I wasn't looking closely enough at this PR. Thanks, @neoaggelos.

Copy link
Contributor

@ryanpetrello ryanpetrello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty reasonable to me.

@jbradberry or @elyezer either of you want to give it awhirl and sign off?

Copy link
Contributor

@jbradberry jbradberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, barring some problems with a dependency that wasn't installed.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 4b72630 into ansible:devel Sep 15, 2020
@neoaggelos neoaggelos deleted the awxkit-import-yaml-loader branch September 15, 2020 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support !include and !import constructors in awx import -f yaml command
4 participants