예제 #1
0
def test_networkml_train_sos():
    sys.argv = [
        'bin/networkml', '-p', 'tests/', '-o', 'train', '-a', 'sos', '-m',
        'networkml/trained_models/sos/SoSmodel'
    ]
    netml = NetworkML()
    assert not netml.model.feature_list
예제 #2
0
def test_networkml_test_randomforest():
    sys.argv = [
        'bin/networkml', '-p', 'tests/', '-o', 'test', '-a', 'randomforest',
        '-m', 'networkml/trained_models/randomforest/RandomForestModel.pkl'
    ]
    os.environ['POSEIDON_PUBLIC_SESSIONS'] = ''
    netml = NetworkML()
예제 #3
0
def test_networkml_eval_sos():
    sys.argv = [
        'bin/networkml', '-p',
        'tests/trace_ab12_2001-01-01_02_03-client-ip-1-2-3-4.pcap', '-a', 'sos'
    ]
    netml = NetworkML()
    assert netml.model.feature_list
예제 #4
0
def main():
    from networkml.NetworkML import NetworkML
    start = time.time()
    NetworkML()
    end = time.time()
    elapsed = end - start
    human_elapsed = humanize.naturaldelta(datetime.timedelta(seconds=elapsed))
    logging.info(f'Elapsed Time: {elapsed} seconds ({human_elapsed})')
예제 #5
0
def test_networkml_train_randomforest():
    sys.argv = [
        'bin/networkml', '-p', 'tests/', '-o', 'train', '-a', 'randomforest',
        '-m', 'networkml/trained_models/randomforest/RandomForestModel.pkl'
    ]
    os.environ['POSEIDON_PUBLIC_SESSIONS'] = ''
    with pytest.raises(SystemExit) as pytest_wrapped_e:
        netml = NetworkML()
    assert pytest_wrapped_e.type == SystemExit
    assert pytest_wrapped_e.value.code == 1
예제 #6
0
def run_networkml(args,
                  expected_code=0,
                  savew=None,
                  model='networkml/trained_models/onelayer/OneLayerModel.pkl',
                  sos_model='networkml/trained_models/sos/SoSmodel'):
    with tempfile.TemporaryDirectory() as tempdir:
        if model:
            test_model = copy_model(model, tempdir)
            args.extend(['-m', test_model])
        if sos_model:
            test_model = copy_model(sos_model, tempdir)
            args.extend(['-s', test_model])
        if savew is not None:
            args.extend(['-w', savew])
        sys.argv = ['bin/networkml'] + args
        if expected_code:
            with pytest.raises(SystemExit) as pytest_wrapped_e:
                netml = NetworkML()
                assert pytest_wrapped_e.type == SystemExit
                assert pytest_wrapped_e.value.code == expected_code
                return netml
        else:
            netml = NetworkML()
            return netml
예제 #7
0
def test_networml_nofiles():
    sys.argv = ['bin/networkml']
    netml = NetworkML()
예제 #8
0
def test_networkml_test_onelayer():
    sys.argv = ['bin/networkml', '-p', 'tests/', '-o', 'test']
    with pytest.raises(SystemExit) as pytest_wrapped_e:
        netml = NetworkML()
    assert pytest_wrapped_e.type == SystemExit
    assert pytest_wrapped_e.value.code == 1
예제 #9
0
def test_networkml_eval_sos():
    sys.argv = ['bin/networkml', '-p', 'tests/test.pcap', '-a', 'sos']
    netml = NetworkML()
예제 #10
0
def test_networkml_eval_randomforest():
    sys.argv = ['bin/networkml', '-p', 'tests/', '-a', 'randomforest']
    os.environ['POSEIDON_PUBLIC_SESSIONS'] = ''
    netml = NetworkML()
예제 #11
0
def test_networkml_eval_onelayer():
    sys.argv = ['bin/networkml', '-p', 'tests/']
    netml = NetworkML()
예제 #12
0
def test_networml_nofiles():
    sys.argv = ['bin/networkml']
    netml = NetworkML()
    assert netml.model.feature_list
예제 #13
0
def test_networkml_eval_onelayer():
    sys.argv = ['bin/networkml', '-p', 'tests/']
    netml = NetworkML()
    assert netml.model.feature_list
예제 #14
0
def test_smoke():
    instance = NetworkML()