Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions net_orc/network/devices/faux-dev/bin/start_network_service
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ else
fi

#Create and set permissions on the output files
LOG_FILE=/runtime/validation/$MODULE_NAME.log
RESULT_FILE=/runtime/validation/result.json
OUTPUT_DIR=/runtime/validation/
LOG_FILE=$OUTPUT_DIR/$MODULE_NAME.log
RESULT_FILE=$OUTPUT_DIR/result.json
touch $LOG_FILE
touch $RESULT_FILE
chown $HOST_USER:$HOST_USER $LOG_FILE
chown $HOST_USER:$HOST_USER $RESULT_FILE
chown -R $HOST_USER:$HOST_USER $OUTPUT_DIR

# Start dhclient
$BIN_DIR/start_dhcp_client $INTF
Expand Down
13 changes: 9 additions & 4 deletions net_orc/python/src/network_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def start(self):
"""Start the network orchestrator."""

LOGGER.debug('Starting network orchestrator')

self._host_user = self._get_host_user()

# Get all components ready
self.load_network_modules()

Expand Down Expand Up @@ -174,10 +177,12 @@ def _device_discovered(self, mac_addr):
LOGGER.debug(
f'Discovered device {mac_addr}. Waiting for device to obtain IP')
device = self._get_device(mac_addr=mac_addr)
os.makedirs(
os.path.join(RUNTIME_DIR,

device_runtime_dir = os.path.join(RUNTIME_DIR,
TEST_DIR,
device.mac_addr.replace(':', '')))
device.mac_addr.replace(':', ''))
os.makedirs(device_runtime_dir)
util.run_command(f'chown -R {self._host_user}:{self._host_user} {device_runtime_dir}')

packet_capture = sniff(iface=self._dev_intf,
timeout=self._startup_timeout,
Expand Down Expand Up @@ -469,7 +474,7 @@ def _start_network_service(self, net_module):
privileged=True,
detach=True,
mounts=net_module.mounts,
environment={'HOST_USER': self._get_host_user()})
environment={'HOST_USER': self._host_user})
except docker.errors.ContainerError as error:
LOGGER.error('Container run error')
LOGGER.error(error)
Expand Down
6 changes: 6 additions & 0 deletions net_orc/python/src/network_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def __init__(self):
def start(self):
"""Start the network validator."""
LOGGER.debug('Starting validator')

# Setup the output directory
host_user = self._get_host_user()
os.makedirs(OUTPUT_DIR, exist_ok=True)
util.run_command(f'chown -R {host_user}:{host_user} {OUTPUT_DIR}')

self._load_devices()
self._build_network_devices()
self._start_network_devices()
Expand Down
6 changes: 6 additions & 0 deletions test_orc/modules/base/bin/start_module
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# Define the local mount point to store local files to
OUTPUT_DIR="/runtime/output"

# Directory where all binaries will be loaded
BIN_DIR="/testrun/bin"

Expand All @@ -11,6 +14,9 @@ IFACE=veth0
# HOST_USER mapped in via docker container environemnt variables
useradd $HOST_USER

# Set permissions on the output files
chown -R $HOST_USER:$HOST_USER $OUTPUT_DIR

# Enable IPv6 for all containers
sysctl net.ipv6.conf.all.disable_ipv6=0
sysctl -p
Expand Down
8 changes: 4 additions & 4 deletions test_orc/modules/dns/python/src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from dns_module import DNSModule

LOG_NAME = "dns_module"
LOG_NAME = "dns_runner"
LOGGER = logger.get_logger(LOG_NAME)
RUNTIME = 1500

Expand All @@ -35,12 +35,12 @@ def __init__(self, module):
signal.signal(signal.SIGQUIT, self._handler)
self.add_logger(module)

LOGGER.info("Starting DNS Test Module")
LOGGER.info("Starting DNS test module")

self._test_module = DNSModule(module)
self._test_module.run_tests()

LOGGER.info("DNS Test Module Finished")
LOGGER.info("DNS test module finished")

def add_logger(self, module):
global LOGGER
Expand All @@ -57,7 +57,7 @@ def _handler(self, signum):

def run():
parser = argparse.ArgumentParser(
description="Test Module DNS",
description="DNS Module Help",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument(
Expand Down
13 changes: 10 additions & 3 deletions test_orc/modules/nmap/python/src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

from nmap_module import NmapModule

LOGGER = logger.get_logger('test_module')

LOG_NAME = "nmap_runner"
LOGGER = logger.get_logger(LOG_NAME)

class NmapModuleRunner:
"""Run the NMAP module tests."""
Expand All @@ -32,12 +32,19 @@ def __init__(self, module):
signal.signal(signal.SIGTERM, self._handler)
signal.signal(signal.SIGABRT, self._handler)
signal.signal(signal.SIGQUIT, self._handler)
self.add_logger(module)

LOGGER.info('Starting nmap Module')
LOGGER.info('Starting nmap module')

self._test_module = NmapModule(module)
self._test_module.run_tests()

LOGGER.info("nmap test module finished")

def add_logger(self, module):
global LOGGER
LOGGER = logger.get_logger(LOG_NAME, module)

def _handler(self, signum):
LOGGER.debug('SigtermEnum: ' + str(signal.SIGTERM))
LOGGER.debug('Exit signal received: ' + str(signum))
Expand Down
16 changes: 12 additions & 4 deletions test_orc/python/src/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
from docker.types import Mount
import logger
from module import TestModule
import util

LOG_NAME = "test_orc"
LOGGER = logger.get_logger("test_orc")
RUNTIME_DIR = "runtime"
RUNTIME_DIR = "runtime/test"
TEST_MODULES_DIR = "modules"
MODULE_CONFIG = "conf/module_config.json"

Expand All @@ -47,10 +48,15 @@ def __init__(self, net_orc):

shutil.rmtree(os.path.join(self._root_path, RUNTIME_DIR),
ignore_errors=True)
os.makedirs(os.path.join(self._root_path, RUNTIME_DIR), exist_ok=True)

def start(self):
LOGGER.debug("Starting test orchestrator")

# Setup the output directory
self._host_user = self._get_host_user()
os.makedirs(RUNTIME_DIR, exist_ok=True)
util.run_command(f'chown -R {self._host_user}:{self._host_user} {RUNTIME_DIR}')

self._load_test_modules()
self.build_test_modules()

Expand Down Expand Up @@ -101,6 +107,7 @@ def _generate_results(self, device):
"runtime/test/" + device.mac_addr.replace(":", "") + "/results.json")
with open(out_file, "w", encoding="utf-8") as f:
json.dump(results, f, indent=2)
util.run_command(f'chown -R {self._host_user}:{self._host_user} {out_file}')
return results

def test_in_progress(self):
Expand Down Expand Up @@ -136,11 +143,12 @@ def _run_test_module(self, module, device):
device_startup_capture = os.path.join(
self._root_path, "runtime/test/" + device.mac_addr.replace(":", "") +
"/startup.pcap")
util.run_command(f'chown -R {self._host_user}:{self._host_user} {device_startup_capture}')

device_monitor_capture = os.path.join(
self._root_path, "runtime/test/" + device.mac_addr.replace(":", "") +
"/monitor.pcap")

util.run_command(f'chown -R {self._host_user}:{self._host_user} {device_monitor_capture}')

client = docker.from_env()

Expand Down Expand Up @@ -170,7 +178,7 @@ def _run_test_module(self, module, device):
read_only=True),
],
environment={
"HOST_USER": self._get_host_user(),
"HOST_USER": self._host_user,
"DEVICE_MAC": device.mac_addr,
"DEVICE_TEST_MODULES": device.test_modules,
"IPV4_SUBNET": self._net_orc.network_config.ipv4_network,
Expand Down