|
52 | 52 | from scanpipe.models import DiscoveredDependency |
53 | 53 | from scanpipe.models import DiscoveredPackage |
54 | 54 | from scanpipe.pipes import flag |
| 55 | +from scanpipe.pipes.license_clarity import get_project_clarity_thresholds |
55 | 56 |
|
56 | 57 | logger = logging.getLogger("scanpipe.pipes") |
57 | 58 |
|
@@ -931,7 +932,10 @@ def make_results_summary(project, scan_results_location): |
931 | 932 | Extract selected sections of the Scan results, such as the `summary` |
932 | 933 | `license_clarity_score`, and `license_matches` related data. |
933 | 934 | The `key_files` are also collected and injected in the `summary` output. |
| 935 | + Additionally, store clarity_compliance_alert in project's extra_data. |
934 | 936 | """ |
| 937 | + import json |
| 938 | + |
935 | 939 | from scanpipe.api.serializers import CodebaseResourceSerializer |
936 | 940 | from scanpipe.api.serializers import DiscoveredPackageSerializer |
937 | 941 |
|
@@ -964,4 +968,16 @@ def make_results_summary(project, scan_results_location): |
964 | 968 | DiscoveredPackageSerializer(package).data for package in key_files_packages_qs |
965 | 969 | ] |
966 | 970 |
|
| 971 | + clarity_score = summary.get("license_clarity_score", {}).get("score") |
| 972 | + if clarity_score is not None: |
| 973 | + clarity_policy = get_project_clarity_thresholds(project) |
| 974 | + if clarity_policy: |
| 975 | + alert = clarity_policy.get_alert_for_score(clarity_score) |
| 976 | + summary["clarity_compliance_alert"] = alert |
| 977 | + |
| 978 | + extra_data = project.extra_data or {} |
| 979 | + extra_data["clarity_compliance_alert"] = alert |
| 980 | + project.extra_data = extra_data |
| 981 | + project.save(update_fields=["extra_data"]) |
| 982 | + |
967 | 983 | return summary |
0 commit comments