homebrew-core/Formula/dependency-check.rb

55 lines
2.0 KiB
Ruby

class DependencyCheck < Formula
desc "OWASP dependency-check"
homepage "https://owasp.org/www-project-dependency-check/"
url "https://github.com/jeremylong/DependencyCheck/releases/download/v7.1.1/dependency-check-7.1.1-release.zip"
sha256 "1070591e7ae2b9ed60384f58db489405c68856f544b8d27456eb3b153478ec8f"
license "Apache-2.0"
livecheck do
url :homepage
regex(/href=.*?dependency-check[._-]v?(\d+(?:\.\d+)+)-release\.zip/i)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "dfcfd63230e56315e51697a4924f4ff47b3c81976e7ca56d93a8b04f93914a9c"
end
depends_on "openjdk"
def install
rm_f Dir["bin/*.bat"]
chmod 0755, "bin/dependency-check.sh"
libexec.install Dir["*"]
(bin/"dependency-check").write_env_script libexec/"bin/dependency-check.sh",
JAVA_HOME: Formula["openjdk"].opt_prefix
(var/"dependencycheck").mkpath
libexec.install_symlink var/"dependencycheck" => "data"
(etc/"dependencycheck").mkpath
jar = "dependency-check-core-#{version}.jar"
corejar = libexec/"lib/#{jar}"
system "unzip", "-o", corejar, "dependencycheck.properties", "-d", libexec/"etc"
(etc/"dependencycheck").install_symlink libexec/"etc/dependencycheck.properties"
end
test do
# wait a random amount of time as multiple tests are being on different OS
# the sleep 1 seconds to 30 seconds assists with the NVD Rate Limiting issues
sleep(rand(1..30))
output = shell_output("#{bin}/dependency-check --version").strip
assert_match "Dependency-Check Core version #{version}", output
(testpath/"temp-props.properties").write <<~EOS
cve.startyear=2017
analyzer.assembly.enabled=false
EOS
system bin/"dependency-check", "-P", "temp-props.properties", "-f", "XML",
"--project", "dc", "-s", libexec, "-d", testpath, "-o", testpath,
"--cveStartYear", Time.now.year, "--cveDownloadWait", "5000"
assert_predicate testpath/"dependency-check-report.xml", :exist?
end
end