diff --git a/lib/license_finder/package_managers/conan.rb b/lib/license_finder/package_managers/conan.rb index fe77c4b7..e7917727 100644 --- a/lib/license_finder/package_managers/conan.rb +++ b/lib/license_finder/package_managers/conan.rb @@ -14,7 +14,13 @@ def license_file_is_good?(license_file_path) end def license_file(project_path, name) - candidates = Dir.glob("#{project_path}/licenses/#{name}/**/LICENSE*") + lic_file = license_file_by_mask(project_path, name, 'LICENSE*') + lic_file = license_file_by_mask(project_path, name, 'copy*') if lic_file.nil? + lic_file + end + + def license_file_by_mask(project_path, name, file_mask) + candidates = Dir.glob("#{project_path}/licenses/#{name}/**/#{file_mask}") candidates.each do |candidate| return candidate if license_file_is_good?(candidate) end diff --git a/lib/license_finder/package_utils/conan_info_parser_v2.rb b/lib/license_finder/package_utils/conan_info_parser_v2.rb index fa1d2965..7d30d5c0 100644 --- a/lib/license_finder/package_utils/conan_info_parser_v2.rb +++ b/lib/license_finder/package_utils/conan_info_parser_v2.rb @@ -3,16 +3,13 @@ module LicenseFinder class ConanInfoParserV2 def parse(info) - @lines = info.lines.map(&:chomp) + @lines = get_dependencies_lines(info) @state = :project_level # state of the state machine @projects = [] # list of projects @current_project = nil # current project being populated in the SM @current_vals = [] # current val list being populate in the SM @current_key = nil # current key to be associated with the current val - line = @lines.shift - line = @lines.shift while line != '======== Basic graph information ========' - while (line = @lines.shift) next if line == '' @@ -33,6 +30,20 @@ def parse(info) private + def get_dependencies_lines(info) + lines = info.lines.map(&:chomp) + graph_info_start = 'basic graph information' + if info.downcase.include?(graph_info_start) + loop do + line = lines.shift + break if lines.empty? + next if line.nil? + break if line.downcase.include?(graph_info_start) + end + end + lines + end + def parse_key_val(line) key, val = key_val(line) if val