libsast 3.1.1__tar.gz → 3.1.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.
Files changed (23) hide show
  1. {libsast-3.1.1 → libsast-3.1.2}/PKG-INFO +2 -1
  2. {libsast-3.1.1 → libsast-3.1.2}/libsast/__init__.py +1 -1
  3. {libsast-3.1.1 → libsast-3.1.2}/libsast/core_matcher/choice_matcher.py +15 -9
  4. {libsast-3.1.1 → libsast-3.1.2}/libsast/core_matcher/pattern_matcher.py +18 -8
  5. {libsast-3.1.1 → libsast-3.1.2}/libsast/scanner.py +1 -0
  6. {libsast-3.1.1 → libsast-3.1.2}/pyproject.toml +2 -1
  7. {libsast-3.1.1 → libsast-3.1.2}/LICENSE +0 -0
  8. {libsast-3.1.1 → libsast-3.1.2}/README.md +0 -0
  9. {libsast-3.1.1 → libsast-3.1.2}/libsast/__main__.py +0 -0
  10. {libsast-3.1.1 → libsast-3.1.2}/libsast/common.py +0 -0
  11. {libsast-3.1.1 → libsast-3.1.2}/libsast/core_matcher/__init__.py +0 -0
  12. {libsast-3.1.1 → libsast-3.1.2}/libsast/core_matcher/helpers.py +0 -0
  13. {libsast-3.1.1 → libsast-3.1.2}/libsast/core_matcher/matchers.py +0 -0
  14. {libsast-3.1.1 → libsast-3.1.2}/libsast/core_sgrep/__init__.py +0 -0
  15. {libsast-3.1.1 → libsast-3.1.2}/libsast/core_sgrep/helpers.py +0 -0
  16. {libsast-3.1.1 → libsast-3.1.2}/libsast/core_sgrep/semantic_sgrep.py +0 -0
  17. {libsast-3.1.1 → libsast-3.1.2}/libsast/exceptions.py +0 -0
  18. {libsast-3.1.1 → libsast-3.1.2}/libsast/standards/cwe.yaml +0 -0
  19. {libsast-3.1.1 → libsast-3.1.2}/libsast/standards/owasp_masvs.yaml +0 -0
  20. {libsast-3.1.1 → libsast-3.1.2}/libsast/standards/owasp_mobile_top10_2016.yaml +0 -0
  21. {libsast-3.1.1 → libsast-3.1.2}/libsast/standards/owasp_mobile_top10_2024.yaml +0 -0
  22. {libsast-3.1.1 → libsast-3.1.2}/libsast/standards/owasp_web_top10_2017.yaml +0 -0
  23. {libsast-3.1.1 → libsast-3.1.2}/libsast/standards.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libsast
3
- Version: 3.1.1
3
+ Version: 3.1.2
4
4
  Summary: A generic SAST library built on top of semgrep and regex
5
5
  Home-page: https://github.com/ajinabraham/libsast
6
6
  License: LGPL-3.0-or-later
@@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3.13
21
21
  Classifier: Topic :: Security
22
22
  Classifier: Topic :: Software Development :: Quality Assurance
23
+ Requires-Dist: billiard (>=4.2.1,<5.0.0)
23
24
  Requires-Dist: pyyaml (>=6.0)
24
25
  Requires-Dist: requests
25
26
  Requires-Dist: semgrep (==1.86.0) ; sys_platform != "win32"
@@ -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.1.1'
15
+ __version__ = '3.1.2'
16
16
  __version_info__ = tuple(int(i) for i in __version__.split('.'))
17
17
  __all__ = [
18
18
  'Scanner',
@@ -24,6 +24,7 @@ class ChoiceMatcher:
24
24
  self.scan_rules = get_rules(options.get('choice_rules'))
25
25
  self.show_progress = options.get('show_progress')
26
26
  self.cpu = options.get('cpu_core')
27
+ self.queue = options.get('queue')
27
28
  self.alternative_path = options.get('alternative_path')
28
29
  exts = options.get('choice_extensions')
29
30
  self.exts = [ext.lower() for ext in exts] if exts else []
@@ -65,15 +66,20 @@ class ChoiceMatcher:
65
66
 
66
67
  def regex_scan(self, file_contents) -> list:
67
68
  """Process regex matches on the file contents."""
68
- # Use ProcessPoolExecutor for regex processing
69
- with ProcessPoolExecutor(max_workers=self.cpu) as cpu_executor:
70
-
71
- results = []
72
- for content in file_contents:
73
- # Process Choice Matcher on the file contents
74
- process_future = cpu_executor.submit(
75
- self.choice_matcher, content)
76
- results.append(process_future.result())
69
+ if self.queue:
70
+ # Use billiard's pool for regex (support queues)
71
+ from billiard import Pool
72
+ with Pool(processes=self.cpu) as pool:
73
+ # Run regex on file data
74
+ results = pool.map(
75
+ self.choice_matcher,
76
+ file_contents)
77
+ else:
78
+ # Use ProcessPoolExecutor for regex processing
79
+ with ProcessPoolExecutor(max_workers=self.cpu) as cpu_executor:
80
+ results = list(cpu_executor.map(
81
+ self.choice_matcher,
82
+ file_contents))
77
83
 
78
84
  self.add_finding(results)
79
85
  return self.findings
@@ -25,6 +25,7 @@ class PatternMatcher:
25
25
  self.scan_rules = get_rules(options.get('match_rules'))
26
26
  self.show_progress = options.get('show_progress')
27
27
  self.cpu = options.get('cpu_core')
28
+ self.queue = options.get('queue')
28
29
  exts = options.get('match_extensions')
29
30
  self.exts = [ext.lower() for ext in exts] if exts else []
30
31
  self.findings = {}
@@ -62,14 +63,23 @@ class PatternMatcher:
62
63
 
63
64
  def regex_scan(self, file_contents: list) -> dict:
64
65
  """Scan file(s) content."""
65
- # Use a ProcessPool for CPU-bound regex
66
- with ProcessPoolExecutor(max_workers=self.cpu) as cpu_executor:
67
-
68
- # Run regex on file data
69
- results = cpu_executor.map(
70
- self.pattern_matcher,
71
- file_contents,
72
- )
66
+ if self.queue:
67
+ # Use billiard's pool for CPU-bound regex (support queues)
68
+ from billiard import Pool
69
+ with Pool(processes=self.cpu) as cpu_executor:
70
+ # Run regex on file data
71
+ results = cpu_executor.map(
72
+ self.pattern_matcher,
73
+ file_contents,
74
+ )
75
+ else:
76
+ # Use a ProcessPool for CPU-bound regex
77
+ with ProcessPoolExecutor(max_workers=self.cpu) as cpu_executor:
78
+ # Run regex on file data
79
+ results = cpu_executor.map(
80
+ self.pattern_matcher,
81
+ file_contents,
82
+ )
73
83
 
74
84
  # Compile findings
75
85
  self.add_finding(results)
@@ -26,6 +26,7 @@ class Scanner:
26
26
  'ignore_paths': [],
27
27
  'show_progress': False,
28
28
  'cpu_core': 1,
29
+ 'queue': False,
29
30
  # Overwrite with options from invocation
30
31
  **(options or {}),
31
32
  }
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "libsast"
3
- version = "3.1.1"
3
+ version = "3.1.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>"]
@@ -27,6 +27,7 @@ python = "^3.8"
27
27
  requests = "*"
28
28
  pyyaml = ">=6.0"
29
29
  semgrep = {version = "1.86.0", markers = "sys_platform != 'win32'"}
30
+ billiard = "^4.2.1"
30
31
 
31
32
  [tool.poetry.group.dev.dependencies]
32
33
  bandit = "*"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes