deploy/Containerfile.security

main
gitbay/deploy/Containerfile.security

56 lines · 2904 bytes

 1# The image the instance's code scan runs in ([security] image in
 2# /etc/gitbay/config.toml, #340). Build it on each runner host that
 3# serves a repository with `repo security enable`, the same way as
 4# Containerfile.ci:
 5#
 6#   scp -P 2222 deploy/Containerfile.security root@gitbay.org:/var/lib/gitbay-runner/gitbay-security.Containerfile
 7#   ssh -p 2222 root@gitbay.org 'chown ci-runner /var/lib/gitbay-runner/gitbay-security.Containerfile \
 8#     && su - ci-runner -s /bin/sh -c "podman build -t localhost/gitbay-security:1 -f gitbay-security.Containerfile ." \
 9#     && rm /var/lib/gitbay-runner/gitbay-security.Containerfile'
10#
11# Everything fetched is pinned to a version and checked against a sha256
12# taken when it was pinned, so a rebuild cannot pick up a different
13# binary or rule set. Bump both together and the tag with them.
14#
15# Opengrep v1.31.0 (2026-10-15), LGPL-2.1. The rules are
16# opengrep/opengrep-rules at its last commit, a fork of semgrep-rules
17# from before that project's licence change: LGPL-2.1 with the Commons
18# Clause, which forbids selling a service whose value is the rules. An
19# instance that charges for hosting should mount its own rules at
20# /opt/opengrep-rules instead.
21FROM docker.io/library/debian:trixie-slim
22
23LABEL org.gitbay.keep=true
24
25ARG OPENGREP_VERSION=v1.31.0
26ARG OPENGREP_SHA256=dbbe3c2058dbe600c449a8ba22ea79a1643a6660658400090d0323a8d0d31147
27ARG RULES_COMMIT=f1d2b562b414783763fd02a6ed2736eaed622efa
28ARG RULES_SHA256=9a5f1cd5c625418cc1c776120123e2d4371df9bb66e099426b17c3488e13619d
29
30RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
31        ca-certificates \
32        curl \
33        git \
34    && rm -rf /var/lib/apt/lists/*
35
36RUN curl -fsSL -o /usr/local/bin/opengrep \
37        "https://github.com/opengrep/opengrep/releases/download/${OPENGREP_VERSION}/opengrep_manylinux_x86" \
38    && echo "${OPENGREP_SHA256}  /usr/local/bin/opengrep" | sha256sum -c - \
39    && chmod 0755 /usr/local/bin/opengrep
40
41# Only the language directories, and without the rules' own test inputs
42# (*.test.*, *.fixed.*), which would otherwise be read as rules or match
43# as findings.
44RUN curl -fsSL -o /tmp/rules.tar.gz \
45        "https://codeload.github.com/opengrep/opengrep-rules/tar.gz/${RULES_COMMIT}" \
46    && echo "${RULES_SHA256}  /tmp/rules.tar.gz" | sha256sum -c - \
47    && mkdir -p /opt/opengrep-rules /tmp/rules \
48    && tar -xzf /tmp/rules.tar.gz -C /tmp/rules --strip-components=1 \
49    && for d in bash c dockerfile generic go java javascript kotlin php python ruby rust swift terraform typescript yaml; do \
50           cp -r "/tmp/rules/$d" /opt/opengrep-rules/; \
51       done \
52    && find /opt/opengrep-rules -type f \( -name '*.test.*' -o -name '*.fixed.*' \) -delete \
53    && find /opt/opengrep-rules -type f ! -name '*.yaml' ! -name '*.yml' -delete \
54    && rm -rf /tmp/rules /tmp/rules.tar.gz
55
56WORKDIR /workspace