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

clamav - adjust max filesize conditionally #4960

Merged
merged 2 commits into from
Jul 11, 2024
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
11 changes: 6 additions & 5 deletions Containers/clamav/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# syntax=docker/dockerfile:latest
# Probably from this file: https://github.com/Cisco-Talos/clamav-docker/blob/main/clamav/1.1/alpine/Dockerfile
# Probably from this file: https://github.com/Cisco-Talos/clamav-docker/blob/main/clamav/1.3/alpine/Dockerfile
FROM clamav/clamav:1.3.1-59

COPY clamav.conf /tmp/clamav.conf
COPY clamav.conf /clamav.conf
COPY --chmod=775 start.sh /start.sh

RUN set -ex; \
apk upgrade --no-cache -a; \
apk add --no-cache tzdata; \
cat /tmp/clamav.conf >> /etc/clamav/clamd.conf; \
rm /tmp/clamav.conf; \
apk add --no-cache tzdata bash; \
mkdir -p /var/run/clamav /run/lock; \
chown -R clamav:clamav /var/run/clamav /run/clamav /var/log/clamav /var/lock /run/lock; \
chmod 777 -R /var/run/clamav /run/clamav /var/log/clamav /var/lock /run/lock /tmp
Expand All @@ -18,3 +17,5 @@ VOLUME /var/lib/clamav
USER clamav

LABEL com.centurylinklabs.watchtower.enable="false"

ENTRYPOINT ["/start.sh"]
7 changes: 4 additions & 3 deletions Containers/clamav/clamav.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# AIO settings
MaxDirectoryRecursion 30
MaxFileSize 100M
PCREMaxFileSize 100M
StreamMaxLength 100M
MaxFileSize 10G
PCREMaxFileSize 10G
StreamMaxLength 10G
12 changes: 12 additions & 0 deletions Containers/clamav/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Adjust settings
cat /etc/clamav/clamd.conf > /tmp/clamd.conf
CLAMAV_FILE="$(sed "s|10G|$MAX_SIZE|" /clamav.conf)"
echo "$CLAMAV_FILE" >> /tmp/clamd.conf

# Call initial init
# shellcheck disable=SC2093
exec /init --config-file="/tmp/clamd.conf"

exec "$@"
4 changes: 2 additions & 2 deletions Containers/nextcloud/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ if [ "$CLAMAV_ENABLED" = 'yes' ]; then
php /var/www/html/occ config:app:set files_antivirus av_mode --value="daemon"
php /var/www/html/occ config:app:set files_antivirus av_port --value="3310"
php /var/www/html/occ config:app:set files_antivirus av_host --value="$CLAMAV_HOST"
php /var/www/html/occ config:app:set files_antivirus av_stream_max_length --value="104857600"
php /var/www/html/occ config:app:set files_antivirus av_max_file_size --value="104857600"
php /var/www/html/occ config:app:set files_antivirus av_stream_max_length --value="$CLAMAV_MAX_SIZE"
php /var/www/html/occ config:app:set files_antivirus av_max_file_size --value="$CLAMAV_MAX_SIZE"
php /var/www/html/occ config:app:set files_antivirus av_infected_action --value="only_log"
fi
else
Expand Down
2 changes: 2 additions & 0 deletions php/containers.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"TALK_PORT=%TALK_PORT%",
"IMAGINARY_ENABLED=%IMAGINARY_ENABLED%",
"IMAGINARY_HOST=nextcloud-aio-imaginary",
"CLAMAV_MAX_SIZE=%APACHE_MAX_SIZE%",
"PHP_UPLOAD_LIMIT=%NEXTCLOUD_UPLOAD_LIMIT%",
"PHP_MEMORY_LIMIT=%NEXTCLOUD_MEMORY_LIMIT%",
"FULLTEXTSEARCH_ENABLED=%FULLTEXTSEARCH_ENABLED%",
Expand Down Expand Up @@ -575,6 +576,7 @@
"internal_port": "3310",
"environment": [
"TZ=%TIMEZONE%",
"MAX_SIZE=%NEXTCLOUD_UPLOAD_LIMIT%",
"CLAMD_STARTUP_TIMEOUT=90"
],
"volumes": [
Expand Down