Sha256: fe4f9f875246bc911462f8adde9e344ee2e2916831b5ea5372d55030fd8a86d9
Contents?: true
Size: 1.26 KB
Versions: 9
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true require "securitytrails" module Mihari module Analyzers class SecurityTrailsDomainFeed < Base attr_reader :type, :title, :description, :tags def initialize(regexp, type: "registered", title: nil, description: nil, tags: []) super() @_regexp = regexp @type = type raise InvalidInputError, "#{@_regexp} is not a valid regexp" unless regexp raise InvalidInputError, "#{type} is not a valid type" unless valid_type? @title = title || "SecurityTrails domain feed lookup" @description = description || "Regexp = /#{@_regexp}/" @tags = tags end def artifacts lookup || [] end private def config_keys %w[securitytrails_api_key] end def api @api ||= ::SecurityTrails::API.new(Mihari.config.securitytrails_api_key) end def valid_type? %w[all new registered].include? type end def regexp @regexp ||= Regexp.compile(@_regexp) rescue InvalidInputError => _e nil end def lookup new_domains.select do |domain| regexp.match? domain end end def new_domains api.feeds.domains type end end end end
Version data entries
9 entries across 9 versions & 1 rubygems