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

[TOOL-95] Add whois info to the host string. #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

diegomarcov
Copy link

No description provided.

@@ -1,5 +1,6 @@
import ipaddress
import socket
from ipwhois import IPWhois
Copy link
Collaborator

Choose a reason for hiding this comment

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

we need to declare this as a new dependency in pyproject.toml

super().__init__(
"A test tried to use socket.socket.connect() "
f'with host "{host}" (allowed: "{allowed}").'
f'with host "{host_text}" (allowed: "{allowed}").'
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesn't it break any test?

Copy link
Author

Choose a reason for hiding this comment

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

assert_host_blocked and test_parametrize_with_socket_enabled_and_allow_hosts are matching with A test tried to use socket.socket.connect() with host*, so no tests seem to be broken.

@mgaitan
Copy link
Collaborator

mgaitan commented Feb 17, 2023

after finish this PR (hopefully with a test) we need to add a new tag and update it in core's requirements

https://github.com/Shiphero/Shiphero-API/blob/master/shiphero_app/requirements/_requirements-docker.in#L7

then recompile the requirements and we should ok.

@mgaitan mgaitan changed the title Add whois info to the host string. [TOOL-95] Add whois info to the host string. Feb 20, 2023
pyproject.toml Outdated
@@ -33,6 +33,7 @@ classifiers = [
[tool.poetry.dependencies]
python = "^3.7"
pytest = ">=3.6.3"
ipwhois = "~=1.2.0"

Choose a reason for hiding this comment

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

For libraries meant to be reused by many applications, strict dependencies are discouraged since they lock every dependent app to use that specific version and block them from upgrading to 1.4.0 for example.

We should be as lax as possible here, and as strict as possible in shiphero_app.
For example here ipwhois = ">= 1.0.0"

Choose a reason for hiding this comment

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

This article is a good reference to understand why. setup.py here would be our pyproject.toml

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, done. Good catch.

@mgaitan
Copy link
Collaborator

mgaitan commented Feb 20, 2023

Diego could you show us how a traceback looks like with this change?

@diegomarcov
Copy link
Author

I paused this after the hackaton but I really want to try and integrate this.

I believe the current issue is when we hit SocketConnectBlockedError we try to perform a network request for the whois info, which is in turn blocked again and we recurse into more similar errors.

Any suggestions on how to tackle this?

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

Successfully merging this pull request may close these issues.

3 participants