Skip to content

Commit

Permalink
Update get_license
Browse files Browse the repository at this point in the history
Signed-off-by: lishengbao <[email protected]>
  • Loading branch information
lishengbao committed Aug 5, 2024
1 parent 264107e commit c3b69a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/models/tpc_software_report_metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/services/tpc_software_metric_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c3b69a8

Please sign in to comment.