mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-31 18:46:53 +00:00
Allow arbitrary binary to pass the private key hook check. Resolves #64
This commit is contained in:
parent
6077f2fefb
commit
07c938e1b1
2 changed files with 7 additions and 7 deletions
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import io
|
||||
import sys
|
||||
|
||||
|
||||
|
|
@ -13,12 +12,11 @@ def detect_private_key(argv=None):
|
|||
private_key_files = []
|
||||
|
||||
for filename in args.filenames:
|
||||
with io.open(filename, 'r') as f:
|
||||
content = f.read()
|
||||
if 'BEGIN RSA PRIVATE KEY' in content:
|
||||
private_key_files.append(content)
|
||||
if 'BEGIN DSA PRIVATE KEY' in content:
|
||||
private_key_files.append(content)
|
||||
content = open(filename, 'rb').read()
|
||||
if b'BEGIN RSA PRIVATE KEY' in content:
|
||||
private_key_files.append(content)
|
||||
if b'BEGIN DSA PRIVATE KEY' in content:
|
||||
private_key_files.append(content)
|
||||
|
||||
if private_key_files:
|
||||
for private_key_file in private_key_files:
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ TESTS = (
|
|||
(b'-----BEGIN DSA PRIVATE KEY-----', 1),
|
||||
(b'ssh-rsa DATA', 0),
|
||||
(b'ssh-dsa DATA', 0),
|
||||
# Some arbitrary binary data
|
||||
(b'\xa2\xf1\x93\x12', 0),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue