Compare headers w/process keys instead of themselves

Also clarifies a bunch of old bad variable names
bug/bundler_fix
James Lee 2017-06-22 21:43:11 -05:00
parent 32fbad7fca
commit 283f36f79a
No known key found for this signature in database
GPG Key ID: 2D6094C7CEA0A321
1 changed files with 11 additions and 11 deletions

View File

@ -390,31 +390,31 @@ class ProcessList < Array
return Rex::Text::Table.new(opts)
end
cols = [ "PID", "PPID", "Name", "Arch", "Session", "User", "Path" ]
cols.delete_if do |c|
none? {|r| r.has_key?(c.downcase)} ||
all? {|r| r[c.downcase].nil?}
column_headers = [ "PID", "PPID", "Name", "Arch", "Session", "User", "Path" ]
column_headers.delete_if do |h|
none? { |process| process.has_key?(h.downcase) } ||
all? { |process| process[h.downcase].nil? }
end
opts = {
'Header' => 'Process List',
'Indent' => 1,
'Columns' => cols
'Columns' => column_headers
}.merge(opts)
tbl = Rex::Text::Table.new(opts)
each { |process|
tbl << cols.map { |c|
next unless cols.any? {|h| h.downcase == c.downcase}
col = c.downcase
each do |process|
tbl << column_headers.map do |header|
col = header.downcase
next unless process.keys.any? { |process_header| process_header == col }
val = process[col]
if col == 'session'
val == 0xFFFFFFFF ? '' : val.to_s
else
val
end
}
}
end
end
tbl
end