-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
107 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
server.document-root = "/var/lib/clamav" | ||
server.document-root = "/var/lib/clamav/" | ||
|
||
server.port = 8080 | ||
|
||
mimetype.assign = ( | ||
".htm" => "text/html", | ||
) | ||
|
||
index-file.names = ( "index.htm" ) | ||
dir-listing.activate = "enable" | ||
dir-listing.encoding = "utf-8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,58 @@ | ||
import sys, time, os | ||
import sys, time, os, subprocess | ||
import click | ||
|
||
from shutil import copytree, rmtree | ||
|
||
from kubernetes import client, config | ||
|
||
|
||
if os.getenv('KUBERNETES_SERVICE_HOST'): | ||
config.load_incluster_config() | ||
else: | ||
config.load_kube_config() | ||
def notify(namespace, deployment): | ||
if os.getenv('KUBERNETES_SERVICE_HOST'): | ||
config.load_incluster_config() | ||
else: | ||
config.load_kube_config() | ||
|
||
|
||
apps_v1 = client.AppsV1Api() | ||
|
||
api_response = apps_v1.patch_namespaced_deployment( | ||
name=deployment, namespace=namespace, | ||
body={"spec": {"template": {"metadata": {"annotations": {"clamavSignatureUpdateTime": str(time.time())}}}}} | ||
) | ||
|
||
|
||
def scan_file(definitions, filepath): | ||
command = ["clamscan", "-d", definitions, filepath] | ||
result = subprocess.call(command) | ||
return result | ||
|
||
|
||
def test_definitions(definitions): | ||
if scan_file(definitions, "files/eicar.txt") == 1: | ||
if scan_file(definitions, "files/safe.txt") == 0: | ||
return True | ||
return False | ||
|
||
|
||
def copy_signatures(from_location, to_location): | ||
rmtree(to_location) | ||
copytree(from_location, to_location) | ||
|
||
|
||
apps_v1 = client.AppsV1Api() | ||
@click.command() | ||
@click.option('-n', '--namespace', default="default", help='The namespace of the clamav deployment') | ||
@click.option('-d', '--deployment', default="clamav", help='The name of the clamav deployment') | ||
@click.option('--test', is_flag=True, help='Should we test the virus definitions') | ||
@click.option('-f', '--movefrom', default="", help='The directory to move signatures from after testing') | ||
@click.option('-t', '--moveto', default="", help='The directory to move signatures to after testing') | ||
def main(namespace, deployment, test, movefrom, moveto): | ||
if test: | ||
if test_definitions(movefrom): | ||
copy_signatures(movefrom, moveto) | ||
else: | ||
sys.exit(1) | ||
notify(namespace, deployment) | ||
|
||
if len(sys.argv) < 3: | ||
sys.exit() | ||
|
||
api_response = apps_v1.patch_namespaced_deployment( | ||
name=sys.argv[2], namespace=sys.argv[1], | ||
body={"spec": {"template": {"metadata": {"annotations": {"clamavSignatureUpdateTime": str(time.time())}}}}} | ||
) | ||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cachetools==4.1.0 | ||
certifi==2020.4.5.1 | ||
chardet==3.0.4 | ||
click==7.1.2 | ||
google-auth==1.14.1 | ||
idna==2.9 | ||
kubernetes==11.0.0 | ||
oauthlib==3.1.0 | ||
pyasn1==0.4.8 | ||
pyasn1-modules==0.2.8 | ||
python-dateutil==2.8.1 | ||
PyYAML==5.3.1 | ||
requests==2.23.0 | ||
requests-oauthlib==1.3.0 | ||
rsa==4.0 | ||
six==1.14.0 | ||
urllib3==1.25.9 | ||
websocket-client==0.57.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
#!/bin/bash | ||
|
||
touch /var/lib/clamav/index.htm | ||
touch /var/lib/clamav/ | ||
|
||
LIGHTTPD_CONFIG="${LIGHTTPD_CONFIG:-lighttpd.conf}" | ||
|
||
freshclam -d | ||
lighttpd -t -f lighttpd.conf | ||
lighttpd -D -f lighttpd.conf | ||
lighttpd -t -f $LIGHTTPD_CONFIG | ||
lighttpd -D -f $LIGHTTPD_CONFIG |