Class: SeccompTools::CLI::Dump
- Includes:
- FilterInput
- Defined in:
- lib/seccomp-tools/cli/dump.rb
Overview
Handle 'dump' command.
Constant Summary collapse
- SUMMARY =
Summary of this command.
'Automatically dump seccomp bpf from executable(s).'- USAGE =
Usage of this command.
"dump - #{SUMMARY}\nNOTE: This command is only available on Linux." \ "\n\nUsage: seccomp-tools dump [EXEC] [options]".freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#handle ⇒ void
Traces the target process and writes out the seccomp filters it installs.
-
#initialize ⇒ Dump
constructor
Instantiate a Dump object, dumping the first filter as disassembly by default.
-
#parser ⇒ OptionParser
Define option parser.
Methods included from Dumpable
#dump_seccomp, #dumping_supported?
Constructor Details
#initialize ⇒ Dump
Instantiate a SeccompTools::CLI::Dump object, dumping the first filter as disassembly by default.
Takes the same arguments as Base#initialize.
23 24 25 26 |
# File 'lib/seccomp-tools/cli/dump.rb', line 23 def initialize(*) super option[:format] = :disasm end |
Instance Method Details
#handle ⇒ void
This method returns an undefined value.
Traces the target process and writes out the seccomp filters it installs.
Only available on Linux, logs an error and returns otherwise.
55 56 57 58 59 60 |
# File 'lib/seccomp-tools/cli/dump.rb', line 55 def handle return unless dumping_supported? return unless super collect_filters.each { |bpf, arch| emit(bpf, arch) } end |
#parser ⇒ OptionParser
Define option parser.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/seccomp-tools/cli/dump.rb', line 31 def parser @parser ||= OptionParser.new do |opt| opt. = usage option_filter_source(opt, 'dump') opt.on('-f', '--format FORMAT', %i[disasm raw inspect], 'Output format. FORMAT can only be one of <disasm|raw|inspect>.', 'Default: disasm') do |f| option[:format] = f end opt.on('-o', '--output FILE', 'Write output to FILE instead of stdout.', 'If multiple seccomp syscalls have been invoked (see --limit),', 'results are written to FILE, FILE_1, FILE_2, etc.', 'For example, with "--output out.bpf" the output files are out.bpf, out_1.bpf, ...') do |o| option[:ofile] = o end end end |