Commit graph

1190 commits

Author SHA1 Message Date
Anthony Sottile
a7971b7d26 appveyor installed git-lfs, fix coverage 2017-01-03 12:56:22 -08:00
Daniel Roschka
3939aee4a3 Address issues mentioned in review 2017-01-03 19:05:49 +01:00
Daniel Roschka
53697318ee Fix a typo in the README 2016-12-30 16:53:09 +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
Chris Kuehl
9573c13884 Merge pull request #160 from Dunedan/detect-ed255519-keys
Detect Ed25519 keys as well
2016-12-26 16:55:50 -06:00
Chris Kuehl
cdb3e2e4bf Add trailing comma 2016-12-26 14:51:26 -08:00
Daniel Roschka
c549cb25a1 Detect Ed25519 keys as well
Ed255519 keys generated by OpenSSH contain "BEGIN OPENSSH PRIVATE KEY"
as identifier. This commit adds coverage for such keys as well.
2016-12-26 19:09:53 +01:00
Anthony Sottile
96fb7fa10f Document pretty-format-json. Resolves #156 2016-12-07 10:44:29 -08:00
Anthony Sottile
52582865ab Merge pull request #155 from pre-commit/asottile-patch-1
Also remove git variables from appveyor
2016-12-01 23:31:31 -08:00
Anthony Sottile
75283ae18f Also remove git variables from appveyor 2016-12-01 16:16:40 -08:00
Anthony Sottile
af7659de18 Merge pull request #154 from alzeih/patch-1
Fix test error "fatal: empty ident name (for <(null)>) not allowed"
2016-12-01 16:09:00 -08:00
alzeih
0637a50cc2 Fix test error "fatal: empty ident name (for <(null)>) not allowed"
This occurs when there is no global setting for git config options user.name and user.email

An example of the error shown below:

E           pre_commit.util.CalledProcessError: Command: ('/usr/bin/git', 'commit', '-m', 'init', '--allow-empty')
E           Return code: 128
E           Expected return code: 0
E           Output: (none)
E           Errors:
E
E               *** Please tell me who you are.
E
E               Run
E
E                 git config --global user.email "you@example.com"
E                 git config --global user.name "Your Name"
E
E               to set your account's default identity.
E               Omit --global to set the identity only in this repository.
E
E               fatal: empty ident name (for <(null)>) not allowed
2016-12-02 12:50:20 +13:00
Anthony Sottile
77a7bba2f9 v0.6.1 2016-11-30 10:40:03 -08:00
Anthony Sottile
fa5003d201 Merge pull request #153 from chriskuehl/add-forbid-submodules-to-hooks
Add forbid-new-submodules to hooks.yaml
2016-11-30 10:35:59 -08:00
Chris Kuehl
4b928ab06b Add forbid-new-submodules to hooks.yaml 2016-11-30 10:25:51 -08:00
Chris Kuehl
7bcb6a92bf Merge pull request #152 from pre-commit/forbid_new_submodules
Add a new hook to forbid new submodules
2016-11-30 10:07:07 -08:00
Anthony Sottile
e3e4378173 pip dropped pypy3, so will we 2016-11-30 09:59:37 -08:00
Anthony Sottile
70e405ede2 Add a new hook to forbid new submodules 2016-11-30 09:56:42 -08:00
Anthony Sottile
7539d8bd1a Merge pull request #150 from chriskuehl/fix-json-decode-error-message
Fix JSON decode error message
2016-11-12 11:59:34 -08:00
Chris Kuehl
6b9265c96a Fix JSON decode error message 2016-11-12 11:54:14 -08:00
Anthony Sottile
d71b52859b Merge pull request #149 from Lucas-C/master
Displaying the filename when the check-json hook fails with a UnicodeDecodeError - fix #148
2016-11-12 11:16:18 -08:00
Lucas Cimon
54e83f7ceb Displaying the filename when the check-json hook fails with a UnicodeDecodeError - fix #148 2016-11-12 09:15:10 +01:00
Anthony Sottile
4ef03c4223 Merge pull request #147 from EMSL-MSC/master
adds top keys list of keys in hashes to put at the top of a hash
2016-11-03 18:10:46 -07:00
David Brown
e9e9c3d577 add test to show how it works a bit more 2016-11-03 18:05:43 -07:00
dmlb2000
84b1fb6827 let pre-commit fix some stuff 2016-11-03 15:54:48 -07:00
dmlb2000
7f057b0bd5 change the name to show both working and not instead of overwriting the function name 2016-11-03 15:51:24 -07:00
dmlb2000
c7ab197645 don't need to blow away the space here 2016-11-03 15:49:04 -07:00
dmlb2000
d06a515ce1 this is much cleaner and might actually get all the coverage with out a bunch of work 2016-11-03 15:47:21 -07:00
dmlb2000
845a3d5bdf adds top keys list of keys in hashes to put at the top of a hash
This adds custom sorting to preferencially add a list of top keys
at the start of any json hash in the json document
2016-11-03 09:41:23 -07:00
Anthony Sottile
8e0d7bab60 Merge pull request #145 from bdellegrazie/safe-yaml-#104
Use safe_load as per PyYAML documentation
2016-10-23 12:54:08 -04:00
Brett Delle Grazie
a234b23667 Use safe_load as per PyYAML documentation
resolves #104
2016-10-23 17:50:42 +01:00
Anthony Sottile
c8a1c91c76 Merge pull request #144 from jzafran/add-j2-extension-hooks
add j2 extension to trailing-whitespace and end-of-file-fixer
2016-10-18 16:49:44 -07:00
Jeremy
3620c87b09 add j2 extension to trailing-whitespace and end-of-file-fixer 2016-10-18 19:45:46 -04:00
Anthony Sottile
4c90c9557d Merge pull request #143 from rcmurphy/master
Add .groovy and .tex files to whitespace hooks
2016-10-07 10:42:26 -07:00
Rebecca Claire Murphy
17fcaab576
Add .groovy and .tex files to whitespace hooks
Modifies the end-of-file-fixer and trailing-whitespace hooks to include
.groovy and .tex (TeX/LaTeX) files.
2016-10-07 11:50:40 -04:00
Anthony Sottile
18d7035de5 Let's make the files: for the two whitespace fixers the same 2016-09-01 10:08:04 -07:00
Anthony Sottile
629896ed4a Merge pull request #142 from htmldoug/add-scala-typescript
end-of-file-fixer & trailing-whitespace: Add .scala and .ts files.
2016-09-01 10:06:09 -07:00
Doug Roper
9a68f58541 end-of-file-fixer & trailing-whitespace: Add .scala and .ts files. 2016-09-01 12:34:02 -04:00
Anthony Sottile
1858edd9da Merge pull request #135 from Lucas-C/master
trailing-whitespace hook: restoring original file in case of failure - fixes #134
2016-08-31 07:35:34 -07:00
Lucas Cimon
cb23c48b0d Post-review fixes 2016-08-31 11:44:59 +02:00
Lucas Cimon
c3c870c398 trailing-whitespace hook: support for CRLFs 2016-08-30 10:34:06 +01:00
Anthony Sottile
09d1747840 Merge pull request #139 from pre-commit/no_py33
Drop py33, add py35
2016-08-22 14:52:13 -07:00
Anthony Sottile
8be6f4c77e Remove pylint 2016-08-22 14:38:49 -07:00
Anthony Sottile
d19360c179 Drop py33, add py35 2016-08-22 14:32:12 -07:00
Anthony Sottile
5744ccfd2a Merge pull request #138 from pre-commit/asottile-patch-1
Document `--indent` for pretty-format-json
2016-08-22 14:27:20 -07:00
Anthony Sottile
b4a9600fa5 Document --indent for pretty-format-json 2016-08-22 14:23:23 -07:00
Lucas Cimon
eaad923dd4 trailing-whitespace hook: Switching from using fileinput to a tempfile and whitespace substitution in binary mode 2016-08-20 11:59:10 +01:00
Lucas Cimon
bc5e7f2d72 trailing-whitespace hook: restoring original file in case of failure - fixes #134 2016-08-19 18:26:33 +02:00
Anthony Sottile
775a7906cd pre-commit-hooks is a pure python package 2016-08-12 10:24:39 -07:00