Skip to content

Commit 2c2e2b4

Browse files
committed
fixing weird variable scoping issue
1 parent 461953f commit 2c2e2b4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
from setuptools import setup
1+
from setuptools import setup, find_packages
22

33
setup(
44
name='truffleHog',
5-
version='2.0.6',
5+
version='2.0.87',
66
description='Searches through git repositories for high entropy strings, digging deep into commit history.',
77
url='https://github.com/dxa4481/truffleHog',
88
author='Dylan Ayrey',
99
author_email='[email protected]',
1010
license='GNU',
11-
packages =['truffleHog'],
11+
packages = ['truffleHog', 'truffleHog.defaultRegexes'],
1212
install_requires=[
1313
'GitPython == 2.1.1'
1414
],

truffleHog/truffleHog.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
from __future__ import absolute_import
45
import shutil
56
import sys
67
import math
@@ -178,10 +179,14 @@ def find_entropy(printableDiff, commit_time, branch_name, prev_commit, blob, com
178179
entropicDiff['reason'] = "High Entropy"
179180
return entropicDiff
180181

181-
def regex_check(printableDiff, commit_time, branch_name, prev_commit, blob, commitHash):
182+
def regex_check(printableDiff, commit_time, branch_name, prev_commit, blob, commitHash, custom_regexes={}):
183+
if custom_regexes:
184+
secret_regexes = custom_regexes
185+
else:
186+
secret_regexes = regexes
182187
regex_matches = []
183-
for key in regexes:
184-
found_strings = regexes[key].findall(printableDiff)
188+
for key in secret_regexes:
189+
found_strings = secret_regexes[key].findall(printableDiff)
185190
for found_string in found_strings:
186191
found_diff = printableDiff.replace(printableDiff, bcolors.WARNING + found_string + bcolors.ENDC)
187192
if found_strings:
@@ -201,7 +206,7 @@ def regex_check(printableDiff, commit_time, branch_name, prev_commit, blob, comm
201206

202207

203208

204-
def find_strings(git_url, since_commit=None, max_depth=None, printJson=False, do_regex=False, do_entropy=True):
209+
def find_strings(git_url, since_commit=None, max_depth=None, printJson=False, do_regex=False, do_entropy=True, custom_regexes={}):
205210
output = {"foundIssues": []}
206211
project_path = clone_git_repo(git_url)
207212
repo = Repo(project_path)
@@ -245,7 +250,7 @@ def find_strings(git_url, since_commit=None, max_depth=None, printJson=False, do
245250
if entropicDiff:
246251
foundIssues.append(entropicDiff)
247252
if do_regex:
248-
found_regexes = regex_check(printableDiff, commit_time, branch_name, prev_commit, blob, commitHash)
253+
found_regexes = regex_check(printableDiff, commit_time, branch_name, prev_commit, blob, commitHash, custom_regexes)
249254
foundIssues += found_regexes
250255
for foundIssue in foundIssues:
251256
print_results(printJson, foundIssue)

0 commit comments

Comments
 (0)