From 5f923ef40ef705034e49f6e3d5e1186d00ba2040 Mon Sep 17 00:00:00 2001 From: Roman Babenko Date: Wed, 2 Aug 2023 12:44:04 +0300 Subject: [PATCH] rule fix --- credsweeper/filters/value_iban_check.py | 2 +- credsweeper/rules/config.yaml | 2 +- setup.py | 1 + tests/__init__.py | 6 +++--- tests/data/depth_3.json | 22 ++++++++++++++++++++++ tests/data/ml_threshold_0.json | 22 ++++++++++++++++++++++ tests/data/output.json | 22 ++++++++++++++++++++++ 7 files changed, 72 insertions(+), 5 deletions(-) diff --git a/credsweeper/filters/value_iban_check.py b/credsweeper/filters/value_iban_check.py index b863de10b..0deb0db9a 100644 --- a/credsweeper/filters/value_iban_check.py +++ b/credsweeper/filters/value_iban_check.py @@ -1,12 +1,12 @@ import contextlib +from schwifty import IBAN from schwifty.exceptions import SchwiftyException from credsweeper.config import Config from credsweeper.credentials import LineData from credsweeper.file_handler.analysis_target import AnalysisTarget from credsweeper.filters import Filter -from schwifty import IBAN class ValueIbanCheck(Filter): diff --git a/credsweeper/rules/config.yaml b/credsweeper/rules/config.yaml index 4899c1f82..51bfce656 100644 --- a/credsweeper/rules/config.yaml +++ b/credsweeper/rules/config.yaml @@ -13,7 +13,7 @@ severity: info type: pattern values: - - (^|[^.0-9A-Za-z_/+-])(?P[A-Z]{2}[A-Z0-9]{14,32})([^=0-9A-Za-z_/+-]|$) + - (^|[^0-9A-Za-z])(?P[A-Z]{2}[0-9]{2}[A-Z0-9]{12,30})([^=0-9A-Za-z]|$) filter_type: - ValueIbanCheck min_line_len: 16 diff --git a/setup.py b/setup.py index dd0908da8..7bc252242 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ "PyYAML", # "requests", # "scipy", # + "schwifty", # "typing_extensions", # "whatthepatch", # "numpy", # diff --git a/tests/__init__.py b/tests/__init__.py index 3b4fe0b68..301553a6a 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -4,11 +4,11 @@ SAMPLES_FILES_COUNT: int = 107 # credentials count after scan -SAMPLES_CRED_COUNT: int = 103 -SAMPLES_CRED_LINE_COUNT: int = 114 +SAMPLES_CRED_COUNT: int = 104 +SAMPLES_CRED_LINE_COUNT: int = 115 # credentials count after post-processing -SAMPLES_POST_CRED_COUNT: int = 97 +SAMPLES_POST_CRED_COUNT: int = 98 # with option --doc SAMPLES_IN_DOC = 86 diff --git a/tests/data/depth_3.json b/tests/data/depth_3.json index 9eaee2bb9..f28395427 100644 --- a/tests/data/depth_3.json +++ b/tests/data/depth_3.json @@ -1169,6 +1169,28 @@ } ] }, + { + "api_validation": "NOT_AVAILABLE", + "ml_validation": "NOT_AVAILABLE", + "ml_probability": null, + "rule": "IBAN", + "severity": "info", + "line_data_list": [ + { + "line": "\u041f\u0440\u0438\u043a\u043b\u0430\u0434 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e IBAN: https://api.accountants/iban/UA893206490000026007052606100/", + "line_num": 3, + "path": "tests/samples/iban", + "info": "tests/samples/iban|RAW", + "value": "UA893206490000026007052606100", + "variable": null, + "entropy_validation": { + "iterator": "BASE64_CHARS", + "entropy": 2.86575901199594, + "valid": false + } + } + ] + }, { "api_validation": "NOT_AVAILABLE", "ml_validation": "VALIDATED_KEY", diff --git a/tests/data/ml_threshold_0.json b/tests/data/ml_threshold_0.json index 7c609cb6e..c5877d248 100644 --- a/tests/data/ml_threshold_0.json +++ b/tests/data/ml_threshold_0.json @@ -1169,6 +1169,28 @@ } ] }, + { + "api_validation": "NOT_AVAILABLE", + "ml_validation": "NOT_AVAILABLE", + "ml_probability": null, + "rule": "IBAN", + "severity": "info", + "line_data_list": [ + { + "line": "\u041f\u0440\u0438\u043a\u043b\u0430\u0434 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e IBAN: https://api.accountants/iban/UA893206490000026007052606100/", + "line_num": 3, + "path": "tests/samples/iban", + "info": "", + "value": "UA893206490000026007052606100", + "variable": null, + "entropy_validation": { + "iterator": "BASE64_CHARS", + "entropy": 2.86575901199594, + "valid": false + } + } + ] + }, { "api_validation": "NOT_AVAILABLE", "ml_validation": "NOT_AVAILABLE", diff --git a/tests/data/output.json b/tests/data/output.json index 5a6f9750d..70a6588af 100644 --- a/tests/data/output.json +++ b/tests/data/output.json @@ -1103,6 +1103,28 @@ } ] }, + { + "api_validation": "NOT_AVAILABLE", + "ml_validation": "NOT_AVAILABLE", + "ml_probability": null, + "rule": "IBAN", + "severity": "info", + "line_data_list": [ + { + "line": "\u041f\u0440\u0438\u043a\u043b\u0430\u0434 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e IBAN: https://api.accountants/iban/UA893206490000026007052606100/", + "line_num": 3, + "path": "tests/samples/iban", + "info": "", + "value": "UA893206490000026007052606100", + "variable": null, + "entropy_validation": { + "iterator": "BASE64_CHARS", + "entropy": 2.86575901199594, + "valid": false + } + } + ] + }, { "api_validation": "NOT_AVAILABLE", "ml_validation": "VALIDATED_KEY",