Skip to content

Commit 1ff8d9c

Browse files
committed
feat(sasts): provide temporary directory for analysis tools
1 parent e9c20c2 commit 1ff8d9c

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

codesectools/sasts/core/sast/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import random
1111
import shutil
12+
import tempfile
1213
import time
1314
from abc import ABC
1415
from pathlib import Path
@@ -121,9 +122,15 @@ def run_analysis(
121122
render_variables[to_replace] = v
122123
elif isinstance(v, Path):
123124
render_variables[to_replace] = str(v.resolve())
125+
elif isinstance(v, list):
126+
render_variables[to_replace] = v
124127
else:
125128
raise NotImplementedError(k, v)
126129

130+
# Make temporary directory available to command
131+
temp_dir = tempfile.TemporaryDirectory()
132+
render_variables["{tempdir}"] = temp_dir.name
133+
127134
with Progress() as progress:
128135
progress.add_task(
129136
f"[b][{self.name}][/b] analyzing: [i]{project_dir.name}[/i]",

codesectools/sasts/tools/Cppcheck/sast.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class CppcheckSAST(PrebuiltBuildlessSAST):
5050
"--enable=all",
5151
"--xml",
5252
"--output-file=cppcheck_output.xml",
53+
"--cppcheck-build-dir={tempdir}",
5354
]
5455
]
5556
valid_codes = [0]

0 commit comments

Comments
 (0)