Clean up cmd_ps table output for Mettle
Mettle can run in all sorts of environments where some colums of a process table will be nil. The existing implementation compacts rows going into the table while providing filtering for the colum contents only by checking the output of the first row in the proc table. Check column filters against all rows to ensure proper table init. Check columns going into table for match against header. Do not compact nil values in the table rows - some things, like kthreads/workers dont have a path while other PIDs will.bug/bundler_fix
parent
bf674263f3
commit
762427b447
|
@ -395,7 +395,10 @@ class ProcessList < Array
|
||||||
# ppid. Cut columns from the list if they aren't there. It is conceivable
|
# ppid. Cut columns from the list if they aren't there. It is conceivable
|
||||||
# that processes might have different columns, but for now assume that the
|
# that processes might have different columns, but for now assume that the
|
||||||
# first one is representative.
|
# first one is representative.
|
||||||
cols.delete_if { |c| !( first.has_key?(c.downcase) ) or first[c.downcase].nil? }
|
cols.delete_if do |c|
|
||||||
|
!(any? {|r| r.has_key?(c.downcase)}) or
|
||||||
|
all? {|r| r[c.downcase].nil?}
|
||||||
|
end
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
'Header' => 'Process List',
|
'Header' => 'Process List',
|
||||||
|
@ -406,6 +409,7 @@ class ProcessList < Array
|
||||||
tbl = Rex::Text::Table.new(opts)
|
tbl = Rex::Text::Table.new(opts)
|
||||||
each { |process|
|
each { |process|
|
||||||
tbl << cols.map { |c|
|
tbl << cols.map { |c|
|
||||||
|
next unless cols.any? {|h| h.downcase == c.downcase}
|
||||||
col = c.downcase
|
col = c.downcase
|
||||||
val = process[col]
|
val = process[col]
|
||||||
if col == 'session'
|
if col == 'session'
|
||||||
|
@ -413,7 +417,7 @@ class ProcessList < Array
|
||||||
else
|
else
|
||||||
val
|
val
|
||||||
end
|
end
|
||||||
}.compact
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tbl
|
tbl
|
||||||
|
|
Loading…
Reference in New Issue