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

fix(sast): fix sast cdk code location paths #5938

Merged
merged 1 commit into from
Jan 14, 2024
Merged
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
6 changes: 6 additions & 0 deletions checkov/common/bridgecrew/platform_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,18 @@ def adjust_sast_match_location_path(self, match: Match) -> None:
for dir in self.scan_dir:
if match.location.path.startswith(os.path.abspath(dir)):
match.location.path = match.location.path.replace(os.path.abspath(dir), self.repo_path) # type: ignore
if match.metadata.code_locations:
for code_location in match.metadata.code_locations:
code_location.path = code_location.path.replace(os.path.abspath(dir), self.repo_path) # type: ignore
return

for file in self.scan_file:
if match.location.path == os.path.abspath(file):
file_dir = '/'.join(match.location.path.split('/')[0:-1])
match.location.path = match.location.path.replace(os.path.abspath(file_dir), self.repo_path) # type: ignore
if match.metadata.code_locations:
for code_location in match.metadata.code_locations:
code_location.path = code_location.path.replace(os.path.abspath(file_dir), self.repo_path) # type: ignore
return

@staticmethod
Expand Down
Loading