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

Failing with --input parameter in config file #78

Closed
juneb opened this issue Nov 15, 2017 · 3 comments
Closed

Failing with --input parameter in config file #78

juneb opened this issue Nov 15, 2017 · 3 comments

Comments

@juneb
Copy link
Contributor

juneb commented Nov 15, 2017

Is the input parameter permitted in config files?

Using aws-encryption-sdk-cli/1.0.2.3 aws-encryption-sdk/1.3.2 on Windows 10.0.14393.1770, PS 5.1.14393.1770

I have a config file, encrypt.conf, with the following contents:

--encrypt
--input .\TestCLI\Hello.txt
--output .\TestEnc
-S
@cmk.conf  #Includes a CMK ID, not ARN

When I run it, the command fails because it can't parse the input parameter in the file.


(py) PS C:\ps-test> aws-crypto `@encrypt.conf
Invalid source.  Must be a valid pathname pattern or stdin (-)

I created another config file, encrypt-no-i.conf, with the same content, except that I omitted the input parameter.

(py) PS C:\ps-test> cat .\encrypt-no-i.conf
--encrypt
--output .\TestEnc
-S
@cmk.conf

Then, I copied the --input parameter from the encrypt.conf file and added it, unchanged, to the command line. This command succeeds. (Overwrite is expected.)

(py) PS C:\ps-test> aws-crypto `@encrypt-no-i.conf --input .\TestCLI\Hello.txt
2017-11-15 08:43:16,765 - MainThread - aws_encryption_sdk_cli - WARNING - Overwriting existing target file because no action was specified otherwise: .TestEnc

I thought it might be a problem with the relative path in Windows, so I created a config file with the fully-qualified input path. I also tried a directory as the input arg + --recursive. That failed, too.

@mattsb42-aws
Copy link
Member

Interesting. In poking at this offline with @juneb it looks like shlex is squashing \ characters. I'll look into making sure the shlex.escape characters are kept platform-correct.

https://docs.python.org/3/library/shlex.html

@mattsb42-aws
Copy link
Member

Looks like we can fix this by simply turning off shlex's POSIX mode when not in a POSIX environment:

>>> import shlex
>>> shlex.split('--input .\TestCLI\Hello.txt')
['--input', '.TestCLIHello.txt']
>>> shlex.split('--input .\TestCLI\Hello.txt', posix=False)
['--input', '.\\TestCLI\\Hello.txt']

@juneb
Copy link
Contributor Author

juneb commented Nov 17, 2017

Verified that Windows paths in the --input, --output, and --metadata-output parameters are being interpreted correctly. The commands that failed before this fix now succeed.

However, environment variables in config files are not being expanded. #89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants