Skip to content

Commit 6978938

Browse files
Akshit MaheshwaryAkshit Maheshwary
authored andcommitted
fixed deepsource issues
1 parent fd200af commit 6978938

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

api_app/analyzers_manager/file_analyzers/capa_info.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,20 @@ def _download_signatures(cls) -> None:
6767
for signature in signatures_list:
6868
try:
6969
process = subprocess.run(
70-
["wget", "-O", SIGNATURE_LOCATION, signature["download_url"]]
70+
[
71+
"/usr/bin/wget",
72+
"-O",
73+
SIGNATURE_LOCATION,
74+
signature["download_url"],
75+
],
76+
check=True,
7177
)
78+
7279
except subprocess.CalledProcessError as e:
80+
stderr = process.stderr
7381
logger.error(f"Failed to download signature: {e}")
7482
raise AnalyzerRunException(
75-
f"Failed to update signatures due to error: {process.stderr}"
83+
f"Failed to update signatures due to error: {stderr}"
7684
)
7785
logger.info("Successfully updated singatures")
7886

@@ -109,7 +117,7 @@ def run(self):
109117
"Couldn't update capa rules or signatures successfully"
110118
)
111119

112-
command: list[str] = ["capa", "--quiet", "--json"]
120+
command: list[str] = ["/usr/local/bin/capa", "--quiet", "--json"]
113121
shell_code_arch = "sc64" if self.arch == "64" else "sc32"
114122
if self.shellcode:
115123
command.append("-f")
@@ -128,17 +136,21 @@ def run(self):
128136
logger.info(f"Starting CAPA analysis for {self.filename}")
129137

130138
process: subprocess.CompletedProcess = subprocess.run(
131-
command, capture_output=True, text=True, timeout=self.timeout
139+
command,
140+
capture_output=True,
141+
text=True,
142+
timeout=self.timeout,
143+
check=True,
132144
)
133145

134-
process.check_returncode()
135146
result = json.loads(process.stdout)
136147
logger.info("CAPA analysis successfully completed")
137148

138149
except subprocess.CalledProcessError as e:
150+
stderr = process.stderr
139151
logger.info(f"Capa Info failed to run for {self.filename} with command {e}")
140152
raise AnalyzerRunException(
141-
f" Analyzer for {self.filename} failed with error: {process.stderr}"
153+
f" Analyzer for {self.filename} failed with error: {stderr}"
142154
)
143155

144156
return result

api_app/analyzers_manager/file_analyzers/floss.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,26 @@ def run(self):
3838
# retrieve them with more simple tools
3939
try:
4040
process: subprocess.CompletedProcess = subprocess.run(
41-
["floss", "--json", "--no", "static", "--", self.filepath],
41+
[
42+
"/usr/local/bin/floss",
43+
"--json",
44+
"--no",
45+
"static",
46+
"--",
47+
self.filepath,
48+
],
4249
capture_output=True,
4350
text=True,
51+
check=True,
4452
)
4553

46-
process.check_returncode()
47-
4854
result = loads(process.stdout)
4955

5056
except subprocess.CalledProcessError as e:
57+
stderr = process.stderr
5158
logger.info(f"Floss failed to run for {self.filename} with command {e}")
5259
raise AnalyzerRunException(
53-
f" Analyzer for {self.filename} failed with error: {process.stderr}"
60+
f" Analyzer for {self.filename} failed with error: {stderr}"
5461
)
5562

5663
result["exceeded_max_number_of_strings"] = {}

0 commit comments

Comments
 (0)