Class: AttachFileCommand
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- AttachFileCommand
- Defined in:
- lib/audit/lib/parser/command/attach_file_command.rb
Overview
A command that uploads a file from the audited host.
Constant Summary collapse
- COMMAND =
Command name in the script.
"ATTACH_FILE"
- @@log =
Logger.new(STDOUT)
Instance Attribute Summary collapse
-
#check ⇒ Object
readonly
Returns the value of attribute check.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#remote_path ⇒ Object
readonly
Returns the value of attribute remote_path.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
-
#initialize(check, severity, args) ⇒ AttachFileCommand
constructor
A new instance of AttachFileCommand.
- #process(parser) ⇒ Object
- #result ⇒ Object
Constructor Details
#initialize(check, severity, args) ⇒ AttachFileCommand
Returns a new instance of AttachFileCommand.
40 41 42 43 44 45 46 47 48 |
# File 'lib/audit/lib/parser/command/attach_file_command.rb', line 40 def initialize(check, severity, args) = args[1 .. -1].join if args.length >= 2 super(check, severity, ) @@log.level = Logger::DEBUG @remote_path = args[0].strip if args.length >= 1 or raise ParseException.new("#{COMMAND} did not supply the file argument") @local_path = nil end |
Instance Attribute Details
#check ⇒ Object (readonly)
Returns the value of attribute check.
36 37 38 |
# File 'lib/audit/lib/parser/command/attach_file_command.rb', line 36 def check @check end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
38 39 40 |
# File 'lib/audit/lib/parser/command/attach_file_command.rb', line 38 def @message end |
#remote_path ⇒ Object (readonly)
Returns the value of attribute remote_path.
37 38 39 |
# File 'lib/audit/lib/parser/command/attach_file_command.rb', line 37 def remote_path @remote_path end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
35 36 37 |
# File 'lib/audit/lib/parser/command/attach_file_command.rb', line 35 def severity @severity end |
Instance Method Details
#process(parser) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/audit/lib/parser/command/attach_file_command.rb', line 50 def process(parser) if parser. then filename = (/^(\/?([^\/]+\/)*)([^\/]+)$/.match(@remote_path) or {3 => nil})[3] @local_path = parser. + "/" + filename parser.connection.copy_from_remote(@remote_path, @local_path) else @@log.info { "file #{@remote_path} attached, but no attachment dir specified" } end end |
#result ⇒ Object
60 61 62 |
# File 'lib/audit/lib/parser/command/attach_file_command.rb', line 60 def result() return AttachFileCommandResult.new(@check, @severity, @message, @local_path) end |