Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #336: _issue_file was not defined by default, causing scans to fail #337

Merged
merged 2 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v3.1.1 - 25 March 2022
----------------------

Bug Fixes:

* [#336](https://github.com/godaddy/tartufo/issues/336) - `_issue_file` was not defined by default, causing all scans to fail

v3.1.0 - 24 March 2022
----------------------

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ maintainers = ["GoDaddy <oss@godaddy.com>"]
name = "tartufo"
readme = "README.md"
repository = "https://github.com/godaddy/tartufo/"
version = "3.1.0"
version = "3.1.1"

[tool.poetry.scripts]
tartufo = "tartufo.cli:main"
Expand Down
2 changes: 1 addition & 1 deletion tartufo/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class ScannerBase(abc.ABC): # pylint: disable=too-many-instance-attributes
_excluded_signatures: Optional[Tuple[str, ...]] = None
_config_data: MutableMapping[str, Any] = {}
_issue_list: List[Issue] = []
_issue_file: IO
_issue_file: Optional[IO] = None
_issue_count: int

def __init__(self, options: types.GlobalOptions) -> None:
Expand Down
18 changes: 18 additions & 0 deletions tests/test_base_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ def test_scan_checks_regex_if_specified(self, mock_regex: mock.MagicMock):
mock_regex.assert_called()


class IssueFileTests(ScannerTestCase):
@mock.patch("tempfile.NamedTemporaryFile")
def test_issue_file_creates_new_temporary_file(self, mock_temp: mock.MagicMock):
self.options.temp_dir = "/foo/bar"
test_scanner = TestScanner(self.options)
issue_file = test_scanner.issue_file
mock_temp.assert_called_once_with(dir="/foo/bar")
self.assertEqual(issue_file, mock_temp.return_value)

@mock.patch("tempfile.NamedTemporaryFile", mock.MagicMock())
def test_issue_file_is_cached(self):
self.options.temp_dir = "/foo/bar"
test_scanner = TestScanner(self.options)
file1 = test_scanner.issue_file
file2 = test_scanner.issue_file
self.assertEqual(file1, file2)


class IssuesTests(ScannerTestCase):
@mock.patch("tartufo.scanner.ScannerBase.scan")
def test_empty_issue_list_causes_scan(self, mock_scan: mock.MagicMock):
Expand Down