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

Added more tests to test_vertical_portscans.py #508

Merged
merged 4 commits into from
Apr 18, 2024

Conversation

Sekhar-Kumar-Dash
Copy link
Collaborator

@Sekhar-Kumar-Dash Sekhar-Kumar-Dash commented Apr 2, 2024

Fixes Issue #510

Changes proposed

With this pull request, I have added more tests to test_vertical_portscans.py, which will improve the code coverage

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • This PR does not contain plagiarized content.
  • The title of my pull request is a short description of the requested changes.

Copy link
Collaborator

@AlyaGomaa AlyaGomaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Sekhar-Kumar-Dash Thank you so much for your effort!
I see you spent so much time understanding the code to come up with that many test cases, we appreciate it.

All my comments are related to code style and formatting, i added 1 commit with refactoring that you could learn from, small things like line length and using mark.parametrize could make it easier for anyone reading your code.

Thanks again!:)

IDEACategory,
Victim,
Proto,
Tag
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're only using Proto from this import list, why import the following? usually your IDE should warn you about this and can even auto fix them for you so you don't have to worry about it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that. I am actually using VS Code now, so this feature must be disabled. I will fix this mistake and update the pull request.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey no need to apologize. thanks!

role = "Client"
type_data = "IPs"
direction = "Dst"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above 3 lines are unused local variables. usually your IDe should warn you about them or mark them in gray.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is actually getting displayed in a light color. Sorry, I missed that earlier. I am fixing it.

vertical_ps.get_not_established_dst_ips(protocol, state, profileid, twid)

def test_check_overlapping_dstports(mock_db):
vertical_ps = ModuleFactory().create_vertical_portscan_obj(mock_db)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Sekhar-Kumar-Dash I'm having trouble understanding this test
why are you testing overlapping ports? what can go wrong here?
Also i recommend using function docstrings so it's easier to know the answer to the above questions without having to ask you every time :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @AlyaGomaa The i have included this test is to ensure that the VerticalPortscan module correctly aggregates the packet counts for overlapping destination ports when scanning both TCP and UDP protocols. it is not a critical test we can remove it if you dont want it

am i getting it wrong??
Also thanks for the docstrings suggestion i will keep that in mind for future unittests PRs

@AlyaGomaa AlyaGomaa merged commit e645c31 into stratosphereips:develop Apr 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants