Пример #1
0
def test_build_debug_logger():

    logger = build_debug_logger('test', 10, 10)

    logger.debug("TEST: debug message")
    logger.info("TEST: info message")
    logger.warning("TEST: warning message")
    logger.error("TEST: error message")
    logger.critical("TEST: critical message")
Пример #2
0
"""
CB utils.py

sqlite and enip use name (string) and pid (int) has key and the state stores values as strings.
sqlite uses float keyword and cpppo use REAL keyword.

"""
from minicps.utils import build_debug_logger

cb_logger = build_debug_logger(
    name=__name__,
    bytes_per_file=10000,
    rotating_files=2,
    lformat='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    ldir='logs/',
    suffix='')

# thresholds velocity
MOTOR_VEL_THRES = {'MIN': 1.0, 'MAX': 50.0}
MOTOR_VEL_INIT_OFF = 0.0
MOTOR_VEL_INIT_ON = 1.0
# thresholds temperature
MOTOR_TEMP_INIT = 15.0
MOTOR_TEMP_THRES = {'MIN': 8.0, 'MAX': 100.0}

NETMASK = '/24'

# PLC
PLC_MAC = '00:00:00:00:00:01'
PLC_ADDR = '10.0.0.1'
PLC_DATA = {
Пример #3
0
Switch naming convention: s2 indicates SWaT L2 network, not to
be confused with link layer.
"""

import os
import sys
import networkx as nx

from minicps.networks import PLC, HMI, DumbSwitch, Attacker
from minicps.networks import EthLink
from minicps.utils import build_debug_logger

swat_logger = build_debug_logger(
    name=__name__,
    bytes_per_file=20000,
    rotating_files=4,
    lformat='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    ldir='examples/swat/logs/',
    suffix='')

# TODO: os.system is deprecated use better commands
def init_swat():
    """ Init swat simulation environment.

    Create the db if necessary
    init the db with constant values

    Create the error directory if necessary (debug)

    """
    try:
Пример #4
0
toy utils.py

sqlite and enip use name (string) and pid (int) has key and the state stores
values as strings.

sqlite uses float keyword and cpppo use REAL keyword.

if ACTUATORX is 1 then is ON otherwise is OFF.
"""

from minicps.utils import build_debug_logger

toy_logger = build_debug_logger(
    name=__name__,
    bytes_per_file=10000,
    rotating_files=2,
    lformat='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    ldir='logs/',
    suffix='')


# others
PLC1_DATA = {
    'SENSOR1': '0',
    'SENSOR2': '0.0',
    'SENSOR3': '0',  # interlock with PLC2
    'ACTUATOR1': '1',  # 0 means OFF and 1 means ON
    'ACTUATOR2': '0',
}
PLC2_DATA = {
    'SENSOR3': '0'  # interlock with PLC1