Skip to content

Commit

Permalink
rebase fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
rscottbailey committed Oct 20, 2021
1 parent f142745 commit 9952ab5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion tartufo/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def scan(self) -> Generator[Issue, None, None]:
self.global_options.b64_entropy_score,
self.global_options.hex_entropy_score,
)
self.logger.info("Found %d issues.", self._issue_count))
self.logger.info("Found %d issues.", self._issue_count)

def scan_entropy(
self, chunk: types.Chunk, b64_entropy_score: float, hex_entropy_score: float
Expand Down
52 changes: 27 additions & 25 deletions tests/test_base_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ def test_scan_entropy_find_b64_strings_for_every_word_in_diff(
mock_strings.return_value = []
b64_entropy_score = 4.5
hex_entropy_score = 3
list(self.scanner.scan_entropy(self.chunk, b64_entropy_score, hex_entropy_score))
list(
self.scanner.scan_entropy(self.chunk, b64_entropy_score, hex_entropy_score)
)
mock_strings.assert_has_calls(
(
mock.call("foo", scanner.BASE64_CHARS),
Expand All @@ -449,9 +451,9 @@ def test_issues_are_not_created_for_b64_string_excluded_signatures(
mock_signature.return_value = True
b64_entropy_score = 4.5
hex_entropy_score = 3
issues = list(self.scanner.scan_entropy(
self.chunk, b64_entropy_score, hex_entropy_score
))
issues = list(
self.scanner.scan_entropy(self.chunk, b64_entropy_score, hex_entropy_score)
)
mock_calculate.assert_not_called()
self.assertEqual(issues, [])

Expand All @@ -468,9 +470,9 @@ def test_issues_are_not_created_for_hex_string_excluded_signatures(
mock_signature.return_value = True
b64_entropy_score = 4.5
hex_entropy_score = 3
issues = list(self.scanner.scan_entropy(
self.chunk, b64_entropy_score, hex_entropy_score
))
issues = list(
self.scanner.scan_entropy(self.chunk, b64_entropy_score, hex_entropy_score)
)
mock_calculate.assert_not_called()
self.assertEqual(issues, [])

Expand All @@ -488,9 +490,9 @@ def test_issues_are_created_for_high_entropy_b64_strings(
mock_calculate.return_value = 9.0
b64_entropy_score = 4.5
hex_entropy_score = 3
issues = list(self.scanner.scan_entropy(
self.chunk, b64_entropy_score, hex_entropy_score
))
issues = list(
self.scanner.scan_entropy(self.chunk, b64_entropy_score, hex_entropy_score)
)
self.assertEqual(len(issues), 1)
self.assertEqual(issues[0].issue_type, types.IssueType.Entropy)
self.assertEqual(issues[0].matched_string, "foo")
Expand All @@ -509,9 +511,9 @@ def test_issues_are_created_for_high_entropy_hex_strings(
mock_calculate.return_value = 9.0
b64_entropy_score = 4.5
hex_entropy_score = 3
issues = list(self.scanner.scan_entropy(
self.chunk, b64_entropy_score, hex_entropy_score
))
issues = list(
self.scanner.scan_entropy(self.chunk, b64_entropy_score, hex_entropy_score)
)
self.assertEqual(len(issues), 1)
self.assertEqual(issues[0].issue_type, types.IssueType.Entropy)
self.assertEqual(issues[0].matched_string, "foo")
Expand All @@ -533,9 +535,9 @@ def test_issues_are_not_created_for_high_entropy_hex_strings_given_entropy_is_ex
mock_calculate.return_value = 9.0
b64_entropy_score = 4.5
hex_entropy_score = 3
issues = list(self.scanner.scan_entropy(
self.chunk, b64_entropy_score, hex_entropy_score
))
issues = list(
self.scanner.scan_entropy(self.chunk, b64_entropy_score, hex_entropy_score)
)
self.assertEqual(len(issues), 0)

@mock.patch("tartufo.scanner.ScannerBase.calculate_entropy")
Expand All @@ -555,9 +557,9 @@ def test_issues_are_not_created_for_low_entropy_b64_strings_given_entropy_is_exc
mock_calculate.return_value = 9.0
b64_entropy_score = 4.5
hex_entropy_score = 3
issues = list(self.scanner.scan_entropy(
self.chunk, b64_entropy_score, hex_entropy_score
))
issues = list(
self.scanner.scan_entropy(self.chunk, b64_entropy_score, hex_entropy_score)
)
self.assertEqual(len(issues), 0)

@mock.patch("tartufo.scanner.ScannerBase.calculate_entropy")
Expand All @@ -574,9 +576,9 @@ def test_issues_are_not_created_for_low_entropy_b64_strings(
mock_calculate.return_value = 1.0
b64_entropy_score = 4.5
hex_entropy_score = 3
issues = list(self.scanner.scan_entropy(
self.chunk, b64_entropy_score, hex_entropy_score
))
issues = list(
self.scanner.scan_entropy(self.chunk, b64_entropy_score, hex_entropy_score)
)
self.assertEqual(len(issues), 0)

@mock.patch("tartufo.scanner.ScannerBase.calculate_entropy")
Expand All @@ -593,9 +595,9 @@ def test_issues_are_not_created_for_low_entropy_hex_strings(
mock_calculate.return_value = 1.0
b64_entropy_score = 4.5
hex_entropy_score = 3
issues = list(self.scanner.scan_entropy(
self.chunk, b64_entropy_score, hex_entropy_score
))
issues = list(
self.scanner.scan_entropy(self.chunk, b64_entropy_score, hex_entropy_score)
)
self.assertEqual(len(issues), 0)


Expand Down

0 comments on commit 9952ab5

Please sign in to comment.