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

Minor NRTMv4 fixes #971

Merged
merged 2 commits into from
Nov 13, 2024
Merged

Minor NRTMv4 fixes #971

merged 2 commits into from
Nov 13, 2024

Conversation

mxsasha
Copy link
Collaborator

@mxsasha mxsasha commented Nov 13, 2024

  • Fix relative URL compatibility for RIPE
  • Update database status for NRTMv4 client success

irrd/mirroring/nrtm4/nrtm4_client.py Dismissed Show dismissed Hide dismissed
@@ -340,8 +342,11 @@
for delta in unf.deltas:
if delta.version < next_version:
continue
url = delta.full_url(self.notification_file_url)
if "nrtm.db.ripe.net" in self.notification_file_url: # pragma: no cover

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

The string
nrtm.db.ripe.net
may be at an arbitrary position in the sanitized URL.

Copilot Autofix AI 7 days ago

To fix the problem, we need to parse the URL and check the hostname properly instead of using a substring check. This can be done using the urlparse function from the urllib.parse module. We will extract the hostname from the URL and then check if it matches the allowed host.

  • Parse the URL using urlparse.
  • Extract the hostname from the parsed URL.
  • Check if the hostname matches the allowed host "nrtm.db.ripe.net".
Suggested changeset 1
irrd/mirroring/nrtm4/nrtm4_client.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/irrd/mirroring/nrtm4/nrtm4_client.py b/irrd/mirroring/nrtm4/nrtm4_client.py
--- a/irrd/mirroring/nrtm4/nrtm4_client.py
+++ b/irrd/mirroring/nrtm4/nrtm4_client.py
@@ -5,2 +5,3 @@
 import pydantic
+from urllib.parse import urlparse
 from joserfc.rfc7515.model import CompactSignature
@@ -287,3 +288,4 @@
         url = unf.snapshot.full_url(self.notification_file_url)
-        if "nrtm.db.ripe.net" in self.notification_file_url:  # pragma: no cover
+        parsed_url = urlparse(self.notification_file_url)
+        if parsed_url.hostname == "nrtm.db.ripe.net":  # pragma: no cover
             url = unf.snapshot.url
@@ -345,3 +347,4 @@
             url = delta.full_url(self.notification_file_url)
-            if "nrtm.db.ripe.net" in self.notification_file_url:  # pragma: no cover
+            parsed_url = urlparse(self.notification_file_url)
+            if parsed_url.hostname == "nrtm.db.ripe.net":  # pragma: no cover
                 url = delta.url
EOF
@@ -5,2 +5,3 @@
import pydantic
from urllib.parse import urlparse
from joserfc.rfc7515.model import CompactSignature
@@ -287,3 +288,4 @@
url = unf.snapshot.full_url(self.notification_file_url)
if "nrtm.db.ripe.net" in self.notification_file_url: # pragma: no cover
parsed_url = urlparse(self.notification_file_url)
if parsed_url.hostname == "nrtm.db.ripe.net": # pragma: no cover
url = unf.snapshot.url
@@ -345,3 +347,4 @@
url = delta.full_url(self.notification_file_url)
if "nrtm.db.ripe.net" in self.notification_file_url: # pragma: no cover
parsed_url = urlparse(self.notification_file_url)
if parsed_url.hostname == "nrtm.db.ripe.net": # pragma: no cover
url = delta.url
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@mxsasha mxsasha merged commit ccf57f6 into main Nov 13, 2024
8 of 9 checks passed
@mxsasha mxsasha deleted the nrtm4-fixes branch November 13, 2024 10:57
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.

1 participant