Skip to content

Digg 472 Follow specification face #526

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

Closed
wants to merge 37 commits into from
Closed

Conversation

AlessandroGasperini
Copy link
Collaborator

New filter on datasets that follows a soecification.
https://dgroupse.atlassian.net/browse/DIGG-472

Kopin1 and others added 30 commits December 3, 2024 11:32
data.terms.termsInfo = termsList
.map((t) => ({
title: getLocalizedValue(t.getAllMetadata(), "dcterms:title"),
url: t.getResourceURI().startsWith("https://dataportal.se")

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

'
https://dataportal.se
' may be followed by an arbitrary host name.

Copilot Autofix

AI 8 months ago

To fix the problem, we need to parse the URL and check its host value instead of using a simple string comparison. This ensures that the check handles arbitrary subdomain sequences correctly and prevents bypassing the security check.

  1. Parse the URL using the URL constructor to extract the host value.
  2. Compare the host value with the allowed host "dataportal.se".
  3. Update the relevant code in the file providers/entrystore-provider/index.tsx.
Suggested changeset 1
providers/entrystore-provider/index.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/providers/entrystore-provider/index.tsx b/providers/entrystore-provider/index.tsx
--- a/providers/entrystore-provider/index.tsx
+++ b/providers/entrystore-provider/index.tsx
@@ -566,3 +566,3 @@
               title: getLocalizedValue(t.getAllMetadata(), "dcterms:title"),
-              url: t.getResourceURI().startsWith("https://dataportal.se")
+              url: new URL(t.getResourceURI()).host === "dataportal.se"
                 ? new URL(t.getResourceURI()).pathname.replace(
EOF
@@ -566,3 +566,3 @@
title: getLocalizedValue(t.getAllMetadata(), "dcterms:title"),
url: t.getResourceURI().startsWith("https://dataportal.se")
url: new URL(t.getResourceURI()).host === "dataportal.se"
? new URL(t.getResourceURI()).pathname.replace(
Copilot is powered by AI and may make mistakes. Always verify output.
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