-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from TomAugspurger/cyberpandas
Added cyberpandas support
- Loading branch information
Showing
8 changed files
with
51 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ requirements: | |
- intake | ||
- python | ||
- pandas | ||
- cyberpandas | ||
- dask | ||
- pcapy | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
intake | ||
pandas | ||
cyberpandas | ||
dask | ||
libpcap | ||
pcapy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
from .utils import dataframe_has_required_columns | ||
from .utils import assert_dataframe_has_required_columns | ||
|
||
|
||
def test_offline_unfiltered(ping_stream): | ||
df = ping_stream.to_dataframe() | ||
assert dataframe_has_required_columns(df, payload=False) | ||
assert_dataframe_has_required_columns(df, payload=False) | ||
assert len(df) == 96 | ||
|
||
|
||
def test_offline_filter_tcp(http_stream): | ||
http_stream.set_filter("tcp") | ||
df = http_stream.to_dataframe() | ||
assert dataframe_has_required_columns(df, payload=False) | ||
assert_dataframe_has_required_columns(df, payload=False) | ||
assert len(df) == 41 | ||
|
||
|
||
def test_offline_filter_udp(http_stream): | ||
http_stream.set_filter("udp") | ||
df = http_stream.to_dataframe() | ||
assert dataframe_has_required_columns(df, payload=False) | ||
assert_dataframe_has_required_columns(df, payload=False) | ||
assert len(df) == 2 | ||
|
||
|
||
def test_offline_filter_icmp(http_stream): | ||
http_stream.set_filter("icmp") | ||
df = http_stream.to_dataframe() | ||
assert dataframe_has_required_columns(df, payload=False) | ||
assert_dataframe_has_required_columns(df, payload=False) | ||
assert len(df) == 0 | ||
|
||
|
||
def test_offline_limit(http_stream): | ||
df = http_stream.to_dataframe(n=10) | ||
assert dataframe_has_required_columns(df, payload=False) | ||
assert_dataframe_has_required_columns(df, payload=False) | ||
assert len(df) == 10 | ||
|
||
|
||
def test_offline_filter_vlan(vlan_stream): | ||
vlan_stream.set_filter("tcp") | ||
df = vlan_stream.to_dataframe() | ||
assert dataframe_has_required_columns(df, payload=False) | ||
assert_dataframe_has_required_columns(df, payload=False) | ||
assert len(df) == 18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
def dataframe_has_required_columns(df, payload): | ||
columns = ['time', 'src_host', 'src_port', 'dst_host', 'dst_port', 'protocol'] | ||
import pandas as pd | ||
import pandas.util.testing as tm | ||
|
||
|
||
def assert_dataframe_has_required_columns(df, payload): | ||
items = [ | ||
('time', 'datetime64[ns]'), | ||
('src_host', 'ip'), | ||
('src_port', 'u4'), | ||
('dst_host', 'ip'), | ||
('dst_port', 'u4'), | ||
('protocol', object) | ||
] | ||
|
||
if payload: | ||
columns.append("payload") | ||
return set(df.columns) == set(columns) | ||
items.append(("payload", 'object')) | ||
|
||
names, types = zip(*items) | ||
|
||
expected = pd.Series(types, index=names) | ||
tm.assert_series_equal(df.dtypes, expected) |