Skip to content

Commit

Permalink
Merge pull request trufflesecurity#15 from bandrel/dev
Browse files Browse the repository at this point in the history
fix for windows access denied issue
  • Loading branch information
dxa4481 authored Jan 4, 2017
2 parents 6ebf25e + 96a4866 commit 6b6a791
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions truffleHog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import argparse
import tempfile
from git import Repo
import os
import stat

if sys.version_info[0] == 2:
reload(sys)
Expand All @@ -14,6 +16,10 @@
BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
HEX_CHARS = "1234567890abcdefABCDEF"

def del_rw(action, name, exc):
os.chmod(name, stat.S_IWRITE)
os.remove(name)

def shannon_entropy(data, iterator):
"""
Borrowed from http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html
Expand Down Expand Up @@ -113,13 +119,14 @@ def find_strings(git_url):
print(printableDiff)

prev_commit = curr_commit
shutil.rmtree(project_path)
return project_path

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Find secrets hidden in the depths of git.')
parser.add_argument('git_url', type=str, help='URL for secret searching')


args = parser.parse_args()
find_strings(args.git_url)
project_path = find_strings(args.git_url)
shutil.rmtree(project_path, onerror=del_rw)

0 comments on commit 6b6a791

Please sign in to comment.