diff --git a/app/models/tpc_software_report_metric.rb b/app/models/tpc_software_report_metric.rb index d85f5b32..7fed7dc7 100644 --- a/app/models/tpc_software_report_metric.rb +++ b/app/models/tpc_software_report_metric.rb @@ -547,21 +547,21 @@ def self.get_code_count(sonar_scanner_result) code_count end - def self.get_license(project_url, scancode_result) + def self.get_license(scancode_result) license_detections = scancode_result.dig("license_detections") || [] unless license_detections&.any? return nil end - standard_license_location = "#{project_url.split("/")[-1]}/License.txt" license_detections.each do |license_detection| (license_detection.dig("reference_matches") || []).each do |reference_match| - if reference_match.dig("from_file") == standard_license_location + from_file_split = reference_match.dig("from_file").split("/") + if from_file_split.length == 2 return reference_match.dig("license_expression") end end end - license_detections.first.dig("license_expression") + return nil end def self.get_ecology_dependency_acquisition(dependency_checker_result) diff --git a/app/services/tpc_software_metric_server.rb b/app/services/tpc_software_metric_server.rb index 1eba5065..10912bbd 100644 --- a/app/services/tpc_software_metric_server.rb +++ b/app/services/tpc_software_metric_server.rb @@ -190,7 +190,7 @@ def tpc_software_callback(command_list, scan_results, task_metadata) when "scancode" metric_hash.merge!(TpcSoftwareReportMetric.get_compliance_license(scan_results.dig(command) || {})) metric_hash.merge!(TpcSoftwareReportMetric.get_compliance_license_compatibility(scan_results.dig(command) || {})) - license = TpcSoftwareReportMetric.get_license(@project_url, scan_results.dig(command) || {}) + license = TpcSoftwareReportMetric.get_license(scan_results.dig(command) || {}) when "binary-checker" metric_hash.merge!(TpcSoftwareReportMetric.get_security_binary_artifact(scan_results.dig(command) || {})) when "signature-checker"