Class: Nasl::Command
- Inherits:
-
Object
show all
- Defined in:
- lib/nasl/command.rb
Class Method Summary
collapse
Class Method Details
.all ⇒ Object
33
34
35
|
# File 'lib/nasl/command.rb', line 33
def self.all
(@_all ||= [])
end
|
.banner(title, width = 80) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/nasl/command.rb', line 49
def self.banner(title, width=80)
middle = "[ #{title} ]"
width = width.to_f
leftover = (width - middle.length) / 2
left = '-' * leftover.floor
right = '-' * leftover.ceil
left + middle + right
end
|
.find(cmd) ⇒ Object
41
42
43
44
45
46
47
|
# 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) ⇒ Object
37
38
39
|
# File 'lib/nasl/command.rb', line 37
def self.inherited(cls)
all << cls
end
|
.initialize! ⇒ Object
29
30
31
|
# 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) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/nasl/command.rb', line 64
def self.run(cfg, args)
paths = args.select { |arg| arg =~ /(\/|\.(inc|nasl))$/ }
args -= paths
if paths.empty?
puts "No directories (/), libraries (.inc), or plugins (.nasl) were specified."
exit 1
end
dirents = []
paths.each do |path|
Pathname.new(path).find do |dirent|
if dirent.file? && dirent.extname =~ /inc|nasl/
dirents << dirent
end
end
end
if self.respond_to? :analyze_all then
analyze_all(cfg, dirents, args)
else
dirents.each { |d| analyze(cfg, d, args) }
end
end
|