Sha256: bb348141bf070cdf0d9e84fbe32a3459a8ed06d2e67f6f964f1cdab3059200c4

Contents?: true

Size: 1.8 KB

Versions: 8

Compression:

Stored size: 1.8 KB

Contents

class GuardDuty < Mapper
  #
  # Returns an array of resources.
  #
  # TODO: test live
  #
  def collect
    resources = []

    #
    # list_detectors
    #
    @client.list_detectors.each_with_index do |response, page|
      log(response.context.operation_name, page)

      response.detector_ids.each do |detector|
        log(response.context.operation_name, 'get_detector', detector)

        # get_detector
        struct = OpenStruct.new(@client.get_detector({ detector_id: detector }).to_h)
        struct.type = 'detector'
        struct.arn = "arn:aws:guardduty:#{@region}:detector/#{detector}"

        # get_findings_statistics (only active findings)
        struct.findings_statistics = @client.get_findings_statistics({
                                                                       detector_id: detector,
                                                                       finding_statistic_types: ['COUNT_BY_SEVERITY'],
                                                                       finding_criteria: {
                                                                         criterion: {
                                                                           'service.archived': {
                                                                             eq: ['false']
                                                                           }
                                                                         }
                                                                       }
                                                                     }).finding_statistics.to_h

        # get_master_account
        struct.master_account = @client.get_master_account({ detector_id: detector }).master.to_h

        resources.push(struct.to_h)
      end
    end

    resources
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
aws_recon-0.2.27 lib/aws_recon/collectors/guardduty.rb
aws_recon-0.2.26 lib/aws_recon/collectors/guardduty.rb
aws_recon-0.2.25 lib/aws_recon/collectors/guardduty.rb
aws_recon-0.2.24 lib/aws_recon/collectors/guardduty.rb
aws_recon-0.2.23 lib/aws_recon/collectors/guardduty.rb
aws_recon-0.2.22 lib/aws_recon/collectors/guardduty.rb
aws_recon-0.2.21 lib/aws_recon/collectors/guardduty.rb
aws_recon-0.2.20 lib/aws_recon/collectors/guardduty.rb