Class: ThreatScanner
- Inherits:
-
Object
- Object
- ThreatScanner
- Defined in:
- lib/ndr_support/threat_scanner.rb
Overview
Defined Under Namespace
Classes: Error, MissingFileError, MissingScannerError, ScannerOperationError, ThreatDetectedError
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#check ⇒ Object
Returns true if the given file is deemed safe, and false if it could not be checked.
-
#check! ⇒ Object
Returns true if the given file is deemed safe, and raises an exception otherwise (if the file is unsafe / does not exist / scanner broke etc).
-
#initialize(path) ⇒ ThreatScanner
constructor
A new instance of ThreatScanner.
Constructor Details
#initialize(path) ⇒ ThreatScanner
Returns a new instance of ThreatScanner.
28 29 30 |
# File 'lib/ndr_support/threat_scanner.rb', line 28 def initialize(path) @path = path.respond_to?(:path) ? path.path : path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
26 27 28 |
# File 'lib/ndr_support/threat_scanner.rb', line 26 def path @path end |
Class Method Details
.installed? ⇒ Boolean
22 23 24 |
# File 'lib/ndr_support/threat_scanner.rb', line 22 def self.installed? system('which clamdscan > /dev/null 2>&1') end |
Instance Method Details
#check ⇒ Object
Returns true if the given file is deemed safe, and false if it could not be checked. Raises if a threat is detected, or the file did not exist.
34 35 36 37 38 |
# File 'lib/ndr_support/threat_scanner.rb', line 34 def check check! rescue MissingScannerError, ScannerOperationError false end |
#check! ⇒ Object
Returns true if the given file is deemed safe, and raises an exception otherwise (if the file is unsafe / does not exist / scanner broke etc).
42 43 44 |
# File 'lib/ndr_support/threat_scanner.rb', line 42 def check! check_existence! && check_installed! && run_scanner! end |