Giter Club home page Giter Club logo

faucetsdn / poseidon Goto Github PK

View Code? Open in Web Editor NEW
416.0 28.0 126.0 20.23 MB

Poseidon is a python-based application that leverages software defined networks (SDN) to acquire and then feed network traffic to a number of machine learning techniques. The machine learning algorithms classify and predict the type of device.

License: Apache License 2.0

Python 91.74% Makefile 0.05% Shell 7.61% Dockerfile 0.61%
machine-learning sdn network-analysis networking software-defined-network network-forensics pcap pcap-files pcap-analyzer sdn-controller

poseidon's Introduction

Poseidon

License Build Status codecov Docker Hub Downloads

Software Defined Network Situational Awareness

POSEIDON is now BlackDuck 2016 OpenSource Rookie of the year

Poseidon began as a joint effort between two of the IQT Labs: Cyber Reboot and Lab41. The project's goal is to explore approaches to better identify what nodes are on a given (computer) network and understand what they are doing. The project utilizes Software Defined Networking and machine learning to automatically capture network traffic, extract relevant features from that traffic, perform classifications through trained models, convey results, and provide mechanisms to take further action. While the project works best leveraging modern SDNs, parts of it can still be used with little more than packet capture (pcap) files.

Table of Contents

Background

The Poseidon project originally began as an experiment to test the merits of leveraging SDN and machine learning techniques to detect abnormal network behavior. (Please read our blogs posts linked below for several years of background) While that long-term goal remains, the unfortunate reality is that the state of rich, labelled, public, and MODERN network data sets for ML training is pretty poor. Our lab is working on improving the availability of network training sets, but in the near term the project remains focused on 1) improving the accuracy of identifying what a node IS (based on captured IP header data) and 2) developing Poseidon into a "harness" of sorts to house machine learning techniques for additional use cases. (Read: Not just ours!)

Prerequisites

  • Docker - Poseidon and related components run on top of Docker, so understanding the fundamentals will be useful for troubleshooting as well. Note: installing via Snap is currently unsupported. A Good Ubuntu Docker Quick-Start
  • Compose - Poseidon is orchestrated with docker-compose. You will need a version that supports compose file format version 3 and health check conditions (minimum 1.29.2).
  • Curl - command-line for transferring data with URLs.
  • git - distributed version control system.
  • jq - command-line JSON processor.
  • An SDN Controller - specifically Faucet
  • ~10GB of free disk space

Note: Installation on OS X is possible but not supported.

Installing

Permissions for Docker

To simplify using commands with Docker, we recommend allowing the user that will be executing Poseidon commands be part of the docker group so they can execute Docker commands without sudo. Typically, this can be done with:

sudo usermod -aG docker $USER

Followed by closing the existing shell and starting a new one.

Getting the bits

NOTE: If you have previously installed Poseidon from a .deb package, please remove it first. Installation from .deb is no longer supported.

Install the poseidon script which we will use to install and manage Poseidon.

curl -L https://raw.githubusercontent.com/IQTLabs/poseidon/main/bin/poseidon -o /usr/local/bin/poseidon
chmod +x /usr/local/bin/poseidon

Faucet Configuration

NOTE: Poseidon requires at least Faucet version 1.9.46 or higher.

Poseidon uses a faucetconfrpc server, to maintain Faucet configuration. Poseidon starts its own server for you by default, and also by default Poseidon and Faucet have to be on the same machine. To run Faucet on a separate machine, you will need to start faucetconfrpc on that other machine, and update faucetconfrpc_address to point to where the faucetconfrpc is running. You may also need to update faucetconfrpc_client, if you are not using the provided automatically generated keys.

If you have Faucet running already, make sure Faucet is started with the following environment variables, which allow Poseidon to change its config, and receive Faucet events:

export FAUCET_EVENT_SOCK=1
export FAUCET_CONFIG_STAT_RELOAD=1

Faucet is now configured and ready for use with Poseidon.

Faucet stacking

Faucet supports stacking (distributed switching - multiple switches acting together as one). Poseidon also supports this - Poseidon's mirroring interface should be connected to a port on the root switch. You will need to allocate a port on each non-root switch also, and install a loopback plug (either Ethernet or fiber) in that port. Poseidon will detect stacking and take care of the rest of the details (using Faucet's tunneling feature to move mirror packets from the non-root switches to the root switch's mirror port). The only Poseidon config required is to add the dedicated port on each switch to the controller_mirror_port dictionary.

Configuring Poseidon

You will need to create a directory and config file on the server where Poseidon will run.

sudo mkdir /opt/poseidon
sudo cp config/poseidon.config /opt/poseidon

Now, edit this file. You will need to set at minimum:

  • controller_type, as appropriate to the controller you are running (see above).
  • collector_nic: must be set to the interface name on the server, that is connected to the switch mirror port.
  • controller_mirror_ports: must be set to the interface on the switch that will be used as the mirror port.

Optionally, you may also set controller_proxy_mirror_ports (for switches that don't have their own mirror ports, and can be mirrored with another switch).

Updating Poseidon

From v0.10.0, you can update an existing Poseidon installation with poseidon -u (your configuration will be preserved). Updating from previous versions is not supported - please remove and reinstall as above. You can also give poseidon -u a specific git hash if you want to update to an unreleased version.

Usage

After installation you'll have a new command poseidon available for looking at the configuration, logs, and shell, as well as stopping and starting the service.

$ poseidon help
Poseidon, an application that leverages software defined networks (SDN) to acquire and then feed network traffic to a number of machine learning techniques. For more info visit: https://github.com/IQTLabs/poseidon

Usage: poseidon [option]
Options:
    -a,  api           get url to the Poseidon API
    -c,  config        display current configuration info
    -d,  delete        delete Poseidon installation (uses sudo)
    -e,  shell         enter into the Poseidon shell, requires Poseidon to already be running
    -h,  help          print this help
    -i,  install       install Poseidon repo (uses sudo)
    -l,  logs          display the information logs about what Poseidon is doing
    -r,  restart       restart the Poseidon service (uses sudo)
    -s,  start         start the Poseidon service (uses sudo)
    -S,  stop          stop the Poseidon service (uses sudo)
    -u,  update        update Poseidon repo, optionally supply a version (uses sudo)
    -V,  version       get the version installed

Step 0:

Optionally specify a prefix location to install Poseidon by setting an environment variable, if it is unset, it will default to /opt and Poseidon. (If using Faucet, it will also override /etc locations to this prefix.)

export POSEIDON_PREFIX=/tmp

Step 1:

poseidon install

Step 2:

Configure Poseidon for your preferred settings. Open /opt/poseidon/poseidon.config (add the Poseidon prefix if you specified one).

For using Faucet, make sure to minimally change the controller_mirror_ports to match the switch name and port number of your mirror port. You will also need to update the collector_nic in the poseidon section to match the interface name of the NIC your mirror port is connected to.

Step 3:

If you don't have Faucet already and/or you want to Poseidon to spin up Faucet for you as well, simply run the following command and you will be done:

poseidon start

Step 4:

If you are using your own installation of Faucet, you will need to enable communication between Poseidon and Faucet. Poseidon needs to change Faucet's configuration, and Faucet needs to send events to Poseidon. This configuration needs to be set with environment variables (see https://docs.faucet.nz/). For example, if running Faucet with Docker, you will need the following environment configuration in the faucet service in your docker-compose file:

        environment:
            FAUCET_CONFIG: '/etc/faucet/faucet.yaml'
            FAUCET_EVENT_SOCK: '/var/run/faucet/faucet.sock'
            FAUCET_CONFIG_STAT_RELOAD: '1'

If Faucet and Poseidon are running on the same machine, you can start Poseidon and you will be done:

poseidon start --standalone

Step 5:

If you are running Faucet and Poseidon on different machines, configuration is more complex (work to make this easier is ongoing): execute Step 4 first. Then you will need to run event-adapter-rabbitmq and faucetconfrpc services on the Faucet host, and change Poseidon's configuration to match.

First start all services from helpers/faucet/docker-compose.yaml on the Faucet host, using a Docker network that has network connectivity with your Poseidon host. Set FA_RABBIT_HOST to be the address of your Poseidon host. faucet_certstrap will generate keys in /opt/faucetconfrpc which will need to be copied to your Poseidon host. Then modify faucetconfrpc_address in /opt/poseidon/config/poseidon.config to point to your Faucet host.

You can now start Poseidon:

poseidon start --standalone

Troubleshooting

Poseidon by its nature depends on other systems. The following are some common issues and troubleshooting steps.

Poseidon doesn't detect any hosts.

The most common cause of this problem, with the FAUCET controller, is RabbitMQ connectivity.

  • Check that the RabbitMQ event adapter (faucet/event-adapter-rabbitmq) is running and not restarting.
# docker ps|grep faucet/event-adapter-rabbitmq
4a7509829be0        faucet/event-adapter-rabbitmq           "/usr/local/bin/entr…"   3 days ago          Up 3 days
  • Check that FAUCET.Event messages are being received by Poseidon.

This command reports the time that the most recent FAUCET.Event message was received by Poseidon.

If run repeatedly over a couple of minutes this timestamp should increase.

docker exec -it poseidon_poseidon_1 /bin/sh
/poseidon # wget -q -O- localhost:9304|grep -E ^poseidon_last_rabbitmq_routing_key_time.+FAUCET.Event
poseidon_last_rabbitmq_routing_key_time{routing_key="FAUCET.Event"} 1.5739482267393966e+09
/poseidon # wget -q -O- localhost:9304|grep -E ^poseidon_last_rabbitmq_routing_key_time.+FAUCET.Event
poseidon_last_rabbitmq_routing_key_time{routing_key="FAUCET.Event"} 1.5739487978768678e+09
/poseidon # exit

Poseidon doesn't report any host roles.

  • Check that the mirror interface is up and receiving packets (should be configured in collector_nic. The interface must be up before Posiedon starts.
# ifconfig enx0023559c2781
enx0023559c2781: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::223:55ff:fe9c:2781  prefixlen 64  scopeid 0x20<link>
        ether 00:23:55:9c:27:81  txqueuelen 1000  (Ethernet)
        RX packets 82979981  bytes 77510139268 (77.5 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 202  bytes 15932 (15.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • Check that there is disk space available and pcaps are being accumulated in /opt/poseidon_files (add POSEIDON_PREFIX in front if it was used.)
# find /opt/poseidon_files -type f -name \*pcap |head -5
/opt/poseidon_files/trace_d3f3217106acd75fe7b5c7069a84a227c9e48377_2019-11-15_03_10_41.pcap
/opt/poseidon_files/tcprewrite-dot1q-2019-11-15-06_26_48.529473-UTC/pcap-node-splitter-2019-11-15-06_26_50.192570-UTC/clients/trace_0a6ce9490c193b65c3cad51fffbadeaed4ed5fdd_2019-11-15_06_11_24-client-ip-216-58-196-147-192-168-254-254-216-58-196-147-vssmonitoring-frame-eth-ip-icmp.pcap
/opt/poseidon_files/tcprewrite-dot1q-2019-11-15-06_26_48.529473-UTC/pcap-node-splitter-2019-11-15-06_26_50.192570-UTC/clients/trace_0a6ce9490c193b65c3cad51fffbadeaed4ed5fdd_2019-11-15_06_11_24-miscellaneous-192-168-254-1-192-168-254-254-vssmonitoring-frame-eth-arp.pcap
/opt/poseidon_files/tcprewrite-dot1q-2019-11-15-06_26_48.529473-UTC/pcap-node-splitter-2019-11-15-06_26_50.192570-UTC/clients/trace_0a6ce9490c193b65c3cad51fffbadeaed4ed5fdd_2019-11-15_06_11_24-client-ip-192-168-254-254-192-168-254-254-74-125-200-189-udp-frame-eth-ip-wsshort-port-443.pcap
/opt/poseidon_files/tcprewrite-dot1q-2019-11-15-06_26_48.529473-UTC/pcap-node-splitter-2019-11-15-06_26_50.192570-UTC/servers/trace_0a6ce9490c193b65c3cad51fffbadeaed4ed5fdd_2019-11-15_06_11_24-server-ip-74-125-68-188-192-168-254-254-74-125-68-188-frame-eth-ip-tcp-port-5228.pcap

Developing

Modifying Code that Runs in a Docker Container

If installed as described above, poseidon's codebase will be at /opt/poseidon. At this location, make changes, then run poseidon restart.

Network Data Logging

Poseidon logs some data about the network it monitors. Therefore it is important to secure Poseidon's own host (aside from logging, Poseidon can of course change FAUCET's network configuration).

There are two main types of logging at the lowest level. The first is FAUCET events - FAUCET generates an event when it learns on which port a host is present on the network, and the event includes source and destination Ethernet MAC and IP addresses (if present). For example:

2019-11-21 20:18:41,909 [DEBUG] faucet - got faucet message for l2_learn: {'version': 1, 'time': 1574367516.3555572, 'dp_id': 1, 'dp_name': 'x930', 'event_id': 172760, 'L2_LEARN': {'port_no': 22, 'previous_port_no': None, 'vid': 254, 'eth_src': '0e:00:00:00:00:99', 'eth_dst': '0e:00:00:00:00:01', 'eth_type': 2048, 'l3_src_ip': '192.168.254.3', 'l3_dst_ip': '192.168.254.254'}}

The second type of logging is host based pcap captures, with most of the application (L4) payload removed. Poseidon causes the ncapture component (https://github.com/IQTLabs/network-tools/tree/main/network_tap/ncapture) to capture traffic, which is logged in /opt/poseidon_files. These are used in turn to learn host roles, etc.

Related Components

Additional Info

poseidon's People

Contributors

aganeshlab41 avatar amsourav avatar anarkiwi avatar bradh41 avatar cglewis avatar d-grossman avatar danielpops avatar dependabot[bot] avatar eugleo avatar gregs5 avatar haivp3010 avatar jamesd4y avatar jeff-wang93 avatar joelvzach avatar joris47 avatar kylemvz avatar lanhamt avatar lilchurro avatar lskillen avatar mshel avatar ns61817 avatar phrostbyten avatar pyup-bot avatar rashley-iqt avatar renovate-bot avatar renovate[bot] avatar rjalfa avatar sanchezg avatar sysadmind avatar viveksyngh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poseidon's Issues

Test creation: print_endpoint_state

NorthboundControllerAbstraction needs better coverage for testing.

add testing for print_endpoint_state to test_NorthBoundControllerAbstraction.py

Test creation: configSelf

NorthboundControllerAbstraction needs better coverage for testing.

add testing for configSelf to test_poseidonMonitor.py

Test creation: get_endpoint_ip

NorthboundControllerAbstraction needs better coverage for testing.

add testing for get_endpoint_ip to test_NorthBoundControllerAbstraction.py

Make a docker container to build docs

  1. create a dockerfile called Dockerfile.docs (you may want to look at the pre-existing container)
  2. Sphinx the project (see http://docs.readthedocs.io/en/latest/getting_started.html)
  3. have output placed somewhere under docs

building the container should look like:
docker build -f ./Dockerfile.docs -t poseidon.docs .

running the container should look like:
docker run -v/someDir:/pathTo/docs poseidon.docs

someDir - would be where to write updated version of docs
/pathTo/docs - inside the container where things are being written

If you have questions please ask. (use the existing Dockerfile as a reference)

Test creation:process

NorthboundControllerAbstraction needs better coverage for testing.

add testing for process to test_poseidonMonitor.py

Test cretion:start_vent_collector

NorthboundControllerAbstraction needs better coverage for testing.

add testing for start_vent_collector to test_poseidonMonitor.py

heuristics: add network machines list

-pcap stats and dns verify both need to maintain list of in-network machines (from onos nab)
-integrate with rabbitmq and uncomment connection and callback handler installer

Query about using the Jupyter Notebooks

Hi @bradh41

I read your post here. Being a newbie to the world of Machine Learning based Cyber Security, I found it very informative. Thank you for that.

I found so many Jupyter Notebooks in the repo. Which one should I start with? Also how can I collect the raw hex dump of the headers (any tool which can help me) for my own custom use case?

Thank you

Test creation: get_endpoint_state

NorthboundControllerAbstraction needs better coverage for testing.

add testing for get_endpoint_state to test_NorthBoundControllerAbstraction.py

make docs failure

$uname -smprv
Darwin 14.5.0 Darwin Kernel Version 14.5.0: Tue Apr 11 16:12:42 PDT 2017; root:xnu-2782.50.9.2.3~1/RELEASE_X86_64 x86_64 i386
$docker -v
Docker version 17.03.1-ce, build c6d412e

$git clone git clone https://github.com/Lab41/poseidon.git && cd poseidon/ && make docs

(Edit: sorry about the formatting, MD is confused by the content)
.
.
.
`=================================== FAILURES ===================================
_____________________________ test_PoseidonStorage _____________________________

def test_PoseidonStorage():
    """
    test of PoseidonStorage class that
    brokers communication with the mongodb container.
    client.address tests connection to database and returns
    tuple of host and port. default port for mongodb
    is 27017.
    """
    ps = PoseidonStorage()
  assert isinstance(ps.client.address, type(()))

poseidon/poseidonStorage/test_poseidonStorage.py:77:


/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py:614: in address
return self._server_property('address')
/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py:580: in _server_property
writable_server_selector)
/usr/local/lib/python2.7/dist-packages/pymongo/topology.py:214: in select_server
address))


self = <pymongo.topology.Topology object at 0x7fe03c650890>
selector = <function writable_server_selector at 0x7fe044fb72a8>
server_selection_timeout = None, address = None

def select_servers(self,
                   selector,
                   server_selection_timeout=None,
                   address=None):
    """Return a list of Servers matching selector, or time out.

        :Parameters:
          - `selector`: function that takes a list of Servers and returns
            a subset of them.
          - `server_selection_timeout` (optional): maximum seconds to wait.
            If not provided, the default value common.SERVER_SELECTION_TIMEOUT
            is used.
          - `address`: optional server address to select.

        Calls self.open() if needed.

        Raises exc:`ServerSelectionTimeoutError` after
        `server_selection_timeout` if no matching servers are found.
        """
    if server_selection_timeout is None:
        server_timeout = self._settings.server_selection_timeout
    else:
        server_timeout = server_selection_timeout

    with self._lock:
        self._description.check_compatible()

        now = _time()
        end_time = now + server_timeout
        server_descriptions = self._description.apply_selector(
            selector, address)

        while not server_descriptions:
            # No suitable servers.
            if server_timeout == 0 or now > end_time:
                raise ServerSelectionTimeoutError(
                  self._error_message(selector))

E ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused

/usr/local/lib/python2.7/dist-packages/pymongo/topology.py:189: ServerSelectionTimeoutError
____________________________ test_db_database_names ____________________________

client = <pytest_falcon.plugin.Client object at 0x7fe03c621c90>

def test_db_database_names(client):
    """
    tests retrieval of database names from
    poseidonStorage.
    """
    resp = client.get('/v1/storage')
  assert resp.status == falcon.HTTP_OK

E AssertionError: assert '500 Internal Server Error' == '200 OK'
E - 500 Internal Server Error
E + 200 OK

poseidon/poseidonStorage/test_poseidonStorage.py:106: AssertionError
___________________________ test_db_collection_names ___________________________

client = <pytest_falcon.plugin.Client object at 0x7fe03c5c9f10>

def test_db_collection_names(client):
    """
    tests retrieval of collection names for a
    given database.
    """
    resp = client.get('/v1/storage/local')
  assert resp.status == falcon.HTTP_OK

E AssertionError: assert '500 Internal Server Error' == '200 OK'
E - 500 Internal Server Error
E + 200 OK

poseidon/poseidonStorage/test_poseidonStorage.py:116: AssertionError
___________________________ test_db_collection_count ___________________________

client = <pytest_falcon.plugin.Client object at 0x7fe03c6502d0>

def test_db_collection_count(client):
    """
    tests retrieval of document count for
    a given database and collection.
    """
    resp = client.get('/v1/storage/local/startup_log')
  assert resp.status == falcon.HTTP_OK

E AssertionError: assert '500 Internal Server Error' == '200 OK'
E - 500 Internal Server Error
E + 200 OK

poseidon/poseidonStorage/test_poseidonStorage.py:131: AssertionError
_____________________________ test_db_retrieve_doc _____________________________

client = <pytest_falcon.plugin.Client object at 0x7fe03c6503d0>

def test_db_retrieve_doc(client):
    """
    tests retrieval of document from a
    given database and collection.
    If no document is found then error message
    is returned.
    """
    resp = client.get(
        '/v1/storage/doc/local/startup_log/ffffffffffffffffffffffff')
  assert resp.status == falcon.HTTP_OK

E AssertionError: assert '500 Internal Server Error' == '200 OK'
E - 500 Internal Server Error
E + 200 OK

poseidon/poseidonStorage/test_poseidonStorage.py:144: AssertionError
___________________________ test_db_collection_query ___________________________

client = <pytest_falcon.plugin.Client object at 0x7fe03c5c9110>

def test_db_collection_query(client):
    """
    tests response from query of database.
    response is a serialized dict with 'count'
    and 'docs' fields.
    """
    query = {}
    query = json.dumps(query)
    resp = client.get('/v1/storage/query/' + 'local/' + 'startup_log/' + query)
  assert resp.status == falcon.HTTP_OK

E AssertionError: assert '500 Internal Server Error' == '200 OK'
E - 500 Internal Server Error
E + 200 OK

poseidon/poseidonStorage/test_poseidonStorage.py:160: AssertionError
_____________________________ test_db_add_one_doc ______________________________

client = <pytest_falcon.plugin.Client object at 0x7fe03c650790>

def test_db_add_one_doc(client):
    """
    tests adding document to a database, then
    tests retrieving added document from the database
    using the returned id, then tests that the collection
    inserted into is listed under the database collections.
    """
    doc = {}
    doc['node_ip'] = 'TEST'
    doc['talked_to'] = {'machine_1': 2,
                        'machine_2': 1,
                        'machine_3': 1}
    doc['recieved_from'] = {'machine_1': 1,
                            'machine_6': 3,
                            'machine_2': 2}
    doc['packet_lengths'] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    doc['flow_id'] = '6a32984d2348e23894f3298'
    doc['dns_records'] = ['0.0.0.0', '1.1.1.1']
    doc['time_rec'] = {'first_sent': '0-0-0 00:00:00.000000',
                       'first_received': '0-0-0 00:00:00.000000',
                       'last_sent': '0-0-0 00:00:00.000000',
                       'last_received': '0-0-0 00:00:00.000000'}
    # adds doc to db
    uri = '/v1/storage/add_one_doc/' + 'test_poseidon_records/' + 'network_graph'
    resp = client.post(uri, data=json.dumps(doc))
  assert resp.status == falcon.HTTP_OK

E AssertionError: assert '500 Internal Server Error' == '200 OK'
E - 500 Internal Server Error
E + 200 OK

poseidon/poseidonStorage/test_poseidonStorage.py:196: AssertionError
____________________________ test_db_add_many_docs _____________________________

client = <pytest_falcon.plugin.Client object at 0x7fe03c524150>

def test_db_add_many_docs(client):
    """
    tests inserting several docs into database.
    encodes with bson for well-formatted url.
    """
    doc_one = {}
    doc_one['node_ip'] = '1.1.1.1'
    doc_one['packet_lengths'] = [1, 1, 2]

    doc_two = {}
    doc_two['node_ip'] = '2.2.2.2'
    doc_two['packet_lengths'] = [3, 5, 8]

    doc_thr = {}
    doc_thr['node_ip'] = '3.3.3.3'
    doc_thr['packet_lengths'] = [13, 21, 34]

    # insert 3 docs
    docs = [doc_one, doc_two, doc_thr]
    uri = '/v1/storage/add_many_docs/'+'test_poseidon_records/'+'network_graph/'
    resp = client.post(uri, data=json.dumps(docs))
  assert resp.status == falcon.HTTP_OK

E AssertionError: assert '500 Internal Server Error' == '200 OK'
E - 500 Internal Server Error
E + 200 OK

poseidon/poseidonStorage/test_poseidonStorage.py:263: AssertionError
____________________________ test_db_update_one_doc ____________________________

client = <pytest_falcon.plugin.Client object at 0x7fe03c650410>

def test_db_update_one_doc(client):
    """
    tests updating nonexistent doc,
    encodes filter and updated doc with
    bson.
    """
    filt = {'node_ip': '-1.-1.-1.-1'}
    update = {'node_ip': '-1.-1.-1.-1', 'new_field': 101}

    # non-existent document
    filt = json.dumps(filt)
    uri = '/v1/storage/update_one_doc/'+'test_poseidon_records/'+'network_graph/'+filt
    resp = client.post(uri, data=json.dumps(update))
    assert resp.status == falcon.HTTP_BAD_REQUEST
    resp = json.loads(resp.body)
    assert not resp['success']

    # insert doc
    doc = {'node_ip': 'GIRAFFE'}
    uri = '/v1/storage/add_one_doc/' + 'test_poseidon_records/' + 'network_graph'
    resp = client.post(uri, data=json.dumps(doc))
  assert resp.status == falcon.HTTP_OK

E AssertionError: assert '500 Internal Server Error' == '200 OK'
E - 500 Internal Server Error
E + 200 OK

poseidon/poseidonStorage/test_poseidonStorage.py:297: AssertionError
===================== 9 failed, 2 passed in 271.80 seconds =====================
The command '/bin/sh -c py.test -v --ignore=poseidon/poseidonMain --ignore=poseidon/poseidonMonitor --ignore=poseidon/periodically --ignore=poseidon/mockController --ignore=collectors --ignore=plugins/ --cov=poseidon/poseidonStorage --cov-report term-missing --cov-config .coveragerc' returned a non-zero code: 1
make: *** [build] Error 1`

Test creation: update_next

NorthboundControllerAbstraction needs better coverage for testing.

add testing for update_next to test_poseidonMonitor.py

Test creation: update_endpoint_state

NorthboundControllerAbstraction needs better coverage for testing.

add testing for update_endpoint_state to test_NorthBoundControllerAbstraction.py

Test creation: get_endpoint_next

NorthboundControllerAbstraction needs better coverage for testing.

add testing for get_endpoint_next to test_NorthBoundControllerAbstraction.py

Test creation: print_endpoint

NorthboundControllerAbstraction needs better coverage for testing.

add testing for print_endpoint to test_poseidonMonitor.py

Endpoint class creation

Create an Endpoint.py in the same dir as poseidonMonitor.py
stores information like:

{
'tenant': u'FLOORPLATE', 
'mac': u'de:ad:be:ef:7f:12', 
'segment': u'prod', 
'name': None, 
'ip-address': u'102.179.20.100'
}

the class should have member variables
state(str) - current state the endpoint is in
next-state(str) - the next state for the endpoint
data(dict) - for storing the above example info

the class should have the following member functions
init by dictionary to make a new object .
make_hash (see NorthboundControllerAbstraction::make_hash)
to_str - make string representation of internals of object
to_json - should return a json view of the object
from_json -initialize object from json
update_state - state <- next_state, next_state <- 'NONE' or a string that is passed as a parameter.

Test creation: firstrun

NorthboundControllerAbstraction needs better coverage for testing.

add testing for first_run to test_NorthBoundControllerAbstraction.py

Test creation: configSelf

NorthboundControllerAbstraction needs better coverage for testing.

add testing for configSelf to test_poseidonMonitor.py

Test creation: make_known_endpoint

NorthboundControllerAbstraction needs better coverage for testing.

add testing for make_known_endpoint to test_NorthBoundControllerAbstraction.py

Test creation: mirror_endpoint

NorthboundControllerAbstraction needs better coverage for testing.

add testing for miror_endpoint to test_NorthBoundControllerAbstraction.py

Test creation: shutdown_endpoint

NorthboundControllerAbstraction needs better coverage for testing.

add testing for shutdown_endpoint to test_NorthBoundControllerAbstraction.py

Test creation: get_q_item

NorthboundControllerAbstraction needs better coverage for testing.

add testing for get_q_item to test_poseidonMonitor.py

Test creation: signal_handler

NorthboundControllerAbstraction needs better coverage for testing.

add testing for signal_handler to test_poseidonMonitor.py

Test creation: update_next_state

NorthboundControllerAbstraction needs better coverage for testing.

add testing for update_next_state to test_poseidonMonitor.py

Test creation: make_endpoint_dict

NorthboundControllerAbstraction needs better coverage for testing.

add testing for make_endpoint_dict to test_NorthBoundControllerAbstraction.py

config file ocd

everything but two entries uses _ for separating works... make the config uniform.

rabbit-server = RABBIT_SERVER
rabbit-port = RABBIT_PORT

change to:

rabbit_server = RABBIT_SERVER
rabbit_port = RABBIT_PORT

fix code to look for the _ versions..

helperFunctions Mixed with my classes: poseidonMonitor

Some of the functions within poseidonMonitor can be moved into a poseidonMonitor_helper.py file

  1. create the poseidonMonitor_helper.py file in the same directory as poseidonMonitor.py
  2. add the appropriate headers to the top of the file
  3. move the helper functions into the new file
  4. add the imports, call the functions correctly now that they are in a new location
  5. put what functions were moved into the issue so I can update the Testing issues.

send metadata to endprocess via Vent

The machine learning process benefits from knowing some metadata about the data it is processing.

poseidonMonitor::start_vent_collector()
should add a 'metadata' field to the 'payload' dict.
'metadata' should be assigned the connection metadata associated with the dev_hash key passed into the function. get the metadata from uss.return_endpoint_state()

ImportError: No module named pika

When I run the test, 2 errors as following,but the package was installed in /usr/local/lib/python2.7/dist-packages/pika,what can I do to resolve the errors:

ERROR collecting poseidon/poseidonMonitor/NorthBoundControllerAbstraction/test_NorthBoundControllerAbstraction.py
ImportError while importing test module '/poseidonWork/poseidon/poseidonMonitor/NorthBoundControllerAbstraction/test_NorthBoundControllerAbstraction.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
poseidon/poseidonMonitor/NorthBoundControllerAbstraction/test_NorthBoundControllerAbstraction.py:28: in
from poseidon.poseidonMonitor.NorthBoundControllerAbstraction.NorthBoundControllerAbstraction import controller_interface
poseidon/poseidonMonitor/NorthBoundControllerAbstraction/NorthBoundControllerAbstraction.py:30: in
import pika
E ImportError: No module named pika
___________________ ERROR collecting scripts/test_rabbit.py ____________________
ImportError while importing test module '/poseidonWork/scripts/test_rabbit.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
scripts/test_rabbit.py:12: in
import pika
E ImportError: No module named pika

Test creation: rabbit_callback

NorthboundControllerAbstraction needs better coverage for testing.

add testing for rabbit_callback to test_poseidonMonitor.py

Test creation: change_endpoint_state

NorthboundControllerAbstraction needs better coverage for testing.

add testing for change_endpoint_state to test_NorthBoundControllerAbstraction.py

Test creation: return_endpoint_state

NorthboundControllerAbstraction needs better coverage for testing.

add testing for return_endpoint_state to test_NorthBoundControllerAbstraction.py

Test creation: find_new_machines

NorthboundControllerAbstraction needs better coverage for testing.

add testing for find_new_machines to test_NorthBoundControllerAbstraction.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.