Commit graph

242 commits

Author SHA1 Message Date
Anthony Sottile
6076fd1b15 Support rebase conflicts in check-merge-conflicts 2017-06-12 10:39:07 -07:00
Evan Felix
a8592669d9 Add a no commit to specific branch hook. (#185)
* add no commit code and config

* add the code

* remove version tweak

* fix logic, remove newline

* add Tests and cleanup testing issues

* remove extraneous modules

* cleanup some pep8 and flake issues

* reorder imports

* more fixes for syntax checking

* code cleanup based off asottile comments

* Use Contractions Properly, alphabatize new hook.

* Adding support for branches with a slash in them.
2017-03-20 10:36:51 -07:00
ushuz
10f8bd2f22 Add unit test for --no-ensure-ascii option 2017-03-20 20:19:01 +08:00
Oliver Zhou
c380d0b3e3 Handling default django test filename of "tests.py" 2017-03-15 00:40:53 -07:00
Anthony Sottile
ef7c425a3e Require a newer version of autopep8 2017-03-13 14:34:13 -07:00
Anthony Sottile
9cee71b5df Add pyupgrade 2017-03-12 18:01:29 -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
Anthony Sottile
81147337c5 Only return nonzero when rewriting whitespace 2017-02-07 09:45:31 -08:00
Anthony Sottile
7752c42452 Add .pre-commit-hooks.yaml for forward compatibility
See pre-commit/pre-commit#470
2017-01-21 18:03:59 -08: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
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
70e405ede2 Add a new hook to forbid new submodules 2016-11-30 09:56:42 -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
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
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
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
Anthony Sottile
8be6f4c77e Remove pylint 2016-08-22 14:38:49 -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
a43122c5f4 Merge pull request #133 from pre-commit/customizable_encoding_pragma
Allow encoding pragma to be customizable
2016-08-12 19:19:28 +02:00
Anthony Sottile
693709e761 Allow encoding pragma to be customizable 2016-08-12 10:11:10 -07:00
Vinay Karanam
c58ae08fed requirements fixer output is similar to pip freeze 2016-07-03 04:10:20 +05:30
Anthony Sottile
cf3aabe9b1 Merge pull request #120 from sanmai-NL/JSON_arbitrary_indentation_separator
Refactor legacy `indent: int` -> `indent: str`
2016-06-12 10:25:59 -07:00
Sander Maijers
a5628863e8
Refactor legacy indent: int -> indent: str
The type of `indent` parameter is preferably `str`. See
http://simplejson.readthedocs.io/en/latest/index.html?highlight=dump#simplejson.dump
. This change allows to specify TABs as indentation delimiter to
`pretty_format_json`. Add input validator/converter for backward compat.
2016-06-12 19:19:07 +02:00
Sander Maijers
9e89b7616a
Increase robustness of tests involving git
1. Disable automatic `git commit` GPG-signing, since that requires interaction.
   This issue was encountered in practice by me, causing spurious test failures
2. In case path operands could turn out to start with dashes, escape the
   operand list with '--'.
2016-06-12 18:58:30 +02:00
Anthony Sottile
a99475afa0 Simplify the tests 2016-05-27 14:09:50 -07:00
Anthony Sottile
4a01f64c8f Fix check-merge-conflict against binary files 2016-05-26 11:20:32 -07:00
William Ting
c92b46587d Add diff3 conflictstyle support for git merge conflicts. 2016-04-30 20:35:33 -07:00
Anthony Sottile
03bf17f2b0 Add a --remove option to fix-encoding-pragma 2016-04-27 11:18:14 -07:00
Anthony Sottile
ea867c2e68 Merge pull request #109 from mattclegg/no-sort-keys
Adding no-sort-keys to pretty_format_json
2016-04-14 08:11:26 -07:00
mattclegg
bd4e37c366 Add test for '--no-sort-keys' 2016-04-14 10:41:39 +01:00
Anthony Sottile
fe9c404019 Forbid files with a UTF-8 BOM 2016-03-18 10:59:31 -07:00
Anthony Sottile
d444ab821d Improve error message when credentials file is not provided 2016-02-08 17:18:56 -08:00
Anthony Sottile
da882286e3 Skip the symlink tests on windows 2016-01-14 19:03:11 -08:00
Benjamin Chess
896c0cfdc0 new hook tests for broken symlinks 2016-01-14 15:25:46 -08:00
Anthony Sottile
3f6f23d73f Teach check-large-files-added about git-lfs. Reslves #82. 2015-12-28 05:38:06 -08:00
Anthony Sottile
7376a29d69 Write to temp directories in such a way that files get cleaned up 2015-12-26 10:58:33 -08:00
Anthony Sottile
3a3a7a153a Run pre-commit during test 2015-12-25 09:42:17 -08:00
phoxelua
58edfc8af6 Fixed regex matching 2015-11-19 00:39:29 -08:00
Anthony Sottile
aa2ba6f94f Add encoding pragma hook. Resolves pre-commit/pre-commit#15 2015-11-13 12:39:43 -08:00
Chris Kuehl
a1b0104f3d Sort requirements.txt case-insensitively 2015-08-17 12:43:13 -07:00
Anthony Sottile
8a8aaf5a60 Add a hook to verify python ast. 2015-08-04 13:48:30 -07:00
Chris Kuehl
ca2be345a1 detect_private_key: print *filenames*, not the key 2015-08-01 17:02:29 -07:00
Anthony Sottile
99574324eb Merge pull request #60 from arahayrabedian/master
AWS credential checking
2015-06-17 11:46:15 -07: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