Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sca): Add root path references to shorten file paths in Image Referencer results #3609

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion checkov/common/images/image_referencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def add_image_records(
file_path=dockerfile_path,
file_content=f'image: {image.name}',
docker_image_name=image.name,
related_resource_id=image.related_resource_id)
related_resource_id=image.related_resource_id,
root_folder=root_path)
report.image_cached_results.append(image_scanning_report)

result = cached_results.get("results", [{}])[0]
Expand Down
3 changes: 3 additions & 0 deletions checkov/sca_image/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ def run(
return report
if files:
self.pbar.initiate(len(files))
# 'root_folder' should contain the common prefix so the absolute full path can be shortened later
root_folder = os.path.split(os.path.commonprefix(files))[0]

for file in files:
self.pbar.set_additional_data({'Current File Scanned': os.path.relpath(file, root_folder)})
self.iterate_image_files(file, report, runner_filter)
Expand Down