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

FLAG-1263: Data mart api client #4966

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft

FLAG-1263: Data mart api client #4966

wants to merge 4 commits into from

Conversation

wri7tno
Copy link
Collaborator

@wri7tno wri7tno commented Mar 19, 2025

Overview

Brief description of what this PR does, and why it is needed.

Demo

If applicable: screenshots, gifs, etc.

Notes

If applicable: ancilary topics, caveats, alternative strategies that didn't work out, etc.

Testing

  • Include any steps to verify the features this PR introduces.
  • If this fixes a bug, include bug reproduction steps.

return;
}

if (slugs.length === 1) {

Check failure

Code scanning / CodeQL

Type confusion through parameter tampering Critical

Potential type confusion as
this HTTP request parameter
may be either an array or a string.

Copilot Autofix AI 6 days ago

To fix the problem, we need to ensure that the slugs parameter is always treated as an array of strings. We can do this by checking the type of slugs and converting it to an array if it is not already one. This will prevent type confusion attacks and ensure that the code behaves as expected.

We will modify the fetchDataByDatasetAndGeostore and postData functions to include type checks and conversions for the slugs parameter. Specifically, we will:

  1. Check if slugs is an array. If not, convert it to an array containing the single value.
  2. Proceed with the existing logic, which assumes slugs is an array.
Suggested changeset 1
pages/api/datamart/v0/land/[...slug].js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/pages/api/datamart/v0/land/[...slug].js b/pages/api/datamart/v0/land/[...slug].js
--- a/pages/api/datamart/v0/land/[...slug].js
+++ b/pages/api/datamart/v0/land/[...slug].js
@@ -40,3 +40,4 @@
   // TODO: add more parameters to the query like, global, adm9, adm1, etc etc etc
-  const { slug: slugs, geostore_id, canopy_cover } = query;
+  const { slug: slugsParam, geostore_id, canopy_cover } = query;
+  const slugs = Array.isArray(slugsParam) ? slugsParam : [slugsParam];
 
@@ -78,3 +79,4 @@
   // TODO: add more parameters to the query like, global, adm9, adm1, etc etc etc
-  const { slug: slugs, geostore_id, canopy_cover } = query;
+  const { slug: slugsParam, geostore_id, canopy_cover } = query;
+  const slugs = Array.isArray(slugsParam) ? slugsParam : [slugsParam];
 
EOF
@@ -40,3 +40,4 @@
// TODO: add more parameters to the query like, global, adm9, adm1, etc etc etc
const { slug: slugs, geostore_id, canopy_cover } = query;
const { slug: slugsParam, geostore_id, canopy_cover } = query;
const slugs = Array.isArray(slugsParam) ? slugsParam : [slugsParam];

@@ -78,3 +79,4 @@
// TODO: add more parameters to the query like, global, adm9, adm1, etc etc etc
const { slug: slugs, geostore_id, canopy_cover } = query;
const { slug: slugsParam, geostore_id, canopy_cover } = query;
const slugs = Array.isArray(slugsParam) ? slugsParam : [slugsParam];

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