libsast 3.0.1__tar.gz → 3.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {libsast-3.0.1 → libsast-3.0.2}/PKG-INFO +1 -1
- {libsast-3.0.1 → libsast-3.0.2}/libsast/__init__.py +1 -1
- {libsast-3.0.1 → libsast-3.0.2}/libsast/core_matcher/matchers.py +26 -2
- {libsast-3.0.1 → libsast-3.0.2}/libsast/core_matcher/pattern_matcher.py +0 -5
- {libsast-3.0.1 → libsast-3.0.2}/pyproject.toml +1 -1
- {libsast-3.0.1 → libsast-3.0.2}/LICENSE +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/README.md +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/__main__.py +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/common.py +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/core_matcher/__init__.py +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/core_matcher/choice_matcher.py +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/core_matcher/helpers.py +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/core_sgrep/__init__.py +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/core_sgrep/helpers.py +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/core_sgrep/semantic_sgrep.py +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/exceptions.py +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/scanner.py +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/standards/cwe.yaml +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/standards/owasp_masvs.yaml +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/standards/owasp_mobile_top10_2016.yaml +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/standards/owasp_mobile_top10_2024.yaml +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/standards/owasp_web_top10_2017.yaml +0 -0
- {libsast-3.0.1 → libsast-3.0.2}/libsast/standards.py +0 -0
|
@@ -12,7 +12,7 @@ year = str(datetime.now().year)
|
|
|
12
12
|
__title__ = 'libsast'
|
|
13
13
|
__authors__ = 'Ajin Abraham'
|
|
14
14
|
__copyright__ = f'Copyright {year} Ajin Abraham, opensecurity.in'
|
|
15
|
-
__version__ = '3.0.
|
|
15
|
+
__version__ = '3.0.2'
|
|
16
16
|
__version_info__ = tuple(int(i) for i in __version__.split('.'))
|
|
17
17
|
__all__ = [
|
|
18
18
|
'Scanner',
|
|
@@ -14,7 +14,7 @@ def get_pos(match):
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
# Cache compiled regex patterns
|
|
17
|
-
@lru_cache(maxsize=
|
|
17
|
+
@lru_cache(maxsize=256)
|
|
18
18
|
def get_compiled_pattern(pattern):
|
|
19
19
|
"""Compile and cache regex patterns."""
|
|
20
20
|
return re.compile(pattern)
|
|
@@ -23,12 +23,36 @@ def get_compiled_pattern(pattern):
|
|
|
23
23
|
class MatchCommand:
|
|
24
24
|
def __init__(self):
|
|
25
25
|
self.patterns = {}
|
|
26
|
+
# Dictionary to map pattern names to their corresponding classes
|
|
27
|
+
self.available_patterns = {
|
|
28
|
+
'Regex': Regex,
|
|
29
|
+
'RegexAnd': RegexAnd,
|
|
30
|
+
'RegexOr': RegexOr,
|
|
31
|
+
'RegexAndNot': RegexAndNot,
|
|
32
|
+
'RegexAndOr': RegexAndOr,
|
|
33
|
+
}
|
|
26
34
|
|
|
27
35
|
def _find_match(self, pattern_name, content, rule):
|
|
28
|
-
pattern_class = self.patterns.get(
|
|
36
|
+
pattern_class = self.patterns.get(
|
|
37
|
+
pattern_name) or self._get_pattern_class(pattern_name)
|
|
29
38
|
self.patterns.setdefault(pattern_name, pattern_class)
|
|
39
|
+
|
|
40
|
+
# Apply case transformation if specified in the rule
|
|
41
|
+
case = rule.get('input_case')
|
|
42
|
+
if case == 'lower':
|
|
43
|
+
content = content.lower()
|
|
44
|
+
elif case == 'upper':
|
|
45
|
+
content = content.upper()
|
|
46
|
+
|
|
47
|
+
# Perform search
|
|
30
48
|
return pattern_class._perform_search(content, rule)
|
|
31
49
|
|
|
50
|
+
def _get_pattern_class(self, pattern_name):
|
|
51
|
+
"""Get pattern class from the available patterns dictionary."""
|
|
52
|
+
if pattern_name in self.available_patterns:
|
|
53
|
+
return self.available_patterns[pattern_name]()
|
|
54
|
+
raise ValueError(f"Pattern '{pattern_name}' is not recognized.")
|
|
55
|
+
|
|
32
56
|
|
|
33
57
|
class MatchStrategy(ABC):
|
|
34
58
|
@abstractmethod
|
|
@@ -103,11 +103,6 @@ class PatternMatcher:
|
|
|
103
103
|
try:
|
|
104
104
|
fmt_data = self._format_content(data, file_path.suffix.lower())
|
|
105
105
|
for rule in self.scan_rules:
|
|
106
|
-
case = rule.get('input_case')
|
|
107
|
-
if case == 'lower':
|
|
108
|
-
fmt_data = fmt_data.lower()
|
|
109
|
-
elif case == 'upper':
|
|
110
|
-
fmt_data = fmt_data.upper()
|
|
111
106
|
matches = self.matcher._find_match(rule['type'], fmt_data, rule)
|
|
112
107
|
if matches:
|
|
113
108
|
results.append({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "libsast"
|
|
3
|
-
version = "3.0.
|
|
3
|
+
version = "3.0.2"
|
|
4
4
|
description = "A generic SAST library built on top of semgrep and regex"
|
|
5
5
|
keywords = ["libsast", "SAST", "Python SAST", "SAST API", "Regex SAST", "Pattern Matcher"]
|
|
6
6
|
authors = ["Ajin Abraham <ajin@opensecurity.in>"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|