3535 USER_OUTPUT_DIR ,
3636 MissingFile ,
3737 NonZeroExit ,
38+ render_command ,
3839 run_command ,
3940)
4041
@@ -52,7 +53,7 @@ class SAST(ABC):
5253 supported_datasets (list[Dataset]): A list of supported dataset classes.
5354 properties (SASTProperties): The properties of the SAST tool.
5455 requirements (SASTRequirements): The requirements for the SAST tool.
55- commands (list[list[Union[str, tuple[str]]]]): The list of commands templates to be rendred and executed.
56+ commands (list[list[Union[str, tuple[str]]]]): The list of commands templates to be rendered and executed.
5657 valid_codes (list[int]): A list of exit codes indicating that the command did not fail.
5758 environ (dict[str, str]): Environment variables to set for commands.
5859 output_files (list[tuple[Path, bool]]): Expected output files and
@@ -89,46 +90,15 @@ def __init__(self) -> None:
8990 Set up supported datasets, the output directory, and requirement status.
9091 """
9192 self .supported_datasets = [
92- DATASETS_ALL [d ] for d in self .supported_dataset_names
93+ DATASETS_ALL [d ]
94+ for d in self .supported_dataset_names
95+ if DATASETS_ALL [d ].is_cached ()
9396 ]
9497 self .output_dir = USER_OUTPUT_DIR / self .name
9598 self .requirements .name = self .name
9699 self .status = self .requirements .get_status ()
97100 self .missing = self .requirements .get_missing ()
98101
99- def render_command (self , command : list [str ], map : dict [str , str ]) -> list [str ]:
100- """Render a command template by replacing placeholders with values.
101-
102- Args:
103- command: The command template as a list of strings.
104- map: A dictionary of placeholders to their replacement values.
105-
106- Returns:
107- The rendered command as a list of strings.
108-
109- """
110- _command = command .copy ()
111- for pattern , value in map .items ():
112- for i , arg in enumerate (_command ):
113- # Check if optional argument can be used
114- if isinstance (arg , tuple ):
115- default_arg , optional_arg = arg
116- if pattern in optional_arg :
117- _command [i ] = arg .replace (pattern , value )
118- else :
119- _command [i ] = default_arg
120- else :
121- if pattern in arg :
122- _command [i ] = arg .replace (pattern , value )
123-
124- # Remove not rendered part of the command:
125- __command = []
126- for part in _command :
127- if not ("{" in part and "}" in part ):
128- __command .append (part )
129-
130- return __command
131-
132102 def run_analysis (
133103 self , lang : str , project_dir : Path , output_dir : Path , ** kwargs : Any
134104 ) -> None :
@@ -165,7 +135,7 @@ def run_analysis(
165135 command_output = ""
166136 start = time .time ()
167137 for command in self .commands :
168- rendered_command = self . render_command (command , render_variables )
138+ rendered_command = render_command (command , render_variables )
169139 retcode , out = run_command (rendered_command , project_dir , self .environ )
170140 command_output += out
171141 if retcode not in self .valid_codes :
0 commit comments