Skip to content

Commit d1c5b5c

Browse files
committed
fix: cwe_checker: handle docker timeouts
otherwise they appear as plugin exception
1 parent ef04e68 commit d1c5b5c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/plugins/analysis/cwe_checker/code/cwe_checker.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from docker.types import Mount
2323
from pydantic import BaseModel
24+
from requests import RequestException
2425
from semver import Version
2526

2627
import config
@@ -61,7 +62,7 @@ def __init__(self):
6162
'application/x-pie-executable',
6263
'application/x-sharedlib',
6364
],
64-
version=Version(1, 0, 0),
65+
version=Version(1, 0, 1),
6566
Schema=self.Schema,
6667
)
6768
)
@@ -129,13 +130,16 @@ def _is_supported_arch(file_type_analysis: BaseModel) -> bool:
129130
return any(supported_arch in arch_type for supported_arch in SUPPORTED_ARCHS)
130131

131132
def _do_full_analysis(self, file_path: str) -> dict:
132-
output = self._run_cwe_checker_in_docker(file_path)
133+
try:
134+
output = self._run_cwe_checker_in_docker(file_path)
135+
except RequestException as e:
136+
raise AnalysisFailedError('No response from cwe_checker Docker container (possible timeout)') from e
133137
if output is None:
134-
raise AnalysisFailedError('Timeout or error during cwe_checker execution')
138+
raise AnalysisFailedError('cwe_checker output is missing (timeout or error during execution)')
135139
try:
136140
return self._parse_cwe_checker_output(output)
137141
except json.JSONDecodeError as error:
138-
raise AnalysisFailedError('cwe_checker execution failed') from error
142+
raise AnalysisFailedError('cwe_checker execution failed: Could not parse output') from error
139143

140144
def analyze(self, file_handle: FileIO, virtual_file_path: dict, analyses: dict[str, BaseModel]) -> Schema:
141145
"""

0 commit comments

Comments
 (0)