From 6589980fe46d3cf254eb24ab68be5ca0b04ad4e2 Mon Sep 17 00:00:00 2001 From: Oliver Sterzel Date: Sun, 26 Jun 2016 22:55:55 +0100 Subject: [PATCH] Updated clam rest service to support additional abirt argument --- clamrest.go | 13 +++++++------ tests/features/environment.py | 7 +++++++ tests/features/steps/scanning.py | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 tests/features/environment.py diff --git a/clamrest.go b/clamrest.go index b0ff685..e3d58a7 100644 --- a/clamrest.go +++ b/clamrest.go @@ -45,13 +45,14 @@ func scanHandler(w http.ResponseWriter, r *http.Request) { } fmt.Printf(time.Now().Format(time.RFC3339) + " Started scanning: " + part.FileName() + "\n") - response, err := c.ScanStream(part); + var abort chan bool; + response, err := c.ScanStream(part, abort); for s := range response { - if strings.Contains(s, "FOUND") { - http.Error(w, s, http.StatusInternalServerError) - } else { - fmt.Fprintf(w, s) - } + if strings.Contains(s.Status, "FOUND") { + //return_string := []string{"Result: ", s.Status, ", Description: ", s.Description} + http.Error(w, "Result: " + s.Status + ", Description: " + s.Description, http.StatusInternalServerError) + } + fmt.Printf(time.Now().Format(time.RFC3339) + " Scan result for: %v, %v\n", part.FileName(), s) } fmt.Printf(time.Now().Format(time.RFC3339) + " Finished scanning: " + part.FileName() + "\n") diff --git a/tests/features/environment.py b/tests/features/environment.py new file mode 100644 index 0000000..7a37f86 --- /dev/null +++ b/tests/features/environment.py @@ -0,0 +1,7 @@ +import os + +def before_all(context): + if os.environ.get('CLAMREST_HOST'): + context.clamrest = "{}".format(os.environ.get('CLAMREST_HOST')) + else: + context.clamrest = "http://127.0.0.1:9000" diff --git a/tests/features/steps/scanning.py b/tests/features/steps/scanning.py index 4f4704c..4b414fa 100644 --- a/tests/features/steps/scanning.py +++ b/tests/features/steps/scanning.py @@ -9,7 +9,7 @@ def step_imp(context, contents): @when('I scan the file for a virus') def step_impl(context): files = { 'file': context.file_contents } - url = "http://127.0.0.1:9000" + url = context.clamrest r = requests.post(url + "/scan", files=files) context.result = r