92 lines
3.0 KiB
Ruby
92 lines
3.0 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
|
|
rebuild 1
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "8f80abd7b8f6793d0cd9dc3a4444a0b5bf9ba3ecad20bacd31c8c29aeabfda08"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "e7a3084cecae1c35ad11667818c86f21dfca31f66ce45b7a3b188017ef19aed8"
|
|
sha256 cellar: :any_skip_relocation, monterey: "0ecb1aded614c152e534b802dd6f78f765eb96b98964af5fdca61c8a0c12283a"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "b711dc4e7f59b3e3e1a3286771e7a06a1de97e9e9acfead6c71e139578c1f795"
|
|
sha256 cellar: :any_skip_relocation, catalina: "1ea5410286cd83d44b45af20b615c3f583878c507347d9c249e16c9d93beb0b1"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "0365bcf73dbc297ee1e76fe8497c40f869b01dc25403e749bd928aa8a37980ae"
|
|
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
|
|
|
|
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
|