|
9 | 9 | from cycode.cli.apps.scan.scan_parameters import get_scan_parameters |
10 | 10 | from cycode.cli.apps.scan.scan_result import ( |
11 | 11 | create_local_scan_result, |
| 12 | + enrich_scan_result_with_data_from_detection_rules, |
12 | 13 | get_scan_result, |
13 | 14 | get_sync_scan_result, |
14 | 15 | print_local_scan_results, |
@@ -77,37 +78,6 @@ def _should_use_sync_flow(command_scan_type: str, scan_type: str, sync_option: b |
77 | 78 | return True |
78 | 79 |
|
79 | 80 |
|
80 | | -def _enrich_scan_result_with_data_from_detection_rules( |
81 | | - cycode_client: 'ScanClient', scan_result: ZippedFileScanResult |
82 | | -) -> None: |
83 | | - detection_rule_ids = set() |
84 | | - for detections_per_file in scan_result.detections_per_file: |
85 | | - for detection in detections_per_file.detections: |
86 | | - detection_rule_ids.add(detection.detection_rule_id) |
87 | | - |
88 | | - detection_rules = cycode_client.get_detection_rules(detection_rule_ids) |
89 | | - detection_rules_by_id = {detection_rule.detection_rule_id: detection_rule for detection_rule in detection_rules} |
90 | | - |
91 | | - for detections_per_file in scan_result.detections_per_file: |
92 | | - for detection in detections_per_file.detections: |
93 | | - detection_rule = detection_rules_by_id.get(detection.detection_rule_id) |
94 | | - if not detection_rule: |
95 | | - # we want to make sure that BE returned it. better to not map data instead of failed scan |
96 | | - continue |
97 | | - |
98 | | - if not detection.severity and detection_rule.classification_data: |
99 | | - # it's fine to take the first one, because: |
100 | | - # - for "secrets" and "iac" there is only one classification rule per-detection rule |
101 | | - # - for "sca" and "sast" we get severity from detection service |
102 | | - detection.severity = detection_rule.classification_data[0].severity |
103 | | - |
104 | | - # detection_details never was typed properly. so not a problem for now |
105 | | - detection.detection_details['custom_remediation_guidelines'] = detection_rule.custom_remediation_guidelines |
106 | | - detection.detection_details['remediation_guidelines'] = detection_rule.remediation_guidelines |
107 | | - detection.detection_details['description'] = detection_rule.description |
108 | | - detection.detection_details['policy_display_name'] = detection_rule.display_name |
109 | | - |
110 | | - |
111 | 81 | def _get_scan_documents_thread_func( |
112 | 82 | ctx: typer.Context, is_git_diff: bool, is_commit_range: bool, scan_parameters: dict |
113 | 83 | ) -> Callable[[list[Document]], tuple[str, CliError, LocalScanResult]]: |
@@ -140,7 +110,7 @@ def _scan_batch_thread_func(batch: list[Document]) -> tuple[str, CliError, Local |
140 | 110 | should_use_sync_flow, |
141 | 111 | ) |
142 | 112 |
|
143 | | - _enrich_scan_result_with_data_from_detection_rules(cycode_client, scan_result) |
| 113 | + enrich_scan_result_with_data_from_detection_rules(cycode_client, scan_result) |
144 | 114 |
|
145 | 115 | local_scan_result = create_local_scan_result( |
146 | 116 | scan_result, batch, command_scan_type, scan_type, severity_threshold |
|
0 commit comments