From d7e44c76e10a71f92046cb08eeb1aa5433adec00 Mon Sep 17 00:00:00 2001 From: Roman Babenko Date: Tue, 15 Nov 2022 23:32:10 +0200 Subject: [PATCH] Version up to 1.4.5 (#243) * Version up to 1.4.5 and template fix * Update whatthepath requirement version to avoid huge diffs check. * Added test for huge patches parsing --- .github/pull-request-template.md | 2 +- credsweeper/__init__.py | 2 +- requirements.txt | 2 +- tests/test_app.py | 26 ++++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/pull-request-template.md b/.github/pull-request-template.md index 38d7691fb..9652b32f5 100644 --- a/.github/pull-request-template.md +++ b/.github/pull-request-template.md @@ -1,6 +1,6 @@ ## Description -Please include a summary of the change and which is is fixed. +Please include a summary of the change and which is fixed. - Add A - Fix B diff --git a/credsweeper/__init__.py b/credsweeper/__init__.py index 29974e194..fdf863094 100644 --- a/credsweeper/__init__.py +++ b/credsweeper/__init__.py @@ -25,4 +25,4 @@ CREDSWEEPER_DIR = Path(__file__).resolve().parent -__version__ = "1.4.4" +__version__ = "1.4.5" diff --git a/requirements.txt b/requirements.txt index 02df2c59d..ca66fab8e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ PyYAML~=6.0 regex~=2022.8.17 requests~=2.28.0 typing_extensions~=4.2.0 -whatthepatch~=1.0.2 +whatthepatch~=1.0.3 # ML requirements numpy<=1.23.0 diff --git a/tests/test_app.py b/tests/test_app.py index 770067189..d0d3a2254 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -52,6 +52,32 @@ def test_it_works_p(self) -> None: # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + def test_huge_diff_p(self) -> None: + # verifies issue when huge patch is parsed very slow + # https://github.com/Samsung/CredSweeper/issues/242 + text = """diff --git a/huge.file b/huge.file + index 0000000..1111111 100644 + --- a/huge.file + +++ a/huge.file + @@ -3,13 +3,1000007 @@ + 00000000 + 11111111 + 22222222 + -33333333 + -44444444 + +55555555 + +66666666 + """ + for n in range(0, 1000000): + text += "+" + hex(n) + "\n" + with tempfile.TemporaryDirectory() as tmp_dir: + target_path = os.path.join(tmp_dir, f"{__name__}.diff") + start_time = time.time() + _stdout, _stderr = self._m_credsweeper(["--path", target_path, "--ml_threshold", "0", "--log", "silence"]) + self.assertGreater(100, time.time() - start_time) + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + def test_it_works_without_ml_p(self) -> None: target_path = str(SAMPLES_DIR / "password") _stdout, _stderr = self._m_credsweeper(["--path", target_path, "--ml_threshold", "0", "--log", "silence"])