Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ updates:
default-days: 7
schedule:
interval: weekly
- package-ecosystem: pip
directory: /site
cooldown:
default-days: 7
schedule:
interval: weekly
78 changes: 78 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
name: pages

# Builds the docs site from the Markdown files and publishes it to GitHub Pages. A pull request
# only builds it. The release workflow starts a run, so the site serves the new get.sh.
on:
push:
branches: [main]
paths:
- README.md
- docs/guide.md
- docs/integrations/**
- rules/README.md
- site/**
- .github/workflows/pages.yml
pull_request:
paths:
- README.md
- docs/guide.md
- docs/integrations/**
- rules/README.md
- site/**
- .github/workflows/pages.yml
workflow_dispatch:

permissions: {}

concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"
- name: Install tools
run: |
python -m venv .venv
.venv/bin/pip install -r site/requirements.txt
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
# The site serves the get.sh of the latest release, not the one on main.
- name: Download the released get.sh
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir release
gh release download --dir release --pattern get.sh --pattern SHA256SUMS
(cd release && grep ' get\.sh$' SHA256SUMS | sha256sum -c -)
- name: Build
run: sh site/build.sh _site release/get.sh
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
if: github.event_name != 'pull_request'
with:
path: _site

deploy:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
id: deploy
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
contents: write
id-token: write
attestations: write
actions: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down Expand Up @@ -60,3 +61,8 @@ jobs:
run: |
gh release create "v$VERSION" dist/* --target "$GITHUB_SHA" --title "v$VERSION" \
--generate-notes
# The docs site serves the newest get.sh, so build it again.
- name: Update the docs site
env:
GH_TOKEN: ${{ github.token }}
run: gh workflow run pages.yml --ref main
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ dist/

# yamllint settings are in tests/lint.sh.
.yamllint.yml

# Pages that site/build.sh copies before it runs mkdocs.
site/.build/
2 changes: 2 additions & 0 deletions scripts/dev/ci-changes.bash
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ else
;;
tests/lint.sh)
lint=true ;;
site/*)
lint=true ;;
tests/ci/real-kernel.sh | tests/ci/container-install.sh | tests/ci/vm-run.sh)
lint=true; runtime=true ;;
tests/bats/* | tests/fixtures/*)
Expand Down
45 changes: 45 additions & 0 deletions site/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh
# Build the docs site from the Markdown files in the repo.
#
# Usage: build.sh <out-dir> [get.sh]
#
# The pages are the README, docs/guide.md, docs/integrations/, and rules/README.md. The links
# between them are rewritten for the site, and links to other repo files point to GitHub. With a
# second argument, that file is served as /get.sh.
set -eu

repo=$(CDPATH='' cd -- "$(dirname -- "$0")/.." >/dev/null && pwd)
blob=https://github.com/spydisec/auditd-kit/blob/main
tree=https://github.com/spydisec/auditd-kit/tree/main

[ $# -ge 1 ] && [ $# -le 2 ] || {
echo "usage: build.sh <out-dir> [get.sh]" >&2
exit 1
}
mkdir -p "$1"
out=$(cd "$1" && pwd)

src=$repo/site/.build
rm -rf "$src"
mkdir -p "$src/integrations"

sed -e 's|](docs/adr/)|]('"$tree"'/docs/adr)|g' \
-e 's|](docs/|](|g' \
-e 's|](rules/README\.md|](rules.md|g' \
-e 's|](\([A-Z][A-Z-]*\.md\))|]('"$blob"'/\1)|g' \
-e 's|](LICENSE)|]('"$blob"'/LICENSE)|g' \
"$repo/README.md" >"$src/index.md"

sed -e 's|](\.\./rules/README\.md|](rules.md|g' \
-e 's|](\.\./scripts/|]('"$blob"'/scripts/|g' \
-e 's|](adr/|]('"$blob"'/docs/adr/|g' \
"$repo/docs/guide.md" >"$src/guide.md"

cp "$repo/rules/README.md" "$src/rules.md"
cp "$repo"/docs/integrations/*.md "$src/integrations/"

if [ $# -eq 2 ]; then
cp "$2" "$src/get.sh"
fi

mkdocs build --strict -f "$repo/site/mkdocs.yml" -d "$out"
49 changes: 49 additions & 0 deletions site/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
# Settings for the docs site. site/build.sh copies the pages into .build/ and runs mkdocs.
site_name: auditd-kit
site_description: Install a tested set of Linux audit rules (auditd) with one command.
repo_url: https://github.com/spydisec/auditd-kit
repo_name: spydisec/auditd-kit
edit_uri: ""
docs_dir: .build
copyright: Apache-2.0

theme:
name: material
font: false
features:
- content.code.copy
- navigation.sections
- toc.follow
palette:
- media: "(prefers-color-scheme: light)"
scheme: default
toggle:
icon: material/weather-night
name: Dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
toggle:
icon: material/weather-sunny
name: Light mode

markdown_extensions:
- tables
- toc:
permalink: true
- pymdownx.highlight
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format

nav:
- Install: index.md
- Guide: guide.md
- Rules: rules.md
- Send events to a SIEM:
- Overview: integrations/send-audit-log.md
- Wazuh: integrations/wazuh.md
- Microsoft Sentinel: integrations/azure-ama.md
- syslog-ng: integrations/syslog-ng.md
2 changes: 2 additions & 0 deletions site/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Exact version pin for the docs site. Dependabot updates it.
mkdocs-material==9.8.1
9 changes: 9 additions & 0 deletions tests/bats/ci-changes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ route() {
[[ "$output" == *"runtime=false"* ]]
}

@test "docs site files select lint only" {
run route site/build.sh site/mkdocs.yml site/requirements.txt
[ "$status" -eq 0 ]
[[ "$output" == *"lint=true"* ]]
[[ "$output" == *"bats=false"* ]]
[[ "$output" == *"runtime=false"* ]]
[[ "$output" == *"packaging=false"* ]]
}

@test "YAML extensions select lint outside known directories" {
run route new/settings.yaml .github/ISSUE_TEMPLATE/bug.yml
[[ "$output" == *"lint=true"* ]]
Expand Down
Loading