Module: Eso::Nexpose

Defined in:
lib/eso/nexpose.rb

Class Method Summary collapse

Class Method Details

.create_add_to_site_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY) ⇒ Object



183
184
185
186
187
188
189
# File 'lib/eso/nexpose.rb', line 183

def self.create_add_to_site_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY)
   Step.new(workflow: workflow,
           service_name: ServiceNames::NEXPOSE,
           type_name: StepNames::ADD_TO_SITE,
           previous_type_name: previous_type_name)
       .add_property(StepConfiguration::ConfigParamProperties::SITE_ID, id)
end

.create_add_vuln_and_scan_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY) ⇒ Object



175
176
177
178
179
180
181
# File 'lib/eso/nexpose.rb', line 175

def self.create_add_vuln_and_scan_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY)
  Step.new(workflow: workflow,
           service_name: ServiceNames::NEXPOSE,
           type_name: StepNames::ADD_VULN_AND_SCAN,
           previous_type_name: previous_type_name)
      .add_property(StepConfiguration::ConfigParamProperties::SITE_ID, id)
end

.create_discover_known_assets_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/eso/nexpose.rb', line 133

def self.create_discover_known_assets_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY)
  step = Step.new(workflow: workflow,
           service_name: ServiceNames::NEXPOSE,
           type_name: StepNames::DISCOVER_KNOWN,
           previous_type_name: previous_type_name)
             .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, id)
  config_params = step.configuration_params
  config_params[:HOURS_SINCE_LAST_SCAN] = {
      :valueClass => Values::ARRAY,
      :items => [
          {
              :valueClass => Values::OBJECT,
              :objectType => Filters::HOURS_SINCE_LAST_SCAN_ITEM,
              :properties => {
                  :operator => {
                      :valueClass => Values::STRING,
                      :value => ::Nexpose::Search::Operator::GREATER_THAN
                  },
                  :operand1 => {
                      :valueClass  => Values::STRING,
                      :value => '1'
                  }
              }
          }
      ]
  }
  step.configuration_params = config_params
  step
end

.create_discover_new_assets_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY) ⇒ Object



125
126
127
128
129
130
131
# File 'lib/eso/nexpose.rb', line 125

def self.create_discover_new_assets_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY)
  Step.new(workflow: workflow,
           service_name: ServiceNames::NEXPOSE,
           type_name: StepNames::DISCOVER_NEW,
           previous_type_name: previous_type_name)
      .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, id)
end

.create_discovery_workflow(conductor:, name:, step1_type:, step1_param: nil, step2_type:, step2_param:) ⇒ Object



88
89
90
91
92
93
# File 'lib/eso/nexpose.rb', line 88

def self.create_discovery_workflow(conductor:, name:, step1_type:, step1_param: nil, step2_type:, step2_param:)
  step1 = self.send("create_#{step1_type.to_s.gsub(/-/, "_")}_step", id: step1_param)
  step2 = self.send("create_#{step2_type.to_s.gsub(/-/, "_")}_step", id: step2_param)
  step2.previous_type_name = step1.type_name
  conductor.create_workflow(name: name, steps: [step1, step2])
end

.create_file_reputation_step(workflow: nil, id:) ⇒ Object



117
118
119
120
121
122
123
# File 'lib/eso/nexpose.rb', line 117

def self.create_file_reputation_step(workflow: nil, id:)
  Step.new(workflow: workflow,
           service_name: ServiceNames::DXL,
           type_name: StepNames::FILE_REPUTATION_TRIGGER,
           previous_type_name: nil)
      .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, id)
end

.create_file_trigger_workflow(conductor:, name:, step1_param:, step2_param:) ⇒ Object



102
103
104
105
106
107
# File 'lib/eso/nexpose.rb', line 102

def self.create_file_trigger_workflow(conductor:, name:, step1_param:, step2_param:)
  step1 = self.create_file_reputation_step(workflow: nil, id: step1_param)
  step2 = self.create_tag_step(workflow: nil, id: step2_param)
  step2.previous_type_name = step1.type_name
  conductor.create_workflow(name: name, steps: [step1, step2])
end

.create_new_vuln_step(workflow: nil, filters:, previous_type_name: StepNames::EMPTY) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
# File 'lib/eso/nexpose.rb', line 163

def self.create_new_vuln_step(workflow: nil, filters:, previous_type_name: StepNames::EMPTY)
  # The filter definitions on the server are not standard at this point so that is why it is necessary to hard code this
  # Opening a defect to fix the consistency on these on the backend so we can use the add_filter function in the automation
  step = Step.new(workflow: workflow,
           service_name: ServiceNames::NEXPOSE,
           type_name: StepNames::NEW_VULN,
           previous_type_name: previous_type_name)

  filters.each { |filter| step.add_filter(filter) }
  step
end

.create_scan_in_site_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY) ⇒ Object



109
110
111
112
113
114
115
# File 'lib/eso/nexpose.rb', line 109

def self.create_scan_in_site_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY)
  Step.new(workflow: workflow,
           service_name: ServiceNames::NEXPOSE,
           type_name: StepNames::SCAN_IN_SITE,
           previous_type_name: previous_type_name)
      .add_property(StepConfiguration::ConfigParamProperties::SITE_ID, id)
end

.create_scan_new_vuln_workflow(conductor:, name:, filters:, site_id:) ⇒ Object



95
96
97
98
99
100
# File 'lib/eso/nexpose.rb', line 95

def self.create_scan_new_vuln_workflow(conductor:, name:, filters:, site_id:)
  step1 = self.create_new_vuln_step(workflow: nil, filters: filters, previous_type_name: StepNames::EMPTY)
  step2 = self.create_add_vuln_and_scan_step(id: site_id)
  step2.previous_type_name = step1.type_name
  conductor.create_workflow(name: name, steps: [step1, step2])
end

.create_scan_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY) ⇒ Object



191
192
193
194
195
196
197
# File 'lib/eso/nexpose.rb', line 191

def self.create_scan_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY)
 Step.new(workflow: workflow,
          service_name: ServiceNames::NEXPOSE,
          type_name: StepNames::SCAN,
          previous_type_name: previous_type_name)
     .add_property(StepConfiguration::ConfigParamProperties::SITE_ID, id)
end

.create_tag_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY) ⇒ Object



199
200
201
202
203
204
205
# File 'lib/eso/nexpose.rb', line 199

def self.create_tag_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY)
   Step.new(workflow: workflow,
            service_name: ServiceNames::NEXPOSE,
            type_name: StepNames::TAG,
            previous_type_name: previous_type_name)
       .add_property(StepConfiguration::ConfigParamProperties::TAG_ID, id)
end

.get_discover_step(workflow:) ⇒ Object



207
208
209
# File 'lib/eso/nexpose.rb', line 207

def self.get_discover_step(workflow: )
  workflow.get_step(StepNames::DISCOVER_NEW) || workflow.get_step(StepNames::DISCOVER_KNOWN)
end