Sha256: 4fe37bfd5cb3e47d98839e3490681f106eaf011afaba0c41c861dfddd4eee80b
Contents?: true
Size: 936 Bytes
Versions: 1
Compression:
Stored size: 936 Bytes
Contents
# frozen_string_literal: true require "http" require "thor" module Miteru class CLI < Thor method_option :post_to_slack, type: :boolean, default: false desc "execute", "Execute the crawler" def execute results = Crawler.execute results.each do |result| message = "#{result} might contain a phishing kit." puts message post_to_slack(message) if options[:post_to_slack] && valid_slack_setting? end end no_commands do def valid_slack_setting? ENV["SLACK_WEBHOOK_URL"] != nil end def post_to_slack(message) webhook_url = ENV["SLACK_WEBHOOK_URL"] raise ArgumentError, "Please set the Slack webhook URL via SLACK_WEBHOOK_URL env" unless webhook_url channel = ENV["SLACK_CHANNEL"] || "#general" payload = { text: message, channel: channel } HTTP.post(webhook_url, json: payload) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
miteru-0.1.0 | lib/miteru/cli.rb |