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
3 changes: 2 additions & 1 deletion framework/python/src/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def get_module_display_name(search):
'dns': 'DNS',
'connection': 'Connection',
'nmap': 'Services',
'tls': 'TLS'
'tls': 'TLS',
'protocol': 'Protocol'
}

for module in modules.items():
Expand Down
9 changes: 8 additions & 1 deletion framework/python/src/test_orc/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,14 @@ def _load_test_modules(self):
loaded_modules = "Loaded the following test modules: "
test_modules_dir = os.path.join(self._path, TEST_MODULES_DIR)

for module_dir in os.listdir(test_modules_dir):
module_dirs = os.listdir(test_modules_dir)
# Check if the directory protocol exists and move it to the beginning
# protocol should always be run first so BACnet binding doesn't get
# corrupted during DHCP changes in the conn module
if 'protocol' in module_dirs:
module_dirs.insert(0, module_dirs.pop(module_dirs.index('protocol')))

for module_dir in module_dirs:

if self._get_test_module(module_dir) is None:
loaded_module = self._load_test_module(module_dir)
Expand Down
6 changes: 3 additions & 3 deletions modules/test/protocol/conf/module_config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"config": {
"enabled": false,
"enabled": true,
"meta": {
"name": "protocol",
"display_name": "Protocol",
Expand All @@ -17,13 +17,13 @@
"name": "protocol.valid_bacnet",
"test_description": "Can valid BACnet traffic be seen",
"expected_behavior": "BACnet traffic can be seen on the network and packets are valid and not malformed",
"required_result": "Required"
"required_result": "Recommended"
},
{
"name": "protocol.valid_modbus",
"test_description": "Can valid Modbus traffic be seen",
"expected_behavior": "Any Modbus functionality works as expected and valid modbus traffic can be observed",
"required_result": "Required",
"required_result": "Recommended",
"config":{
"port": 502,
"device_id": 1,
Expand Down
26 changes: 14 additions & 12 deletions modules/test/protocol/python/src/protocol_bacnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# 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.
"""Module run all the BACnet related methods for testing"""
"""Module to run all the BACnet related methods for testing"""

import BAC0
import logging
Expand All @@ -28,39 +28,41 @@ def __init__(self, log):
LOGGER = log

# Setup the BAC0 Log
BAC0.log_level(log_file=logging.DEBUG, stdout=logging.INFO, stderr=logging.CRITICAL)

BAC0.log_level(log_file=logging.DEBUG,
stdout=logging.INFO,
stderr=logging.CRITICAL)

self.devices = []

def discover(self, local_ip=None):
LOGGER.info("Performing BACnet discovery...")
LOGGER.info('Performing BACnet discovery...')
bacnet = BAC0.lite(local_ip)
LOGGER.info("Local BACnet object: " + str(bacnet))
LOGGER.info('Local BACnet object: ' + str(bacnet))
try:
bacnet.discover(global_broadcast=True)
except Exception as e:
LOGGER.error(e)
LOGGER.info("BACnet discovery complete")
LOGGER.info('BACnet discovery complete')
with open(BAC0_LOG,'r',encoding='utf-8') as f:
bac0_log = f.read()
LOGGER.info("BAC0 Log:\n" + bac0_log)
LOGGER.info('BAC0 Log:\n' + bac0_log)
self.devices = bacnet.devices

# Check if the device being tested is in the discovered devices list
def validate_device(self, local_ip, device_ip):
result = None
LOGGER.info("Validating BACnet device: " + device_ip)
LOGGER.info('Validating BACnet device: ' + device_ip)
self.discover(local_ip + '/24')
LOGGER.info("BACnet Devices Found: " + str(len(self.devices)))
LOGGER.info('BACnet Devices Found: ' + str(len(self.devices)))
if len(self.devices) > 0:
# Load a fail result initially and pass only
# if we can validate it's the right device responding
result = False, (
f'Could not confirm discovered BACnet device is the ' +
'Could not confirm discovered BACnet device is the ' +
'same as device being tested')
for device in self.devices:
name, vendor, address, device_id = device
LOGGER.info("Checking Device: " + str(device))
address = device[2]
LOGGER.info('Checking device: ' + str(device))
if device_ip in address:
result = True, 'Device IP matches discovered device'
break
Expand Down