homebrew-core/Formula/auditbeat.rb

92 lines
3.2 KiB
Ruby

class Auditbeat < Formula
desc "Lightweight Shipper for Audit Data"
homepage "https://www.elastic.co/products/beats/auditbeat"
url "https://github.com/elastic/beats.git",
tag: "v8.6.1",
revision: "14f2f8d585f8c380945feee789771bd782cd6b2d"
license "Apache-2.0"
head "https://github.com/elastic/beats.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, arm64_ventura: "4cee1a7e73957b6b2701a8dad039feedb0e608db631cb35c2944a4369281e4a8"
sha256 cellar: :any_skip_relocation, arm64_monterey: "db5131577f4425f001230b6ad03429f69f90630e7113c97e6fdfbb86ed3f4880"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "817956d74bb14bea272ad447244c5e286f90741d9effaee64cd97ac5ff09bee3"
sha256 cellar: :any_skip_relocation, ventura: "daf9d543b57383f53d7dc9edd5d79181328284d8d356d77800a8b4827c690062"
sha256 cellar: :any_skip_relocation, monterey: "c9c83f15969329b20a50ef2cd97b23ea4e1b44c180f698dbf6ebfd091f7d245e"
sha256 cellar: :any_skip_relocation, big_sur: "d022348c6c0a2414680875fed1d2e4adcc3ece92b3c1f614399b253708cad974"
sha256 cellar: :any_skip_relocation, x86_64_linux: "0f824b9db93634039334c246f7124757fd4f151898617ec89428f3aa5144e2d7"
end
depends_on "go" => :build
depends_on "mage" => :build
depends_on "python@3.11" => :build
def install
# remove non open source files
rm_rf "x-pack"
cd "auditbeat" do
# don't build docs because it would fail creating the combined OSS/x-pack
# docs and we aren't installing them anyway
inreplace "magefile.go", "devtools.GenerateModuleIncludeListGo, Docs)",
"devtools.GenerateModuleIncludeListGo)"
# prevent downloading binary wheels during python setup
system "make", "PIP_INSTALL_PARAMS=--no-binary :all", "python-env"
system "mage", "-v", "build"
system "mage", "-v", "update"
(etc/"auditbeat").install Dir["auditbeat.*", "fields.yml"]
(libexec/"bin").install "auditbeat"
prefix.install "build/kibana"
end
(bin/"auditbeat").write <<~EOS
#!/bin/sh
exec #{libexec}/bin/auditbeat \
--path.config #{etc}/auditbeat \
--path.data #{var}/lib/auditbeat \
--path.home #{prefix} \
--path.logs #{var}/log/auditbeat \
"$@"
EOS
chmod 0555, bin/"auditbeat"
generate_completions_from_executable(bin/"auditbeat", "completion", shells: [:bash, :zsh])
end
def post_install
(var/"lib/auditbeat").mkpath
(var/"log/auditbeat").mkpath
end
service do
run opt_bin/"auditbeat"
end
test do
(testpath/"files").mkpath
(testpath/"config/auditbeat.yml").write <<~EOS
auditbeat.modules:
- module: file_integrity
paths:
- #{testpath}/files
output.file:
path: "#{testpath}/auditbeat"
filename: auditbeat
EOS
fork do
exec "#{bin}/auditbeat", "-path.config", testpath/"config", "-path.data", testpath/"data"
end
sleep 5
touch testpath/"files/touch"
sleep 30
assert_predicate testpath/"data/beat.db", :exist?
output = JSON.parse((testpath/"data/meta.json").read)
assert_includes output, "first_start"
end
end