class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-08-05",
      revision: "2bcb3e5c5e1961dd722935d4bb936d0d6fab634f"
  version "2021-08-05"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "857054bb5a7f8e5797d1203d1b5c0b2ac0ffdf1e7784ed33a1e8bb34130bf0a1"
    sha256 cellar: :any_skip_relocation, big_sur:       "596054e64830f6b0dd9fddd4510c8637c0bcf77365fa3dd6c4285641236b798e"
    sha256 cellar: :any_skip_relocation, catalina:      "07aed705568fd894153db5b014fb6f659c7970a2c8a5986b69ab26a7b4ce5996"
    sha256 cellar: :any_skip_relocation, mojave:        "d31a5d026ac63498b89fa115a96916300a0983881498364022d2d091889f7731"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "f90a8ed912001e5869a1927958c16fcd01cbb25086da8ffb3c7c38857d8a4a47"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
