Skip to content

Commit 8be693b

Browse files
committed
Rebase of dss branch with upstream yelp detect secrets master
Use base.disable_flag_text functionality Strict camelCase
1 parent eecb426 commit 8be693b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+494
-605
lines changed

.secrets.baseline

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "test_data/.*|tests/.*|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2019-08-13T20:44:51Z",
6+
"generated_at": "2020-01-13T18:12:22Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -41,56 +41,56 @@
4141
"hashed_secret": "daefe0b4345a654580dcad25c7c11ff4c944a8c0",
4242
"is_secret": false,
4343
"is_verified": false,
44-
"line_number": 44,
44+
"line_number": 47,
4545
"type": "Private Key"
4646
},
4747
{
4848
"hashed_secret": "f0778f3e140a61d5bbbed5430773e52af2f5fba4",
4949
"is_secret": false,
5050
"is_verified": false,
51-
"line_number": 45,
51+
"line_number": 48,
5252
"type": "Private Key"
5353
},
5454
{
5555
"hashed_secret": "27c6929aef41ae2bcadac15ca6abcaff72cda9cd",
5656
"is_secret": false,
5757
"is_verified": false,
58-
"line_number": 46,
58+
"line_number": 49,
5959
"type": "Private Key"
6060
},
6161
{
6262
"hashed_secret": "4ada9713ec27066b2ffe0b7bd9c9c8d635dc4ab2",
6363
"is_secret": false,
6464
"is_verified": false,
65-
"line_number": 47,
65+
"line_number": 50,
6666
"type": "Private Key"
6767
},
6868
{
6969
"hashed_secret": "1348b145fa1a555461c1b790a2f66614781091e9",
7070
"is_secret": false,
7171
"is_verified": false,
72-
"line_number": 48,
72+
"line_number": 51,
7373
"type": "Private Key"
7474
},
7575
{
7676
"hashed_secret": "be4fc4886bd949b369d5e092eb87494f12e57e5b",
7777
"is_secret": false,
7878
"is_verified": false,
79-
"line_number": 49,
79+
"line_number": 52,
8080
"type": "Private Key"
8181
},
8282
{
8383
"hashed_secret": "9279619d0c9a9529b0b223e3b809f4df24b8ba8b",
8484
"is_secret": false,
8585
"is_verified": false,
86-
"line_number": 50,
86+
"line_number": 53,
8787
"type": "Private Key"
8888
},
8989
{
9090
"hashed_secret": "11200d1bf5e1eb358b5d823c443347d97e982a85",
9191
"is_secret": false,
9292
"is_verified": false,
93-
"line_number": 51,
93+
"line_number": 54,
9494
"type": "Private Key"
9595
}
9696
],
@@ -236,7 +236,7 @@
236236
"hashed_secret": "1348b145fa1a555461c1b790a2f66614781091e9",
237237
"is_secret": false,
238238
"is_verified": false,
239-
"line_number": 799,
239+
"line_number": 849,
240240
"type": "Private Key"
241241
}
242242
]

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ deploy:
2626
branch: mvp
2727
matrix:
2828
include:
29+
- env: TOXENV=py27
30+
python: 2.7
2931
- env: TOXENV=py35
3032
python: 3.5
3133
- env: TOXENV=py36

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ The current heuristic searches we implement out of the box include:
106106

107107
* **ArtifactoryDetector**: checks to see if Artifactory credentials are present.
108108

109-
* **GHDetector**: checks to see if GitHub credentials are present.
109+
* **GheDetector**: checks to see if GitHub credentials are present.
110110

111111
## IBM versioning and rebase guide
112112

detect_secrets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '0.12.5-ibm.6-mvp'
1+
VERSION = '0.13.0-ibm.7-dss'

detect_secrets/core/audit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SecretNotFoundOnSpecifiedLineError(Exception):
2525
def __init__(self, line):
2626
super(SecretNotFoundOnSpecifiedLineError, self).__init__(
2727
'ERROR: Secret not found on line {}!\n'.format(line)
28-
+ 'Try recreating or updating your baseline to fix this issue.',
28+
+ 'Try recreating your baseline to fix this issue.',
2929
)
3030

3131

@@ -206,7 +206,7 @@ def compare_baselines(old_baseline_filename, new_baseline_filename):
206206
except SecretNotFoundOnSpecifiedLineError:
207207
decision = _get_user_decision(prompt_secret_decision=False)
208208

209-
if decision == 'q': # pragma: no cover
209+
if decision == 'q':
210210
print('Quitting...')
211211
break
212212

@@ -562,7 +562,7 @@ def _print_context( # pragma: no cover
562562
raise error_obj
563563

564564

565-
def _get_user_decision(prompt_secret_decision=True, can_step_back=False): # pragma: no cover
565+
def _get_user_decision(prompt_secret_decision=True, can_step_back=False):
566566
"""
567567
:type prompt_secret_decision: bool
568568
:param prompt_secret_decision: if False, won't ask to label secret.
@@ -574,7 +574,7 @@ def _get_user_decision(prompt_secret_decision=True, can_step_back=False): # pra
574574
allowable_user_input.append('b')
575575

576576
user_input = None
577-
while user_input not in allowable_user_input: # pragma: no cover
577+
while user_input not in allowable_user_input:
578578
if user_input:
579579
print('Invalid input.')
580580

detect_secrets/core/baseline.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import re
44
import subprocess
55

6+
from detect_secrets import util
67
from detect_secrets.core.log import get_logger
78
from detect_secrets.core.secrets_collection import SecretsCollection
89

10+
911
log = get_logger(format_string='%(message)s')
1012

1113

@@ -43,13 +45,16 @@ def initialize(
4345
4446
:type should_scan_all_files: bool
4547
:type output_raw: bool
48+
:type output_verified_false: bool
4649
:rtype: SecretsCollection
4750
"""
4851
output = SecretsCollection(
4952
plugins,
5053
custom_plugin_paths=custom_plugin_paths,
5154
exclude_files=exclude_files_regex,
5255
exclude_lines=exclude_lines_regex,
56+
word_list_file=word_list_file,
57+
word_list_hash=word_list_hash,
5358
output_raw=output_raw,
5459
output_verified_false=output_verified_false,
5560
)
@@ -294,8 +299,8 @@ def _get_git_tracked_files(rootdir='.'):
294299
git_files = subprocess.check_output(
295300
[
296301
'git',
302+
'-C', rootdir,
297303
'ls-files',
298-
rootdir,
299304
],
300305
stderr=fnull,
301306
)

detect_secrets/core/potential_secret.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,7 @@ def __init__(
5858
self.verified_result = None
5959
self.other_factors = {}
6060

61-
# If two PotentialSecrets have the same values for these fields,
62-
# they are considered equal. Note that line numbers aren't included
63-
# in this, because line numbers are subject to change.
64-
self.fields_to_compare = ['filename', 'secret_hash', 'type']
65-
66-
def set_secret(self, secret):
67-
self.secret_hash = self.hash_secret(secret)
68-
69-
# Note: Originally, we never wanted to keep the secret value in memory,
61+
# NOTE: Originally, we never wanted to keep the secret value in memory,
7062
# after finding it in the codebase. However, to support verifiable
7163
# secrets (and avoid the pain of re-scanning again), we need to
7264
# keep the plaintext in memory as such.
@@ -76,11 +68,16 @@ def set_secret(self, secret):
7668
# in the repository.
7769
self.secret_value = secret
7870
self.output_raw = output_raw
71+
7972
# If two PotentialSecrets have the same values for these fields,
8073
# they are considered equal. Note that line numbers aren't included
8174
# in this, because line numbers are subject to change.
8275
self.fields_to_compare = ['filename', 'secret_hash', 'type']
8376

77+
def set_secret(self, secret):
78+
self.secret_hash = self.hash_secret(secret)
79+
self.secret_value = secret
80+
8481
@staticmethod
8582
def hash_secret(secret):
8683
"""This offers a way to coherently test this class,

detect_secrets/core/secrets_collection.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,26 @@ def __init__(
2121
custom_plugin_paths=None,
2222
exclude_files=None,
2323
exclude_lines=None,
24+
word_list_file=None,
25+
word_list_hash=None,
2426
output_raw=False,
2527
output_verified_false=False,
2628
):
2729
"""
2830
:type plugins: tuple of detect_secrets.plugins.base.BasePlugin
2931
:param plugins: rules to determine whether a string is a secret
30-
31-
:type custom_plugin_paths: Tuple[str]|None
32-
:param custom_plugin_paths: possibly empty tuple of paths that have custom plugins.
33-
3432
:type exclude_files: str|None
3533
:param exclude_files: optional regex for ignored paths.
36-
3734
:type exclude_lines: str|None
3835
:param exclude_lines: optional regex for ignored lines.
39-
40-
:type version: str
41-
:param version: version of detect-secrets that SecretsCollection
42-
is valid at.
43-
36+
:type word_list_file: str|None
37+
:param word_list_file: optional word list file for ignoring certain words.
38+
:type word_list_hash: str|None
39+
:param word_list_hash: optional iterated sha1 hash of the words in the word list.
4440
:type output_raw: bool|None
45-
:param output_raw: whether or not to output the raw, unhashed secret
41+
:param output_raw: whether or not to output the raw, unhashed secret.
42+
:type output_verified_false: bool
43+
:param output_verified_false: whether to output secrets that fail verification.
4644
"""
4745
self.data = {}
4846
self.version = VERSION
@@ -51,14 +49,16 @@ def __init__(
5149
self.custom_plugin_paths = custom_plugin_paths or ()
5250
self.exclude_files = exclude_files
5351
self.exclude_lines = exclude_lines
54-
<<<<<<< HEAD
52+
53+
self.output_raw = output_raw
54+
self.output_verified_false = output_verified_false
55+
self.version = VERSION
56+
5557
self.word_list_file = word_list_file
5658
self.word_list_hash = word_list_hash
57-
=======
59+
self.version = VERSION
5860
self.output_raw = output_raw
5961
self.output_verified_false = output_verified_false
60-
self.version = VERSION
61-
>>>>>>> Option to output raw secret
6262

6363
@classmethod
6464
def load_baseline_from_string(cls, string):
@@ -347,10 +347,12 @@ def _extract_secrets_from_file(self, f, filename):
347347
log.info('Checking file: %s', filename)
348348

349349
for results, plugin in self._results_accumulator(filename):
350-
results.update(plugin.analyze(
351-
f, filename, self.output_raw,
352-
self.output_verified_false,
353-
))
350+
results.update(
351+
plugin.analyze(
352+
f, filename, self.output_raw,
353+
self.output_verified_false,
354+
),
355+
)
354356
f.seek(0)
355357

356358
except UnicodeDecodeError:

0 commit comments

Comments
 (0)