Skip to content

Commit

Permalink
Merge pull request #1 from GSA-TTS/feature/support-proxy-for-freshclam
Browse files Browse the repository at this point in the history
Feature/support proxy for freshclam
  • Loading branch information
asteel-gsa authored May 30, 2023
2 parents 4916375 + a2d641d commit 51c2ef4
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
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
43 changes: 43 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Build and Publish ClamAV Image
on:
workflow_dispatch:
workflow_call:

env:
DOCKER_NAME: clamav-rest
IMAGE: clamav
GH_REPO: GSA-TTS/clamav-rest

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 }}
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

0 comments on commit 51c2ef4

Please sign in to comment.