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

Update cmr mappings #1102

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
Open

Update cmr mappings #1102

wants to merge 14 commits into from

Conversation

CarsonDavis
Copy link
Collaborator

No description provided.

Base automatically changed from 1051-backend-model-changes-on-cosmos-to-hold-new-incoming-urls-frontend to dev November 21, 2024 14:15
def test_sde_link_generation(self):
data = {"meta": {"concept-id": "C179001887-SEDAC"}}
dataset = CmrDataset(data)
assert "sciencediscoveryengine.nasa.gov" in dataset.sde_link

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

The string
sciencediscoveryengine.nasa.gov
may be at an arbitrary position in the sanitized URL.

Copilot Autofix AI 11 days ago

To fix the problem, we need to parse the URL and check the hostname to ensure it matches the expected value. This can be done using the urlparse function from the urllib.parse module. We will extract the hostname from the URL and verify that it matches "sciencediscoveryengine.nasa.gov".

  • Parse the URL using urlparse.
  • Extract the hostname from the parsed URL.
  • Check if the hostname matches "sciencediscoveryengine.nasa.gov".
Suggested changeset 1
scripts/ej/test_cmr_processing.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/scripts/ej/test_cmr_processing.py b/scripts/ej/test_cmr_processing.py
--- a/scripts/ej/test_cmr_processing.py
+++ b/scripts/ej/test_cmr_processing.py
@@ -450,3 +450,5 @@
         dataset = CmrDataset(data)
-        assert "sciencediscoveryengine.nasa.gov" in dataset.sde_link
+        from urllib.parse import urlparse
+        parsed_url = urlparse(dataset.sde_link)
+        assert parsed_url.hostname == "sciencediscoveryengine.nasa.gov"
         assert "C179001887-SEDAC" in dataset.sde_link
EOF
@@ -450,3 +450,5 @@
dataset = CmrDataset(data)
assert "sciencediscoveryengine.nasa.gov" in dataset.sde_link
from urllib.parse import urlparse
parsed_url = urlparse(dataset.sde_link)
assert parsed_url.hostname == "sciencediscoveryengine.nasa.gov"
assert "C179001887-SEDAC" in dataset.sde_link
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
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