Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: ProfilingFlowsDatabase.add_port() missing 1 required positional argument: 'port_type' #333

Closed
naturalnetworks opened this issue May 1, 2023 · 3 comments

Comments

@naturalnetworks
Copy link
Contributor

Describe the bug

Setting 'analysis_direction = all' in config/slips.conf results in the following error during a capture:

Traceback (most recent call last):
  File "/home/user/StratosphereLinuxIPS/slips_files/core/profilerProcess.py", line 1259, in add_flow_to_profile
    self.handle_in_flows()
  File "/home/user/StratosphereLinuxIPS/slips_files/core/profilerProcess.py", line 1371, in handle_in_flows
    self.store_features_going_in(rev_profileid, rev_twid)
  File "/home/user/StratosphereLinuxIPS/slips_files/core/profilerProcess.py", line 1516, in store_features_going_in
    __database__.add_port(profileid, twid, self.flow, role, port_type)
TypeError: ProfilingFlowsDatabase.add_port() missing 1 required positional argument: 'port_type'

To Reproduce
Steps to reproduce the behavior:

  1. Set analysis_direction to 'all' in slips.conf
  2. Set network interface to promisc (or use a dummy interface with tcpreplay)
  3. ./slips.py -c config/slips.conf -i
  4. Confirm data eg tcpdump -i -c 10
  5. Wait for error to appear

Expected behavior
No type error should show during normal operation.

Branch
Develop. Issue not seen in Master.

Environment (please complete the following information):

  • OS: Ubuntu (Raspberri Pi/ARM64)
  • Version: 23.04 (Linux 6.2.0-1004-raspi)
  • Python version: Python 3.11.2
  • Are you running slips in docker or locally? Locally

Additional context

Dug around in slips_files/core/profilerProcess.py and /slips_files/core/database/_profile_flow.py.

Confirmed that 'ProfilingFlowsDatabase.add_port()' requires the following:

    def add_port(
        self,
        profileid: str,
        twid: str,
        ip_address: str,
        columns: dict,
        role: str,
        port_type: str,
    ):

'def store_features_going_in(self, profileid, twid)' in profilerProcess.py is only setting 5 arguments, not 6.

__database__.add_port(profileid, twid, self.flow, role, port_type)

Changed profilerProcess.py to:

        # Add the srcip and srcport
        __database__.add_ips(profileid, twid, self.flow, role)
        port_type = 'Src'
        # __database__.add_port(profileid, twid, self.flow, role, port_type)
        __database__.add_port(
            profileid,
            twid,
            self.daddr_as_obj,
            self.column_values,
            role,
            port_type,
        )

        # Add the dstport
        port_type = 'Dst'
        # __database__.add_port(profileid, twid,self.flow, role, port_type)
        __database__.add_port(
            profileid,
            twid, 
            self.daddr_as_obj,
            self.column_values,
            role,
            port_type,
        )

Error no longer seen and code matches with the current Master.

@naturalnetworks
Copy link
Contributor Author

naturalnetworks commented May 2, 2023

My changes actually didn't work, causes the following error:

Traceback (most recent call last):sending traffic in the last 1 hr: 1. (2023/05/02 20:45:52)
  File "/home/user/StratosphereLinuxIPS/slips_files/core/profilerProcess.py", line 1260, in add_flow_to_profile
    self.handle_in_flows()
  File "/home/user/StratosphereLinuxIPS/slips_files/core/profilerProcess.py", line 1372, in handle_in_flows
    self.store_features_going_in(rev_profileid, rev_twid)
  File "/home/user/StratosphereLinuxIPS/slips_files/core/profilerProcess.py", line 1522, in store_features_going_in
    self.column_values,
    ^^^^^^^^^^^^^^^^^^
AttributeError: 'ProfilerProcess' object has no attribute 'column_values'

A lot has changed with profilerProcess.py, not sure if I will be able to figure it out. Likely related to issue #331 .

@AlyaGomaa
Copy link
Collaborator

this is fixed yesterday in the latest develop
you can pull now and let us know if this problem persists.
Thank you so much for reporting!

@naturalnetworks
Copy link
Contributor Author

Looking good so far. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants