Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/support proxy for freshclam #1

Merged
merged 6 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
11 changes: 11 additions & 0 deletions .github/workflows/auto-build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Build Clam AV Every Week
on:
schedule:
- cron: '0 4 * * 0'

jobs:
create-docker-image:
name: Build a Docker image on Sunday at 4 am
uses: ./.github/workflows/build-image.yml
secrets: inherit
49 changes: 49 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: Build and Publish ClamAV Image
on:
workflow_dispatch:
workflow_call:

env:
DOCKER_NAME: clamav-rest
IMAGE: clamav
GH_REPO: gsa-tts/fac

jobs:
build-clamav:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Get Date
shell: bash
id: date
run: |
echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT

- name: Checkout Repository
uses: actions/checkout@v3

- name: Build Docker Image
run: docker build . -t ${{ env.DOCKER_NAME }}:${{ steps.date.outputs.date }}

- name: Tag Image
run: |
docker tag ${{ env.DOCKER_NAME }}:${{ steps.date.outputs.date }} ghcr.io/${{ env.GH_REPO }}/${{ env.IMAGE }}:${{ steps.date.outputs.date }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Image
run: docker push --all-tags ghcr.io/${{ env.GH_REPO }}/${{ env.IMAGE }}

- name: Upload Artifact
asteel-gsa marked this conversation as resolved.
Show resolved Hide resolved
uses: ishworkh/docker-image-artifact-upload@v1
with:
image: "${{ env.DOCKER_NAME }}:${{ steps.date.outputs.date }}"
retention_days: "8"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ Below is the complete list of available options that can be used to customize yo
| `PCRE_MATCHLIMIT` | Maximum PCRE Match Calls - Default `100000` |
| `PCRE_RECMATCHLIMIT` | Maximum Recursive Match Calls to PCRE - Default `2000` |
| `SIGNATURE_CHECKS` | Check times per day for a new database signature. Must be between 1 and 50. - Default `2` |
| `PROXY_SERVER` | Specify a proxy for freshclam to utilize, if applicable, set in environment variables - Optional |
| `PROXY_PORT` | The port for the proxy server, if applicable, set in environment variables - Optional |
| `PROXY_USERNAME` | The username for the proxy server, if applicable, set in environment variables - Optional |
| `PROXY_PASSWORD` | The password for the proxy server, if applicable, set in environment variables - Optional |
## Networking
Expand Down
16 changes: 16 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ sed -i 's/^#MaxPartitions .*$/MaxPartitions '"$MAX_PARTITIONS"'/g' /etc/clamav/c
sed -i 's/^#MaxIconsPE .*$/MaxIconsPE '"$MAX_ICONSPE"'/g' /etc/clamav/clamd.conf
sed -i 's/^#PCREMatchLimit.*$/PCREMatchLimit '"$PCRE_MATCHLIMIT"'/g' /etc/clamav/clamd.conf
sed -i 's/^#PCRERecMatchLimit .*$/PCRERecMatchLimit '"$PCRE_RECMATCHLIMIT"'/g' /etc/clamav/clamd.conf

if [ -n "$PROXY_SERVER" ]; then
sed -i 's~^#HTTPProxyServer .*~HTTPProxyServer '"$PROXY_SERVER"'~g' /etc/clamav/freshclam.conf

# It's not required, but if they also provided a port, then configure it
if [ -n "$PROXY_PORT" ]; then
sed -i 's/^#HTTPProxyPort .*$/HTTPProxyPort '"$PROXY_PORT"'/g' /etc/clamav/freshclam.conf
fi

# It's not required, but if they also provided a username, then configure both the username and password
if [ -n "$PROXY_USERNAME" ]; then
sed -i 's/^#HTTPProxyUsername .*$/HTTPProxyUsername '"$PROXY_USERNAME"'/g' /etc/clamav/freshclam.conf
sed -i 's~^#HTTPProxyPassword .*~HTTPProxyPassword '"$PROXY_PASSWORD"'~g' /etc/clamav/freshclam.conf
fi
fi

(
freshclam --daemon --checks=$SIGNATURE_CHECKS &
clamd &
Expand Down