class Nasl::Command
Public Class Methods
all()
click to toggle source
# File lib/nasl/command.rb, line 33 def self.all (@_all ||= []) end
find(cmd)
click to toggle source
# File lib/nasl/command.rb, line 41 def self.find(cmd) all.each do |cls| return cls if cls.binding == cmd end nil end
inherited(cls)
click to toggle source
# File lib/nasl/command.rb, line 37 def self.inherited(cls) all << cls end
initialize!()
click to toggle source
# File lib/nasl/command.rb, line 29 def self.initialize! Dir.glob(Nasl.lib + 'nasl/commands/*.rb').each { |f| load(f) } end
run(cfg, args)
click to toggle source
# File lib/nasl/command.rb, line 64 def self.run(cfg, args) # Separate plugins and libraries from the rest of the arguments. paths = args.select { |arg| arg =~ /(\/|\.(inc|nasl))$/ } args -= paths # If we have no paths to process, there's a problem. Special purpose # commands that don't require files to be declared should override this # method. if paths.empty? puts "No directories (/), libraries (.inc), or plugins (.nasl) were specified." exit 1 end # Collect all the paths together, recursively. dirents = [] paths.each do |path| Pathname.new(path).find do |dirent| if dirent.file? && dirent.extname =~ /inc|nasl/ dirents << dirent end end end # If the command is capable of handling all the paths at once, send them # in a group, otherwise send them individually. if self.respond_to? :analyze_all then analyze_all(cfg, dirents, args) else dirents.each do |d| puts banner(d.basename) analyze(cfg, d, args) puts banner(d.basename) end end end