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
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()
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
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})')
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
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
def test_networml_nofiles(): sys.argv = ['bin/networkml'] netml = NetworkML()
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
def test_networkml_eval_sos(): sys.argv = ['bin/networkml', '-p', 'tests/test.pcap', '-a', 'sos'] netml = NetworkML()
def test_networkml_eval_randomforest(): sys.argv = ['bin/networkml', '-p', 'tests/', '-a', 'randomforest'] os.environ['POSEIDON_PUBLIC_SESSIONS'] = '' netml = NetworkML()
def test_networkml_eval_onelayer(): sys.argv = ['bin/networkml', '-p', 'tests/'] netml = NetworkML()
def test_networml_nofiles(): sys.argv = ['bin/networkml'] netml = NetworkML() assert netml.model.feature_list
def test_networkml_eval_onelayer(): sys.argv = ['bin/networkml', '-p', 'tests/'] netml = NetworkML() assert netml.model.feature_list
def test_smoke(): instance = NetworkML()