Skip to content

Commit

Permalink
change wording to secret x of y
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Li committed Oct 5, 2018
1 parent 54abf27 commit cc6bddb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 31 deletions.
28 changes: 7 additions & 21 deletions detect_secrets/core/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,13 @@ def _print_context(filename, secret, count, total, plugin_settings): # pragma:
:raises: SecretNotFoundOnSpecifiedLineError
"""
secrets_left = '{}/{}'.format(
count,
total,
)
print('{} {}\n{} {}'.format(
BashColor.color(
'Secrets Left:',
Color.BOLD,
),
BashColor.color(
secrets_left,
Color.PURPLE,
),
BashColor.color(
'Filename: ',
Color.BOLD,
),
BashColor.color(
filename,
Color.PURPLE,
),
print('{} {} {} {}\n{} {}'.format(
BashColor.color('Secret', Color.BOLD),
BashColor.color(str(count), Color.PURPLE),
BashColor.color('of', Color.BOLD),
BashColor.color(str(total), Color.PURPLE),
BashColor.color('Filename:', Color.BOLD),
BashColor.color(filename, Color.PURPLE),
))
print('-' * 10)

Expand Down
16 changes: 8 additions & 8 deletions tests/core/audit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ def test_basic(self, mock_printer):
assert sed_call.call_args[0][0] == 'sed -n 10,20p filenameA'.split()

assert mock_printer.message == textwrap.dedent("""
Secrets Left: 1/2
Filename: filenameA
Secret 1 of 2
Filename: filenameA
----------
10:a
11:b
Expand Down Expand Up @@ -394,8 +394,8 @@ def test_secret_at_top_of_file(self, mock_printer):
assert sed_call.call_args[0][0] == 'sed -n 1,6p filenameA'.split()

assert mock_printer.message == textwrap.dedent("""
Secrets Left: 1/2
Filename: filenameA
Secret 1 of 2
Filename: filenameA
----------
1:-----BEGIN PRIVATE KEY-----
2:e
Expand All @@ -421,8 +421,8 @@ def test_secret_not_found(self, mock_printer):
)

assert mock_printer.message == textwrap.dedent("""
Secrets Left: 1/2
Filename: filenameA
Secret 1 of 2
Filename: filenameA
----------
ERROR: Secret not found on line 15!
Try recreating your baseline to fix this issue.
Expand Down Expand Up @@ -450,8 +450,8 @@ def test_secret_in_yaml_file(self, mock_printer):
)

assert mock_printer.message == textwrap.dedent("""
Secrets Left: 1/2
Filename: filenameB
Secret 1 of 2
Filename: filenameB
----------
10:a
11:b
Expand Down
4 changes: 2 additions & 2 deletions tests/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ def test_audit_short_file(self, filename, expected_output):
main('audit will_be_mocked'.split())

assert printer_shim.message == textwrap.dedent("""
Secrets Left: 1/1
Filename: {}
Secret 1 of 1
Filename: {}
----------
{}
----------
Expand Down

0 comments on commit cc6bddb

Please sign in to comment.