Class: Emasser::DeviceScans
- Inherits:
-
SubCommandBase
- Object
- Thor
- SubCommandBase
- Emasser::DeviceScans
- Defined in:
- lib/emasser/post.rb
Overview
Upload device scans (delivery method can be a file or a zip file)
The body of a request for this endpoint accepts a single binary file. Specific file extensions are expected depending upon the scanType parameter. For example, .ckl or .cklb files are accepted when using scanType is set to disaStigViewerCklCklb.
When set to acasAsrArf or policyAuditor, a .zip file is expected which should contain a single scan result (for example, a single pair of .asr and .arf files).
Single files are expected for all other scan types as this endpoint requires files to be uploaded consecutively as opposed to in bulk.
Current scan types that are supported: • ACAS: ASR/ARF • ACAS: NESSUS • DISA STIG Viewer: CKL/CKLB • DISA STIG Viewer: CMRS • Policy Auditor • SCAP Compliance Checker
Endpoint:
/api/systems/{systemId}/device-scan-results
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from SubCommandBase
Methods included from OutputConverters
#change_to_datetime, #to_output_hash
Methods included from InputConverters
Methods included from OptionsParser
#optional_options, #required_options
Class Method Details
.exit_on_failure? ⇒ Boolean
801 802 803 |
# File 'lib/emasser/post.rb', line 801 def self.exit_on_failure? true end |
Instance Method Details
#upload ⇒ Object
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 |
# File 'lib/emasser/post.rb', line 816 def upload # Check if business logic is satisfied process_business_logic # Options contain the default values (type, category, and isTemplate) # They are sent to the API in the form_params option opts = {} opts[:isBaseline] = [:isBaseline] if [:isBaseline] # Configure the upload file begin # If we have a single file, could be a zip file if [:filename] tempfile = File.open([:filename], 'r') else puts 'One (1) file is expected!'.yellow end rescue Errno::ENOENT => e warn "File open exception: #{e}".red exit 1 end # Call the API begin result = EmassClient::DeviceScanResultsApi .new .add_scan_results_by_system_id([:systemId], [:scanType], tempfile, opts) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling DeviceScanResultsApi->add_scan_results_by_system_id'.red puts to_output_hash(e) end end |