Skip to content

Commit

Permalink
Merge pull request #139 from cglewis/master
Browse files Browse the repository at this point in the history
cleanup unused code
  • Loading branch information
cglewis committed Jul 17, 2018
2 parents 9cde8cc + 6709c6a commit 1fd5e3e
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 30 deletions.
3 changes: 1 addition & 2 deletions DeviceClassifier/OneLayer/eval_OneLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

from redis import StrictRedis
from poseidonml.OneLayer import OneLayerModel
from poseidonml.pcap_utils import is_private, clean_session_dict, create_inputs
from poseidonml.reader import sessionizer
from poseidonml.pcap_utils import is_private, clean_session_dict
from poseidonml.eval_SoSModel import eval_pcap

logging.basicConfig(level=logging.INFO)
Expand Down
1 change: 0 additions & 1 deletion DeviceClassifier/OneLayer/test_OneLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
logging.basicConfig(level=logging.INFO)

def calc_f1(results, ignore_unknown=False):
logger = logging.getLogger(__name__)
results_by_label = {}
for file, file_results in results.items():
if file != 'labels':
Expand Down
3 changes: 1 addition & 2 deletions DeviceClassifier/RandomForest/eval_RandomForest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

from redis import StrictRedis
from poseidonml.RandomForestModel import RandomForestModel
from poseidonml.pcap_utils import is_private, clean_session_dict, create_inputs
from poseidonml.reader import sessionizer
from poseidonml.pcap_utils import is_private, clean_session_dict
from poseidonml.eval_SoSModel import eval_pcap

logging.basicConfig(level=logging.INFO)
Expand Down
1 change: 0 additions & 1 deletion DeviceClassifier/RandomForest/test_RandomForest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
logging.basicConfig(level=logging.INFO)

def calc_f1(results, ignore_unknown=False):
logger = logging.getLogger(__name__)
results_by_label = {}
for file, file_results in results.items():
if file != 'labels':
Expand Down
5 changes: 0 additions & 5 deletions utils/OneLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ def get_features(self, filepath, source_ip=None):
full_features /= np.expand_dims(self.stds, 0)
features = full_features[:, self.feature_list]

'''
last_packet = list(binned_sessions[-1].items())[-1]
timestamp = last_packet[1][0][0]
'''

return features, source_ip, timestamps, other_ips


Expand Down
7 changes: 0 additions & 7 deletions utils/RandomForestModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@ def get_features(self, filepath, source_ip=None):
full_features /= np.expand_dims(self.stds, 0)
features = full_features[:, self.feature_list]

'''
try:
last_packet = list(binned_sessions[-1].items())[-1]
timestamp = last_packet[1][0][0]
except:
timestamp = None
'''
return features, source_ip, timestamps, other_ips


Expand Down
10 changes: 1 addition & 9 deletions utils/eval_SoSModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import sys
import json
import logging
import pickle
import numpy as np
import tensorflow as tf
from pkg_resources import working_set
from pkg_resources import Requirement
from .SoSmodel import SoSModel
from .session_sequence import create_dataset
from .session_iterator import BatchIterator
import time

logging.basicConfig(level=logging.INFO)
tf.logging.set_verbosity(tf.logging.ERROR)
Expand Down Expand Up @@ -41,7 +39,6 @@ def eval_pcap(pcap, label=None):
sessions = iterator.sessions

num_total = 0
num_abnormal = 0
max_score = 0
scores = {}
for i, X in enumerate(X_list):
Expand All @@ -57,7 +54,7 @@ def eval_pcap(pcap, label=None):
p = session['protocol']
if p == '06': p = 'TCP'
if p == '17': p = 'UDP'
if p == '01': p == 'ICMP'
if p == '01': p = 'ICMP'
flowlike = p + ' '
if session['initiated by source']:
flowlike += session['source']+' to '+session['destination']
Expand All @@ -67,11 +64,6 @@ def eval_pcap(pcap, label=None):
if s > max_score:
max_score = s

'''
print("Processed",num_total,"sessions of which",num_abnormal,"were abnormal")
with open('sos_output.json', 'w') as output_file:
json.dump(scores, output_file)
'''
return max_score

if __name__ == '__main__':
Expand Down
1 change: 0 additions & 1 deletion utils/iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pickle
import numpy as np
from sklearn.model_selection import train_test_split

class BatchIterator:
def __init__(
Expand Down
1 change: 0 additions & 1 deletion utils/session_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import numpy as np
from .RandomForestModel import RandomForestModel
from .pcap_utils import clean_session_dict
from .pcap_utils import get_source
from .pcap_utils import featurize_session

Expand Down
1 change: 0 additions & 1 deletion utils/train_SoSModel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import sys
import json
import logging
Expand Down

0 comments on commit 1fd5e3e

Please sign in to comment.