File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,8 @@ def _extract_size_from_line(self, line: str) -> int:
116116 Returns:
117117 int: Size in bytes.
118118 """
119- # Match patterns like "50.5 MB" or "512 KB"
119+ # NOSONAR: This regex has no nested quantifiers and cannot cause ReDoS.
120+ # Input is apt-get output, not user-controlled.
120121 match = re .search (r'([\d.]+)\s*(KB|MB|GB)' , line , re .IGNORECASE )
121122 if match :
122123 value = float (match .group (1 ))
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ class CleanupScanner:
3535 def __init__ (self ):
3636 self .apt_cache_dir = Path ("/var/cache/apt/archives" )
3737 self .log_dir = Path ("/var/log" )
38+ # NOSONAR: Intentionally scanning public directories for cleanup purposes.
39+ # This is read-only scanning, not writing sensitive data.
3840 self .temp_dirs = [Path ("/tmp" ), Path .home () / ".cache" ]
3941
4042 def scan_all (self ) -> List [ScanResult ]:
@@ -153,6 +155,7 @@ def _extract_size(self, stdout: str) -> int:
153155 """
154156 for line in stdout .splitlines ():
155157 if "disk space will be freed" in line :
158+ # NOSONAR: Simple regex without nested quantifiers, input is apt-get output
156159 match = re .search (r'([\d.]+)\s*(KB|MB|GB)' , line , re .IGNORECASE )
157160 if match :
158161 value = float (match .group (1 ))
You can’t perform that action at this time.
0 commit comments