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
24 changes: 23 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: cmd/prepare
- name: Install Testrun
shell: bash {0}
run: TESTRUN_DIR=. cmd/install
run: cmd/install -l
timeout-minutes: 30
- name: Run tests
shell: bash {0}
Expand All @@ -55,6 +55,28 @@ jobs:
name: runtime_api_${{ github.run_id }}
path: runtime.tgz

testrun_unit:
permissions: {}
name: Unit
runs-on: ubuntu-20.04
timeout-minutes: 15
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install dependencies
shell: bash {0}
run: cmd/prepare
- name: Install Testrun
shell: bash {0}
run: cmd/install -l
- name: Build Testrun
shell: bash {0}
run: cmd/build
timeout-minutes: 10
- name: Run tests
shell: bash {0}
run: bash testing/unit/run.sh

pylint:
permissions: {}
name: Pylint
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ testing/unit/tls/output/
testing/unit/tls/tmp/
testing/unit/report/output/
testing/unit/risk_profile/output/
testing/unit/services/output/

*.deb
make/DEBIAN/postinst
Expand Down
6 changes: 6 additions & 0 deletions modules/test/baseline/baseline.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,11 @@ COPY $MODULE_DIR/conf /testrun/conf
# Copy over all binary files
COPY $MODULE_DIR/bin /testrun/bin

# Remove incorrect line endings
RUN dos2unix /testrun/bin/*

# Make sure all the bin files are executable
RUN chmod u+x /testrun/bin/*

# Copy over all python files
COPY $MODULE_DIR/python /testrun/python
6 changes: 6 additions & 0 deletions modules/test/conn/conn.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@ COPY $MODULE_DIR/conf /testrun/conf
# Copy over all binary files
COPY $MODULE_DIR/bin /testrun/bin

# Remove incorrect line endings
RUN dos2unix /testrun/bin/*

# Make sure all the bin files are executable
RUN chmod u+x /testrun/bin/*

# Copy over all python files
COPY $MODULE_DIR/python /testrun/python
6 changes: 6 additions & 0 deletions modules/test/dns/dns.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@ COPY $MODULE_DIR/conf /testrun/conf
# Copy over all binary files
COPY $MODULE_DIR/bin /testrun/bin

# Remove incorrect line endings
RUN dos2unix /testrun/bin/*

# Make sure all the bin files are executable
RUN chmod u+x /testrun/bin/*

# Copy over all python files
COPY $MODULE_DIR/python /testrun/python
6 changes: 6 additions & 0 deletions modules/test/ntp/ntp.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ COPY $MODULE_DIR/conf /testrun/conf
# Copy over all binary files
COPY $MODULE_DIR/bin /testrun/bin

# Remove incorrect line endings
RUN dos2unix /testrun/bin/*

# Make sure all the bin files are executable
RUN chmod u+x /testrun/bin/*

# Copy over all python files
COPY $MODULE_DIR/python /testrun/python
104 changes: 52 additions & 52 deletions modules/test/protocol/bin/start_test_module
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
#!/bin/bash
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Setup and start the connection test module
# Define where the python source files are located
PYTHON_SRC_DIR=/testrun/python/src
# Fetch module name
MODULE_NAME=$1
# Default interface should be veth0 for all containers
DEFAULT_IFACE=veth0
# Allow a user to define an interface by passing it into this script
DEFINED_IFACE=$2
# Select which interace to use
if [[ -z $DEFINED_IFACE || "$DEFINED_IFACE" == "null" ]]
then
echo "No interface defined, defaulting to veth0"
INTF=$DEFAULT_IFACE
else
INTF=$DEFINED_IFACE
fi
# Create and set permissions on the log files
LOG_FILE=/runtime/output/$MODULE_NAME.log
RESULT_FILE=/runtime/output/$MODULE_NAME-result.json
touch $LOG_FILE
touch $RESULT_FILE
chown $HOST_USER $LOG_FILE
chown $HOST_USER $RESULT_FILE
# Run the python script that will execute the tests for this module
# -u flag allows python print statements
# to be logged by docker by running unbuffered
python3 -u $PYTHON_SRC_DIR/run.py "-m $MODULE_NAME"
#!/bin/bash

# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Setup and start the connection test module

# Define where the python source files are located
PYTHON_SRC_DIR=/testrun/python/src

# Fetch module name
MODULE_NAME=$1

# Default interface should be veth0 for all containers
DEFAULT_IFACE=veth0

# Allow a user to define an interface by passing it into this script
DEFINED_IFACE=$2

# Select which interace to use
if [[ -z $DEFINED_IFACE || "$DEFINED_IFACE" == "null" ]]
then
echo "No interface defined, defaulting to veth0"
INTF=$DEFAULT_IFACE
else
INTF=$DEFINED_IFACE
fi

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

# Run the python script that will execute the tests for this module
# -u flag allows python print statements
# to be logged by docker by running unbuffered
python3 -u $PYTHON_SRC_DIR/run.py "-m $MODULE_NAME"

echo Module has finished
6 changes: 6 additions & 0 deletions modules/test/protocol/protocol.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,11 @@ COPY $MODULE_DIR/bin /testrun/bin
# Copy over all binary files
COPY $MODULE_DIR/bin /testrun/bin

# Remove incorrect line endings
RUN dos2unix /testrun/bin/*

# Make sure all the bin files are executable
RUN chmod u+x /testrun/bin/*

# Copy over all python files
COPY $MODULE_DIR/python /testrun/python
6 changes: 6 additions & 0 deletions modules/test/services/services.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@ COPY $MODULE_DIR/conf /testrun/conf
# Copy over all binary files
COPY $MODULE_DIR/bin /testrun/bin

# Remove incorrect line endings
RUN dos2unix /testrun/bin/*

# Make sure all the bin files are executable
RUN chmod u+x /testrun/bin/*

# Copy over all python files
COPY $MODULE_DIR/python /testrun/python
62 changes: 31 additions & 31 deletions modules/test/tls/bin/get_tls_client_connections.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#!/bin/bash
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CAPTURE_FILE="$1"
SRC_IP="$2"
PROTOCOL=$3
TSHARK_OUTPUT="-T json -e ip.src -e tcp.dstport -e ip.dst"
TSHARK_FILTER="ip.src == $SRC_IP and tls"
# Add a protocol filter if defined
if [ -n "$PROTOCOL" ];then
TSHARK_FILTER="$TSHARK_FILTER and $PROTOCOL"
fi
response=$(tshark -r "$CAPTURE_FILE" $TSHARK_OUTPUT $TSHARK_FILTER)
echo "$response"
#!/bin/bash

# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

CAPTURE_FILE="$1"
SRC_IP="$2"
PROTOCOL=$3

TSHARK_OUTPUT="-T json -e ip.src -e tcp.dstport -e ip.dst"
TSHARK_FILTER="ip.src == $SRC_IP and tls"

# Add a protocol filter if defined
if [ -n "$PROTOCOL" ];then
TSHARK_FILTER="$TSHARK_FILTER and $PROTOCOL"
fi

response=$(tshark -r "$CAPTURE_FILE" $TSHARK_OUTPUT $TSHARK_FILTER)

echo "$response"

1 change: 1 addition & 0 deletions modules/test/tls/python/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scapy
14 changes: 10 additions & 4 deletions modules/test/tls/tls.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,20 @@ COPY $MODULE_DIR/conf /testrun/conf
# Copy over all binary files
COPY $MODULE_DIR/bin /testrun/bin

# Remove incorrect line endings
RUN dos2unix /testrun/bin/*

# Make sure all the bin files are executable
RUN chmod u+x /testrun/bin/*

# Copy over all python files
COPY $MODULE_DIR/python /testrun/python

#Install all python requirements for the module
# Install all python requirements for the module
RUN pip3 install -r /testrun/python/requirements.txt

# Install all python requirements for the modules unit test
RUN pip3 install -r /testrun/python/requirements-test.txt

# Create a directory inside the container to store the root certificates
RUN mkdir -p /testrun/root_certs



17 changes: 0 additions & 17 deletions testing/unit/build.sh

This file was deleted.

Loading