aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmiliano Ciavatta2020-04-01 15:37:49 +0000
committerEmiliano Ciavatta2020-04-01 16:43:22 +0000
commitabfd4957925b7d9dd6d12195bd3d6366c845e9e3 (patch)
treed073e55a45931f9f2fed0e58cd1fe894180ef155
parentc2f10d25535ce9dd6e448434f1bd859e24d4f77b (diff)
Add code coverage trigger
-rw-r--r--.gitignore2
-rw-r--r--.travis.yml15
-rw-r--r--README.md3
-rw-r--r--caronte.go2
-rw-r--r--docker-compose.testing.yml6
-rw-r--r--storage_test.go2
-rwxr-xr-xtravis_tests.sh2
7 files changed, 21 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index df15af9..7991000 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@
# Build file
caronte
-
+coverage.txt \ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 801a37f..1d66f6e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,11 +6,18 @@ services:
before_script:
- docker pull eciavatta/caronte-env
+ - docker pull mongo:4
- docker-compose -f docker-compose.testing.yml up -d --build
-script:
- - docker logs -f caronte_caronte_1 | grep "travis" | (read status; if $status -eq "travis_tests_fails"; then exit 1; fi)
+script: >-
+ docker ps -a &&
+ docker logs -f $(docker ps -a -q --filter="name=caronte_caronte") | grep "travis" |
+ (read status; if [[ $status == "travis_tests_fails" ]]; then exit 1; fi)
+
+after_success:
+ - docker cp "$(docker ps -a -q --filter='name=caronte_caronte'):/caronte/coverage.txt" coverage.txt
+ - bash <(curl -s https://codecov.io/bash)
after_script:
- - docker logs caronte_caronte_1
- - docker-compose down
+ - docker logs $(docker ps -a -q --filter="name=caronte_caronte")
+ - docker-compose -f docker-compose.testing.yml down
diff --git a/README.md b/README.md
index 8180132..888b88d 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
# [WIP] Caronte
+[![Build Status](https://travis-ci.com/eciavatta/caronte.svg?branch=develop)](https://travis-ci.com/eciavatta/caronte)
+[![codecov](https://codecov.io/gh/eciavatta/caronte/branch/develop/graph/badge.svg)](https://codecov.io/gh/eciavatta/caronte)
+
<img align="left" src="https://divinacommedia.weebly.com/uploads/5/5/2/3/5523249/1299707879.jpg">
Caronte is a tool to analyze the network flow during capture the flag events of type attack/defence.
It reassembles TCP packets captured in pcap files to rebuild TCP connections, and analyzes each connection to find user-defined patterns.
diff --git a/caronte.go b/caronte.go
index 934828d..96bb281 100644
--- a/caronte.go
+++ b/caronte.go
@@ -4,7 +4,7 @@ import (
"fmt"
)
-func mainn() {
+func main() {
// testStorage()
storage := NewStorage("localhost", 27017, "testing")
err := storage.Connect(nil)
diff --git a/docker-compose.testing.yml b/docker-compose.testing.yml
index 019628c..51997d6 100644
--- a/docker-compose.testing.yml
+++ b/docker-compose.testing.yml
@@ -4,7 +4,7 @@ services:
mongo:
image: mongo:4
networks:
- - caronte-net
+ - acheronet
restart: always
caronte:
@@ -17,11 +17,11 @@ services:
depends_on:
- mongo
networks:
- - caronte-net
+ - acheronet
command: "./travis_tests.sh"
environment:
MONGO_HOST: mongo
MONGO_PORT: 27017
networks:
- caronte-net:
+ acheronet:
diff --git a/storage_test.go b/storage_test.go
index 32a10a6..6b36833 100644
--- a/storage_test.go
+++ b/storage_test.go
@@ -106,7 +106,7 @@ func TestMain(m *testing.M) {
}
mongoPort, ok := os.LookupEnv("MONGO_PORT")
if !ok {
- mongoHost = "27017"
+ mongoPort = "27017"
}
uniqueDatabaseName := sha256.Sum256([]byte(time.Now().String()))
diff --git a/travis_tests.sh b/travis_tests.sh
index cb4363c..5c51823 100755
--- a/travis_tests.sh
+++ b/travis_tests.sh
@@ -4,7 +4,7 @@
sleep 10
# run tests
-go test -v
+go test -v -race -coverprofile=coverage.txt -covermode=atomic
RET_CODE=$?