Commit Graph

18 Commits

Author SHA1 Message Date
Anthony Sottile 8f6152921e drop python3.6 support
python 3.6 reached end of life on 2021-12-23

Committed via https://github.com/asottile/all-repos
2022-01-15 19:24:05 -05:00
Anthony Sottile a5cf10d9b2 Use more inclusive language
Committed via https://github.com/asottile/all-repos
2021-05-14 19:12:09 -07:00
Anthony Sottile a7f73434a6 Use covdefaults to handle coveragerc 2020-02-29 20:34:45 -08:00
Anthony Sottile 21553c2ca9 Allow arbitrarily encoded files to be checked with detect-aws-credentials 2020-02-18 10:24:17 -08:00
Alexander Demin 75d4832e98 Unit test for empty AWS variables 2020-02-13 12:01:38 +00:00
Anthony Sottile 8626e266dd double-quote-string-fixer 2019-02-11 19:57:37 -08:00
Anthony Sottile 4575652bd2 Use default flake8 config 2019-02-11 19:56:15 -08:00
Pablo Vega 7c631b3b79 Adding a test for detect_aws_credentials when key contains spaces 2018-01-26 15:19:01 -08:00
Anthony Sottile b281d87906 Upgrade pre-commit hooks 2017-07-17 17:41:44 -07:00
Anthony Sottile e9aea74a77 Upgrade add-trailing-comma to 0.4.1 2017-07-15 13:06:38 -07:00
Anthony Sottile 2a902e0a07 Use asottile/add-trailing-comma 2017-07-12 18:58:30 -07:00
Mike Fiedler 312e721ce9
Add flag to detect-aws-credentials to allow missing keys
In the event that there exists no configuration for AWS credentials and
they are not exported in to the current environment, a flag may be
passed to allow exiting the hook successfully.

Resolves #174

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
2017-02-10 12:54:03 -05:00
Daniel Roschka 3939aee4a3 Address issues mentioned in review 2017-01-03 19:05:49 +01:00
Daniel Roschka 0fd09bf67a Add AWS_CONFIG_FILE to the environment variables
Turns out there is an additional environment variable AWS_CONFIG_FILE,
which gets evaluated for finding configuration files as well. This
commit adds support for it.
2016-12-30 10:39:38 +01:00
Daniel Roschka b0d4cdb1ee Improve searching for configured AWS credentials
The previous approach for finding AWS credentials was pretty naive and
only covered contents of a single file (~/.aws/credentials by
default).

The AWS CLI documentation states various other ways to configure
credentials which weren't covered:
https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#credentials
Even that aren't all ways, a look into the code shows:
https://github.com/boto/botocore/blob/develop/botocore/credentials.py

This commit changes the behavior so the hook will behave in a way
that if the AWS CLI is able to obtain credentials from local files,
the hook will find them as well.

The changes in detail are:
- detect AWS session tokens and handle them like secret keys.
- always search credentials in the default AWS CLI file locations
  ( ~/.aws/config, ~/.aws/credentials, /etc/boto.cfg and ~/.boto)
- detect AWS credentials configured via environment variables in
  AWS_SECRET_ACCESS_KEY, AWS_SECURITY_TOKEN and AWS_SESSION_TOKEN
- check additional configuration files configured via environment
  variables (AWS_CREDENTIAL_FILE, AWS_SHARED_CREDENTIALS_FILE and
  BOTO_CONFIG)
- print out the first four characters of each secret found in files to
  be checked in, to make it easier to figure out, what the secrets
  were, which were going to be checked in
- improve error handling for parsing ini-files
- improve tests

There is a major functional change introduced by this commit:
Locations the AWS CLI gets credentials from are always searched and
there is no way to disable them. --credentials-file is still there to
specify one or more additional files to search credentials in. It's
the purpose of this hook to find and check files for found
credentials, so it should work in any case. As this commit also
improves error handling for not-existing or malformed configuration
files, it should be no big deal.

Receiving credentials via the EC2 and ECS meta data services is not
covered intentionally, to not further increase the amount of changes
in this commit and as it's probably an edge case anyway to have this
hook running in such an environment.
2016-12-30 08:41:24 +01:00
Anthony Sottile a99475afa0 Simplify the tests 2016-05-27 14:09:50 -07:00
Anthony Sottile d444ab821d Improve error message when credentials file is not provided 2016-02-08 17:18:56 -08:00
Ara Hayrabedian 02e8bdc9d8 add tests, test sample files and minor refactor of exit codes in actual hook in order to facilitate testing 2015-06-12 19:20:56 +04:00