Skip to content

Commit 6b00b61

Browse files
committed
fix a file link for SAST; use CWE without text in card details
1 parent 8149d13 commit 6b00b61

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

cycode/cli/printers/utils/detection_data.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,21 @@ def get_cwe_cve_link(cwe_cve: Optional[str]) -> Optional[str]:
3535
return None
3636

3737

38+
def clear_cwe_name(cwe: str) -> str:
39+
"""Clear CWE.
40+
41+
Intput: CWE-532: Insertion of Sensitive Information into Log File
42+
Output: CWE-532
43+
"""
44+
if cwe.startswith('CWE'):
45+
return cwe.split(':')[0]
46+
47+
return cwe
48+
49+
3850
def get_detection_clickable_cwe_cve(scan_type: str, detection: 'Detection') -> str:
3951
def link(url: str, name: str) -> str:
40-
return f'[link={url}]{name}[/]'
52+
return f'[link={url}]{clear_cwe_name(name)}[/]'
4153

4254
if scan_type == consts.SCA_SCAN_TYPE:
4355
cve = detection.detection_details.get('vulnerability_id')
@@ -84,5 +96,13 @@ def get_detection_file_path(scan_type: str, detection: 'Detection') -> Path:
8496
folder_path = detection.detection_details.get('file_path', '')
8597
file_name = detection.detection_details.get('file_name', '')
8698
return Path.joinpath(Path(folder_path), Path(file_name))
99+
if scan_type == consts.SAST_SCAN_TYPE:
100+
file_path = detection.detection_details.get('file_path', '')
101+
102+
# fix the absolute path...BE returns string which does not start with /
103+
if not file_path.startswith('/'):
104+
file_path = f'/{file_path}'
105+
106+
return Path(file_path)
87107

88108
return Path(detection.detection_details.get('file_name', ''))

0 commit comments

Comments
 (0)