bin/pwn_bdba_scan in pwn-0.4.804 vs bin/pwn_bdba_scan in pwn-0.4.805
- old
+ new
@@ -14,12 +14,12 @@
options.on('-cCONFIG', '--config=CONFG', '<Required - Black Duck Binary Analysis YAML config>') do |g|
opts[:config] = g
end
- options.on('-pNAME', '--parent-group=NAME', '<Required - Black Duck Binary Analysis Parent Group Name to Associate with Binary Scan>') do |p|
- opts[:parent_group_name] = p
+ options.on('-pID', '--parent-group-id=ID', '<Required - Black Duck Binary Analysis Parent Group ID to Associate with Binary Scan>') do |p|
+ opts[:parent_group_id] = p
end
options.on('-sFILE', '--scan=FILE', '<Required - File to Scan in Black Duck Binary Analysis>') do |f|
opts[:target_file] = f
end
@@ -56,12 +56,12 @@
yaml_config = YAML.load_file(config, symbolize_names: true)
token = yaml_config[:token]
raise "ERROR: BDBA Token Not Found: #{token}" if token.nil?
- parent_group_name = opts[:parent_group_name]
- raise "ERROR: BDBA Parent Group Name Not Provided: #{parent_group_name}" if parent_group_name.nil?
+ parent_group_id = opts[:parent_group_id]
+ raise "ERROR: BDBA Parent Group ID Not Provided: #{parent_group_id}" if parent_group_id.nil?
target_file = opts[:target_file]
raise "ERROR: BDBA Target File Not Found: #{target_file}" unless File.exist?(target_file)
report_path = opts[:report_path]
@@ -72,35 +72,25 @@
report_type_str = opts[:report_type] ||= 'csv_vulns'
report_type = report_type_str.to_s.to_sym
version = opts[:version]
- groups_resp = PWN::Plugins::BlackDuckBinaryAnalysis.get_groups(
- token: token
- )
-
- parent_arr = groups_resp[:groups].select { |g| g[:name] == parent_group_name }
- raise "ERROR: BDBA Parent Group Not Found: #{parent_group_name}" if parent_arr.nil?
-
- sorted_parent_arr = parent_arr.sort_by { |g| g[:id] }
- parent_id = sorted_parent_arr.last[:id]
-
unless report_only
puts "Uploading/Scanning: #{target_file}"
PWN::Plugins::BlackDuckBinaryAnalysis.upload_file(
token: token,
file: target_file,
- group_id: parent_id,
+ group_id: parent_group_id,
version: version
)
end
scan_progress_resp = {}
scan_progress_busy_duration = 0
loop do
scan_progress_resp = PWN::Plugins::BlackDuckBinaryAnalysis.get_apps_by_group(
token: token,
- group_id: parent_id
+ group_id: parent_group_id
)
break if scan_progress_resp[:products].none? { |p| p[:status] == 'B' } || report_only
# Cancel queued scan if it's been queued for more than 90 minutes