99class GrypeScanner :
1010 """Scanner implementation for Grype."""
1111
12+ BASE_TEMPLATE_PATH = os .getenv ("GITHUB_ACTION_PATH" , os .getcwd ())
1213 # Map format types to appropriate file extensions
1314 TEMPLATES_PATH = {
14- "csv" : "src/config/templates/csv.tmpl" ,
15- "html" : "src/config/templates/html.tmpl" ,
16- "junit" : "src/config/templates/junit.tmpl" ,
17- "table" : "src/config/templates/table.tmpl" ,
15+ "csv" : os . path . join ( BASE_TEMPLATE_PATH , "src/config/templates/csv.tmpl" ) ,
16+ "html" : os . path . join ( BASE_TEMPLATE_PATH , "src/config/templates/html.tmpl" ) ,
17+ "junit" : os . path . join ( BASE_TEMPLATE_PATH , "src/config/templates/junit.tmpl" ) ,
18+ "table" : os . path . join ( BASE_TEMPLATE_PATH , "src/config/templates/table.tmpl" ) ,
1819 }
1920
2021 def configure_grype (self ):
@@ -26,6 +27,10 @@ def configure_grype(self):
2627 os .environ ["GRYPE_LOG_LEVEL" ] = "info"
2728 os .environ ["GRYPE_PRETTY" ] = "true"
2829
30+ logging .info ("Base template path: %s" , self .BASE_TEMPLATE_PATH )
31+ for fmt , path in self .TEMPLATES_PATH .items ():
32+ logging .info ("Template for %s: %s" , fmt , path )
33+
2934 def determine_output_file ( # pylint: disable=too-many-arguments, too-many-positional-arguments, too-many-return-statements
3035 self , target , scanner_args , inputs , output_dir , file_extension
3136 ):
@@ -177,6 +182,13 @@ def _run_scan(self, target, report_format, output_file, scanner_args):
177182 # Handle template formats
178183 if report_format in self .TEMPLATES_PATH :
179184 template_path = self .TEMPLATES_PATH [report_format ]
185+ if not os .path .exists (template_path ):
186+ logging .error ("Template file not found: %s" , template_path )
187+ return {
188+ "format" : report_format ,
189+ "success" : False ,
190+ "error" : f"Template file not found: { template_path } " ,
191+ }
180192 cmd .extend (["--template" , template_path ])
181193 cmd .extend (["-o" , "template" ])
182194 cmd .extend (["--file" , output_file ])
0 commit comments