bin/pwn_bdba_groups in pwn-0.4.805 vs bin/pwn_bdba_groups in pwn-0.4.806
- old
+ new
@@ -21,12 +21,12 @@
options.on('-lNAME', '--list-group=NAME', '<Optional - List Group Details>') do |l|
opts[:list_group_name] = l
end
- options.on('-pPNAME', '--parent-group=PNAME', '<Optional - Black Duck Binary Analysis Parent Group Name to Associate with Group>') do |p|
- opts[:parent_group_name] = p
+ options.on('-pID', '--parent-group-ID=ID', '<Optional - Black Duck Binary Analysis Parent Group ID to Associate with Group>') do |p|
+ opts[:parent_group_id] = p
end
end.parse!
if opts.empty?
puts `#{$PROGRAM_NAME} --help`
@@ -44,66 +44,44 @@
token = yaml_config[:token]
raise "ERROR: BDBA Token Not Found: #{token}" if token.nil?
list_group_name = opts[:list_group_name]
- parent_group_name = opts[:parent_group_name]
- parent_id = nil
+ parent_group_id = opts[:parent_group_id]
- if list_group_name || parent_group_name
+ if list_group_name
groups_resp = PWN::Plugins::BlackDuckBinaryAnalysis.get_groups(
token: token
)
- raise 'No groups found in BDBA. Use the --create flag to create your first group.' if groups_resp.nil?
+ group_arr = groups_resp[:groups].select { |g| g[:name] == list_group_name }
- list_or_parent = list_group_name unless list_group_name.nil?
- list_or_parent = parent_group_name unless parent_group_name.nil?
-
- group_arr = groups_resp[:groups].select { |g| g[:name] == list_or_parent }
-
if list_group_name && group_arr.empty?
puts 'BDBA Group Not Found.'
exit 1
end
- group_arr_sorted = group_arr.sort_by { |g| g[:id] }
- if group_arr_sorted.length > 1
- dup_groups_arr = []
- group_arr_sorted.each do |group|
- this_group_id = group[:id]
- this_group_details = PWN::Plugins::BlackDuckBinaryAnalysis.get_group_details(
- token: token,
- group_id: this_group_id
- )
- dup_groups_arr.push(this_group_details[:group])
- end
+ group_details_arr = []
+ group_arr.each do |group|
+ group_id = group.[:id]
- puts "ERROR: Multiple BDBA Groups Found:\n#{dup_groups_arr}"
- exit 1
- end
-
- group = group_arr_sorted.last
- parent_id = group[:id]
-
- if list_group_name
- group_id = parent_id
- group_details_resp = PWN::Plugins::BlackDuckBinaryAnalysis.get_group_details(
+ this_group_details = PWN::Plugins::BlackDuckBinaryAnalysis.get_group_details(
token: token,
group_id: group_id
)
- puts group_details_resp.to_json
- exit 0
+ group_details_arr.push(this_group_details)
end
+ puts group_details_arr.to_json
+ exit 0
end
group_name = opts[:group_name]
raise "ERROR: BDBA Group Name Not Provided: #{group_name}" if group_name.nil?
create_group_resp = PWN::Plugins::BlackDuckBinaryAnalysis.create_group(
token: token,
name: group_name,
- parent_id: parent_id
+ parent_id: parent_group_id
)
puts create_group_resp.to_json
rescue SystemExit, Interrupt
puts "\nGoodbye."