openapi runner hangs the scan on an unreadable file (PermissionError uncaught in parse_format)
Describe the issue
The openapi framework runner hangs the entire scan when it encounters an unreadable .json/.yaml/.yml file in the scan path (e.g. a file owned by a different uid in a CI checkout). Instead of skipping the file, the uncaught PermissionError propagates through the parallel object-runner and the scan never completes — in a CI job it runs until an external timeout kills the process.
Root cause
checkov/openapi/runner.py::parse_format wraps load_file in a try/except that catches only ValueError:
@staticmethod
def parse_format(f, func):
try:
content = Runner.load_file(f) # read_file_with_any_encoding(f)
valid = Runner.pre_validate_file(content)
...
except ValueError: # PermissionError / OSError NOT caught
return Falseload_file -> read_file_with_any_encoding performs open(f), which raises PermissionError (an OSError, not a ValueError) on an unreadable file. That exception is not caught here. It propagates through
checkov/common/runners/object_runner.py::_load_files:
results = parallel_runner.run_function(lambda f: (f, self._parse_file(f)), files_to_load)whose own comment notes it only expects "an uncaught exception occurs". The parallel worker handling of that uncaught exception does not fail-fast/skip; the run stalls.
To Reproduce
mkdir /tmp/repro && cd /tmp/repro
printf '{"scan":"report","findings":[]}' > report.json
chmod 000 report.json # or chown to a different uid (the CI case)
checkov -d . --framework all -o jsonObserved error chain:
[ERROR] Permission denied when accessing template file: .../report.json
[ERROR] Failed to invoke function ... object_runner.<lambda> with .../report.json
File ".../checkov/openapi/runner.py", line 41, in _parse_file
File ".../checkov/openapi/runner.py", line 51, in parse_format
File ".../checkov/openapi/runner.py", line 103, in load_file
PermissionError: [Errno 13] Permission denied: '.../report.json'Expected behavior
An unreadable file in the scan path should be logged and skipped, and the scan should continue and complete. A single unreadable file must not stall a --framework all run.
Suggested fix
Broaden the except in parse_format (and/or in load_file's caller) to also catch OSError, returning None/False so the file is skipped:
except (ValueError, OSError):
return NoneVersion
- checkov 3.3.19 (reproduced); Python 3.12 and 3.14.
- Encountered via ASH v3.7.1 running
checkov --framework allin a GitLab CI container, where a report artifact from an earlier job (owned by a different uid) sat in the scan directory.
Source: bridgecrewio/checkov