diff --git a/tools/devsecops_engine_tools/engine_sca/engine_dependencies/src/infrastructure/driven_adapters/xray_tool/xray_manager_scan.py b/tools/devsecops_engine_tools/engine_sca/engine_dependencies/src/infrastructure/driven_adapters/xray_tool/xray_manager_scan.py index d34e494d..9c2fee30 100644 --- a/tools/devsecops_engine_tools/engine_sca/engine_dependencies/src/infrastructure/driven_adapters/xray_tool/xray_manager_scan.py +++ b/tools/devsecops_engine_tools/engine_sca/engine_dependencies/src/infrastructure/driven_adapters/xray_tool/xray_manager_scan.py @@ -212,12 +212,18 @@ def scan_dependencies(self, prefix, cwd, mode, to_scan): scan_result = json.loads(result.stdout) else: scan_result = {} - file_result = os.path.join(os.getcwd(), "scan_result.json") - with open(file_result, "w") as file: - json.dump(scan_result, file, indent=4) + if any( + word in result.stderr + for word in ["What went wrong", "Caused by"] + ): + logger.error(f"Error executing Xray scan: {result.stderr}") + return None if result.stdout == "null\n": logger.warning(f"Xray scan returned null: {result.stderr}") return None + file_result = os.path.join(os.getcwd(), "scan_result.json") + with open(file_result, "w") as file: + json.dump(scan_result, file, indent=4) return file_result else: logger.error(f"Error executing Xray scan: {result.stderr}")