From 9927a8edff851e146e374eabcf6bf7f29d7758b0 Mon Sep 17 00:00:00 2001 From: ess3nce Date: Tue, 9 Jul 2024 23:31:46 +0800 Subject: [PATCH] Fix pattern_matcher.py logic problem --- libsast/core_matcher/pattern_matcher.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libsast/core_matcher/pattern_matcher.py b/libsast/core_matcher/pattern_matcher.py index 05b79e8..0b86e55 100644 --- a/libsast/core_matcher/pattern_matcher.py +++ b/libsast/core_matcher/pattern_matcher.py @@ -81,18 +81,18 @@ def pattern_matcher(self, file_path): results = [] try: data = file_path.read_text('utf-8', 'ignore') + if file_path.suffix.lower() in ('.html', '.xml'): + tmp_data = strip_comments2(data) + else: + tmp_data = strip_comments(data) for rule in self.scan_rules: case = rule.get('input_case') if case == 'lower': - tmp_data = data.lower() + fmt_data = tmp_data.lower() elif case == 'upper': - tmp_data = data.upper() + fmt_data = tmp_data.upper() else: - tmp_data = data - if file_path.suffix.lower() in ('.html', '.xml'): - fmt_data = strip_comments2(tmp_data) - else: - fmt_data = strip_comments(tmp_data) + fmt_data = tmp_data matches = self.matcher._find_match( rule['type'], fmt_data,