ajilach / clamav-rest

ClamAV virus/malware scanner with REST API
https://hub.docker.com/r/ajilaag/clamav-rest
MIT License
40 stars 24 forks source link

Feature: Support proxy in entrypoint for freshclam #19

Open asteel-gsa opened 1 year ago

asteel-gsa commented 1 year ago

Referencing an open item we would like to modify the entrypoint.sh to pass proxy information into freshclam.conf

Files to modify: entrypoint.sh

Description: Following the pattern present in entrypoint.sh we would like to add a conditional to support an environment variable being set of $PROXY_SERVER. If the environment variables are set for $PROXY_PORT that can also be set, along with $PROXY_USERNAME and $PROXY_PASSWORD for the following items in freshclam.conf:

#HTTPProxyServer https://proxy.example.com
#HTTPProxyPort 1234
#HTTPProxyUsername myusername
#HTTPProxyPassword mypass
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
mogul commented 1 year ago

@rhermanek if you're available to review/merge the PR, we'd appreciate it! We'd rather not maintain a fork of the image if we can help it.