homebrew-core/Formula/auditbeat.rb

88 lines
2.9 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.4.1",
revision: "fe210d46ebc339459e363ac313b07d4a9ba78fc7"
license "Apache-2.0"
head "https://github.com/elastic/beats.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "6bec5789ae70e9b00e473a7ef4d5d0efcbe64fee0cbed82a1930d96db1b05197"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "6a27487a80100baafbe5d265c0aa465d2c563810eee022c1503a5c20f5ce7d06"
sha256 cellar: :any_skip_relocation, monterey: "67baaee31964edd255f6a9c1dc7ca3cd37853b371ff126ee62f274ff3444440e"
sha256 cellar: :any_skip_relocation, big_sur: "94dabe5e1b9653e0421af4c30a26b7682327ca86a6dc0cbc55de91555a9eed42"
sha256 cellar: :any_skip_relocation, catalina: "1941568bfeac3062a268fc149c5ae6c9ebbe42b0c4e357656dea85f05b5f3fe5"
sha256 cellar: :any_skip_relocation, x86_64_linux: "a0634a75fa07c8b55fb89cd7bdd9bf9a9cb78555b68accedaa414cc251925451"
end
depends_on "go" => :build
depends_on "mage" => :build
depends_on "python@3.10" => :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
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