Skip to content

Commit

Permalink
feat(container): Add a basic container image
Browse files Browse the repository at this point in the history
This patch introduces a basic container image as Dockerfile and build
workflow via GitHub Actions. The container image is automatically built
on tags and pushed to ghcr.io.
  • Loading branch information
Henrik Busch authored and hillu committed Apr 29, 2023
1 parent 2678b17 commit a129436
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
tags:
- "v*"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
prep:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -60,6 +64,12 @@ jobs:
asset_path: laurel.tar.gz
asset_name: laurel-${{ needs.prep.outputs.git_version }}-x86_64-musl.tar.gz
asset_content_type: application/tar
# Use tar to keep permissions
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.2
with:
name: laurel
path: laurel.tar.gz

build-glibc:
needs: prep
Expand Down Expand Up @@ -104,3 +114,87 @@ jobs:
asset_path: laurel.tar.gz
asset_name: laurel-${{ needs.prep.outputs.git_version }}-x86_64-glibc.tar.gz
asset_content_type: application/tar

build-container-image:
needs: build-musl
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Download a Build Artifact
uses: actions/download-artifact@v2.1.1
with:
name: laurel
path: .

# use tar to keep permissions
- name: Unpack Build Artifact
run: tar -xzf laurel.tar.gz

- name: Edit configuration
run: |
sed -e 's#^input = .*#input = "unix:/var/run/audispd_events"#' etc/laurel/config.toml
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
with:
cosign-release: 'v1.13.1'

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM gcr.io/distroless/static-debian11

COPY laurel /usr/bin/laurel
COPY etc/laurel/config.toml /etc/laurel/config.toml
ENTRYPOINT ["/usr/bin/laurel"]
CMD ["--config", "/etc/laurel/config.toml"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ The [_LAUREL_ installation instructions](INSTALL.md) contain instructions on how

We developed _LAUREL_ because we were not content with feature sets and performance characteristics of existing projects and products. Please refer to the [Performance](performance.md) document for details.

## Container Image

From v0.5.2 on laurel is able to connect to a socket for forwarded auditd messages and can be executed in a container this way. A basic container image is published in this repository to `ghcr.io/threathunters-io/laurel` with tags `latest` and the respective version tag.

The provided container image build includes default labels via docker buildx from the pipeline. These labels are not included in the provided Dockerfile but are considered good practice. If you use a custom build with another tooling, consider adding the default labels to the Dockerfile.

The provided container image contains the default configuration, with one modification: Laurel connects to `/var/run/audispd_events` (the default path specified for the `builtin_af_unix` _auditd(8)_ plug-in. The plug-in needs to be enabled and the socket must be accessible from within the container. The rest of the configuration file should be customized as needed before deploying.

## License

GNU General Public License, version 3
Expand Down

0 comments on commit a129436

Please sign in to comment.