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

Translate local RC feeds (exabgp/hist) into ARTEMIS configuration primitives #254

Merged
merged 47 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
15729c7
step 1: instruct exabgp monitor to send updates also in autoconf exch…
vkotronis Oct 14, 2019
b4402d5
Step 2: exchange, queue, consumer and handler placeholder in configur…
vkotronis Oct 14, 2019
1e3926e
Step 3: workflow for bgp update to conf translation + translation pla…
vkotronis Oct 14, 2019
6f559d3
Step 4: draft of bgp update to pref, asn(s), rule translator
vkotronis Oct 14, 2019
8f7e23f
Added support from learning from past BGP updates
vkotronis Oct 21, 2019
888dabe
if existing rule found, do nothing
vkotronis Oct 22, 2019
2544dcf
ignore autoconf updates that you have seen before, exactly the same
vkotronis Oct 22, 2019
14923f4
use communities to get neighbor info
vkotronis Oct 22, 2019
7c57557
being robust to missing conf file sections
vkotronis Oct 22, 2019
bd4eb52
making conf parse robust against missing sections, monitors see /0 ::…
vkotronis Oct 22, 2019
35cf186
simplifying complex translation (dict to conf) method
vkotronis Oct 22, 2019
fff2f1c
making autoconf request RPC (hist, conf)
vkotronis Oct 22, 2019
9ae4c71
bgpstreamhist class, exabgp RPC, conf withdrawal autoconf
vkotronis Oct 23, 2019
66fa85d
added autoconf tester placeholder
vkotronis Oct 25, 2019
b19176a
sending autoconf updates in autoconf tester
vkotronis Oct 25, 2019
7d0fae3
sample autoconf tester testfiles and msg send logic
vkotronis Oct 25, 2019
175519d
framework for receiving conf while autoconf update is processed
vkotronis Oct 25, 2019
adc0223
fixes in autoconf-tester dockerfile and entrypoint
vkotronis Oct 25, 2019
7edbe53
deactivating conf check until further notice
vkotronis Oct 25, 2019
6c09650
added supervisor control in autoconf tester
vkotronis Oct 25, 2019
e2bc45c
correct exchange+queue placement (config), nested consumers
vkotronis Oct 25, 2019
c860a41
successful autoconf tests (automated), need also to check list rules
vkotronis Oct 25, 2019
12b0bdb
full tests, parallel coveralls pending
vkotronis Oct 25, 2019
c6887dd
parallel coveralls
vkotronis Oct 25, 2019
d5938cc
correct volume and commands for entrypoints
vkotronis Oct 25, 2019
ff0e4ce
correct params in backend container for autoconf tester
vkotronis Oct 25, 2019
438caa2
protecting new conf code with exceptions, plus correct coveralls para…
vkotronis Oct 26, 2019
8843d2d
do not cover listerner, observer and scheduler (no need) in parallel …
vkotronis Oct 26, 2019
94fd7dd
correct (as in backend testing) autotester supervisor service conf
vkotronis Oct 26, 2019
1e60678
corrected autoconf behavior in exabgp, bgpstreamhist, fixed bug with …
vkotronis Oct 26, 2019
4cee105
coveragerc in autoconf-tester
vkotronis Oct 26, 2019
3abe9db
minor: neighbors != origins in autoconf
vkotronis Oct 30, 2019
0b40f7f
autoconf-config.yaml config
vkotronis Oct 30, 2019
0ca7759
removed coveralls from autoconf tester
vkotronis Nov 2, 2019
a18c6dc
merge with master
vkotronis Nov 2, 2019
51aca2d
fixed autoconf tester compose, added test entrypoint
vkotronis Nov 2, 2019
892d536
minor renaming
vkotronis Nov 2, 2019
7d056d9
autoconf tester in travis
vkotronis Nov 2, 2019
eeae324
Merge branch 'master' into exabgp-auto-conf
slowr Nov 3, 2019
9045ffc
Merge branch 'master' into exabgp-auto-conf
vkotronis Nov 4, 2019
f2e17b7
Merge branch 'exabgp-auto-conf' of github.com:FORTH-ICS-INSPIRE/artem…
vkotronis Nov 4, 2019
9ccce61
changing tester structure
vkotronis Nov 4, 2019
40ca2a8
fixing missing tester files
vkotronis Nov 4, 2019
848e68a
correcting Dockerfile error
vkotronis Nov 4, 2019
ce320f1
wait-fors need to be inside docker folders
vkotronis Nov 4, 2019
0ce46e6
minor
vkotronis Nov 4, 2019
040aafd
corrected wait-for locations
vkotronis Nov 4, 2019
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
21 changes: 17 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,29 @@ jobs:
- docker tag inspiregroup/artemis-monitor:${DOCKER_TAG} artemis_monitor:latest
script:
- docker-compose -f docker-compose.testcafe.yaml up --abort-on-container-exit
- name: BackendTest
- name: TestDetection
install:
- pip install codecov
before_script:
- docker pull inspiregroup/artemis-backend:${DOCKER_TAG}
- docker tag inspiregroup/artemis-backend:${DOCKER_TAG} artemis_backend:latest
- docker build -t artemis_testing tester
- docker-compose -f docker-compose.testbackend.yaml up -d
- docker build -t artemis_detection_testing tester/detection
- docker-compose -f docker-compose.testdetection.yaml up -d
script:
- docker run --rm -ti --env-file .env --network artemis_artemis artemis_testing
- docker run --rm -ti --env-file .env --network artemis_artemis artemis_detection_testing
after_success:
- sh convert_coverage.sh
- codecov
- name: TestAutoconf
install:
- pip install codecov
before_script:
- docker pull inspiregroup/artemis-backend:${DOCKER_TAG}
- docker tag inspiregroup/artemis-backend:${DOCKER_TAG} artemis_backend:latest
- docker build -t artemis_autoconf_testing tester/autoconf
- docker-compose -f docker-compose.testautoconf.yaml up -d
script:
- docker run --rm -ti --env-file .env --network artemis_artemis artemis_autoconf_testing
after_success:
- sh convert_coverage.sh
- codecov
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- Artemis::BGP Updates per prefix
- Artemis::BGP Updates per service
- Artemis::Offending ASes
- Get prefix, origin and neighbor info (communities) from exaBGP or hist 'A'/'W' updates
- autoconf flag in configuration for exaBGP and hist monitors
- autoconf tester
- ENV variable WITHDRAWN_HIJACK_THRESHOLD to consider hijacks withdrawn based on a threshold
- TravisCI and CodeCov support

Expand All @@ -22,7 +25,7 @@
- TBD (removed a feature)

### Deprecated
- TBD (soon-to-be removed feature)
- SemaphoreCI and coveralls

### Security
- TBD (addressing vulnerability)
Expand Down
14 changes: 14 additions & 0 deletions backend/configs/autoconf-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prefixes: {}
monitors:
riperis: [''] # by default this uses all available monitors
bgpstreamlive:
- routeviews
- ris
betabmp:
- betabmp
exabgp:
- ip: exabgp # this will automatically be resolved to the exabgp container's IP
port: 5000 # default port
autoconf: "true"
asns: {}
rules: []
515 changes: 464 additions & 51 deletions backend/core/configuration.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/core/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def config_request_rpc(self):
queues=[callback_queue],
no_ack=True,
):
while not self.rules:
while self.rules is None:
vkotronis marked this conversation as resolved.
Show resolved Hide resolved
self.connection.drain_events()

def handle_bgp_update(self, message):
Expand Down
2 changes: 1 addition & 1 deletion backend/core/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def config_request_rpc(self) -> NoReturn:
queues=[callback_queue],
no_ack=True,
):
while not self.rules:
while self.rules is None:
vkotronis marked this conversation as resolved.
Show resolved Hide resolved
self.connection.drain_events()
log.debug("{}".format(self.rules))

Expand Down
2 changes: 1 addition & 1 deletion backend/core/mitigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def config_request_rpc(self):
queues=[callback_queue],
no_ack=True,
):
while not self.rules:
while self.rules is None:
vkotronis marked this conversation as resolved.
Show resolved Hide resolved
self.connection.drain_events()

def handle_config_request_reply(self, message):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ services:
HIJACK_LOG_FIELDS: ${HIJACK_LOG_FIELDS}
WITHDRAWN_HIJACK_THRESHOLD: ${WITHDRAWN_HIJACK_THRESHOLD}
volumes:
- ./tester/configs/:/etc/artemis/
- ./tester/supervisor.d/:/etc/supervisor/conf.d/
- ./tester/autoconf/configs/:/etc/artemis/
- ./tester/autoconf/supervisor.d/:/etc/supervisor/conf.d/
- ./tester/entrypoint.test:/root/entrypoint
- ./tester/.coveragerc:/root/core/.coveragerc
rabbitmq:
Expand All @@ -49,7 +49,7 @@ services:
expose:
- ${RABBITMQ_PORT}
volumes:
- ./tester/rabbitmq/enabled-plugins:/etc/rabbitmq/enabled_plugins
- ./other/rabbitmq/enabled-plugins:/etc/rabbitmq/enabled_plugins
postgres:
image: timescale/timescaledb:1.1.0-pg10
container_name: postgres
Expand All @@ -63,9 +63,9 @@ services:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASS}
volumes:
- ./tester/db/init.sql:/docker-entrypoint-initdb.d/zinit.sql
- ./tester/db/data/:/docker-entrypoint-initdb.d/data/
- ./tester/db/libs/:/docker-entrypoint-initdb.d/libs/
- ./other/db/init.sql:/docker-entrypoint-initdb.d/zinit.sql
- ./other/db/data/:/docker-entrypoint-initdb.d/data/
- ./other/db/libs/:/docker-entrypoint-initdb.d/libs/
pg-amqp-bridge:
image: subzerocloud/pg-amqp-bridge:0.0.6
container_name: pg-amqp-bridge
Expand All @@ -80,7 +80,7 @@ services:
- AMQP_URI=amqp://${RABBITMQ_HOST}//
- BRIDGE_CHANNELS=events:amq.direct
volumes:
- ./tester/wait-for:/root/wait-for
- ./backend/wait-for:/root/wait-for
command: ["/root/wait-for", "${RABBITMQ_HOST}:${RABBITMQ_PORT}", "-t", "0", "--", "pg-amqp-bridge"]

networks:
Expand Down
87 changes: 87 additions & 0 deletions docker-compose.testdetection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
version: '3'
services:
backend:
image: artemis_backend
build: ./backend/
container_name: backend
depends_on:
- rabbitmq
- postgres
networks:
- artemis
expose:
- ${BACKEND_SUPERVISOR_PORT}
- ${REDIS_PORT}
environment:
ARTEMIS_WEB_HOST: ${ARTEMIS_WEB_HOST}
RABBITMQ_USER: ${RABBITMQ_USER}
RABBITMQ_PASS: ${RABBITMQ_PASS}
RABBITMQ_HOST: ${RABBITMQ_HOST}
RABBITMQ_PORT: ${RABBITMQ_PORT}
DB_USER: ${DB_USER}
DB_PASS: ${DB_PASS}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
DB_NAME: ${DB_NAME}
DB_VERSION: ${DB_VERSION}
REDIS_HOST: ${REDIS_HOST}
REDIS_PORT: ${REDIS_PORT}
BACKEND_SUPERVISOR_HOST: ${BACKEND_SUPERVISOR_HOST}
BACKEND_SUPERVISOR_PORT: ${BACKEND_SUPERVISOR_PORT}
GUI_ENABLED: "false"
BULK_TIMER: 0.1
PULL_REQUEST_NUMBER: ${PULL_REQUEST_NUMBER}
HIJACK_LOG_FILTER: ${HIJACK_LOG_FILTER}
MON_TIMEOUT_LAST_BGP_UPDATE: ${MON_TIMEOUT_LAST_BGP_UPDATE}
HIJACK_LOG_FIELDS: ${HIJACK_LOG_FIELDS}
WITHDRAWN_HIJACK_THRESHOLD: ${WITHDRAWN_HIJACK_THRESHOLD}
volumes:
- ./tester/detection/configs/:/etc/artemis/
- ./tester/detection/supervisor.d/:/etc/supervisor/conf.d/
- ./tester/entrypoint.test:/root/entrypoint
- ./tester/.coveragerc:/root/core/.coveragerc
rabbitmq:
image: rabbitmq:3.7.8-management-alpine
container_name: rabbitmq
restart: always
networks:
- artemis
expose:
- ${RABBITMQ_PORT}
volumes:
- ./tester/detection/rabbitmq/enabled-plugins:/etc/rabbitmq/enabled_plugins
postgres:
image: timescale/timescaledb:1.1.0-pg10
container_name: postgres
restart: always
networks:
- artemis
expose:
- ${DB_PORT}
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASS}
volumes:
- ./tester/detection/db/init.sql:/docker-entrypoint-initdb.d/zinit.sql
- ./tester/detection/db/data/:/docker-entrypoint-initdb.d/data/
- ./tester/detection/db/libs/:/docker-entrypoint-initdb.d/libs/
pg-amqp-bridge:
image: subzerocloud/pg-amqp-bridge:0.0.6
container_name: pg-amqp-bridge
depends_on:
- postgres
- backend
- rabbitmq
networks:
- artemis
environment:
- POSTGRESQL_URI=postgres://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}
- AMQP_URI=amqp://${RABBITMQ_HOST}//
- BRIDGE_CHANNELS=events:amq.direct
volumes:
- ./backend/wait-for:/root/wait-for
command: ["/root/wait-for", "${RABBITMQ_HOST}:${RABBITMQ_PORT}", "-t", "0", "--", "pg-amqp-bridge"]

networks:
artemis:
4 changes: 2 additions & 2 deletions frontend/webapp/core/fetch_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ def get_prefixes_list(self):
return []

prefixes_list = []
for rule in self.config_yaml["rules"]:
for rule in self.config_yaml.get("rules", []):
rule["prefixes"] = flatten(rule["prefixes"])
for prefix in rule["prefixes"]:
if prefix not in prefixes_list:
prefixes_list.append(prefix)
return prefixes_list

def get_rules_list(self):
return self.config_yaml["rules"]
return self.config_yaml.get("rules", [])

def get_raw_response(self):
return self.raw_json
Expand Down
46 changes: 24 additions & 22 deletions monitor/core/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,17 @@ def init_exabgp_instance(self):
exabgp_monitor_str = "{}:{}".format(
exabgp_monitor["ip"], exabgp_monitor["port"]
)
p = Popen(
[
"/usr/local/bin/python3",
"taps/exabgp_client.py",
"--prefixes",
self.prefix_file,
"--host",
exabgp_monitor_str,
],
shell=False,
)
exabgp_cmd = [
"/usr/local/bin/python3",
"taps/exabgp_client.py",
"--prefixes",
self.prefix_file,
"--host",
exabgp_monitor_str,
]
if "autoconf" in exabgp_monitor:
exabgp_cmd.append("-a")
p = Popen(exabgp_cmd, shell=False)
self.process_ids.append(
(
"[exabgp] {} {}".format(
Expand All @@ -367,17 +367,19 @@ def init_bgpstreamhist_instance(self):
)
)
bgpstreamhist_dir = self.monitors["bgpstreamhist"]
p = Popen(
[
"/usr/local/bin/python3",
"taps/bgpstreamhist.py",
"--prefixes",
self.prefix_file,
"--dir",
bgpstreamhist_dir,
],
shell=False,
)
if "dir" in self.monitors["bgpstreamhist"]:
bgpstreamhist_dir = self.monitors["bgpstreamhist"]["dir"]
bgpstreamhist_cmd = [
"/usr/local/bin/python3",
"taps/bgpstreamhist.py",
"--prefixes",
self.prefix_file,
"--dir",
bgpstreamhist_dir,
]
if "autoconf" in self.monitors["bgpstreamhist"]:
bgpstreamhist_cmd.append("-a")
p = Popen(bgpstreamhist_cmd, shell=False)
self.process_ids.append(
(
"[bgpstreamhist] {} {}".format(
Expand Down
1 change: 1 addition & 0 deletions monitor/core/taps/betabmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def run_bgpstream_beta_bmp(prefixes_file=None):
)
else:
log.warning("Invalid format message: {}".format(msg))
break
try:
elem = rec.get_next_elem()
except BaseException:
Expand Down
Loading