85 lines
2.9 KiB
Ruby
85 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: "v7.14.1",
|
|
revision: "703d589a09cfdbfd7f84c1d990b50b6b7f62ac29"
|
|
license "Apache-2.0"
|
|
head "https://github.com/elastic/beats.git", branch: "master"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "6a4a2e180757063cc9d05ceeb3d028402f23144c8d6b36355d5a55b213f7d58f"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "7a8d4e2261dc6bc5eba1704f9db0d7ce00b62ec97246932c4b4b0c782c78b591"
|
|
sha256 cellar: :any_skip_relocation, catalina: "8396804fb3dc8bbed8bec21517ef0cabf830e0f39c01309925bc8db6a77b370f"
|
|
sha256 cellar: :any_skip_relocation, mojave: "03c5e83df8cbe2d2a04fe4c329ed03a2f90e9ad451fc8bb05dc25734c1ef0adf"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "156496f3a7cea83cb85e14a8df6fb90752597e6ce3599402a094bd80a7985722"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "mage" => :build
|
|
depends_on "python@3.9" => :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
|
|
s = File.readlines(testpath/"auditbeat/auditbeat").last(1)[0]
|
|
assert_match(/"action":\["(initial_scan|created)"\]/, s)
|
|
realdirpath = File.realdirpath(testpath)
|
|
assert_match "\"path\":\"#{realdirpath}/files/touch\"", s
|
|
end
|
|
end
|