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

#OBS-I335: hudi spec fix #275

Merged
merged 6 commits into from
Nov 12, 2024
Merged

#OBS-I335: hudi spec fix #275

merged 6 commits into from
Nov 12, 2024

Conversation

JeraldJF
Copy link

No description provided.


let updatedConfigs = currentConfigs;
if(newConfigs) {
const removeConfigs = _.map(_.filter(newConfigs, {action: "remove"}), "value.field_key")

Check failure

Code scanning / CodeQL

Loop bound injection High

Iteration over a user-controlled object with a potentially unbounded .length property from a
user-provided value
.

Copilot Autofix AI about 1 month ago

To fix the problem, we need to ensure that newConfigs is an array before using its .length property in the loop. This can be done by adding a check to confirm that newConfigs is an array. If it is not, we can either return an empty array or handle the error appropriately.

Suggested changeset 1
api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts b/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
--- a/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
+++ b/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
@@ -137,3 +137,3 @@
     let updatedConfigs = currentConfigs;
-    if(newConfigs) {
+    if(Array.isArray(newConfigs)) {
         const removeConfigs = _.map(_.filter(newConfigs, {action: "remove"}), "value.field_key")
EOF
@@ -137,3 +137,3 @@
let updatedConfigs = currentConfigs;
if(newConfigs) {
if(Array.isArray(newConfigs)) {
const removeConfigs = _.map(_.filter(newConfigs, {action: "remove"}), "value.field_key")
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
let updatedConfigs = currentConfigs;
if(newConfigs) {
const removeConfigs = _.map(_.filter(newConfigs, {action: "remove"}), "value.field_key")
const addConfigs = _.map(_.filter(newConfigs, {action: "upsert"}), "value")

Check failure

Code scanning / CodeQL

Loop bound injection High

Iteration over a user-controlled object with a potentially unbounded .length property from a
user-provided value
.

Copilot Autofix AI about 1 month ago

To fix the problem, we need to ensure that newConfigs is an array before using its .length property in the loop. This can be done by adding a check to confirm that newConfigs is an instance of an array. If it is not, we should handle the error appropriately, possibly by returning an empty array or throwing an error.

Suggested changeset 1
api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts b/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
--- a/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
+++ b/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
@@ -137,3 +137,3 @@
     let updatedConfigs = currentConfigs;
-    if(newConfigs) {
+    if(Array.isArray(newConfigs)) {
         const removeConfigs = _.map(_.filter(newConfigs, {action: "remove"}), "value.field_key")
EOF
@@ -137,3 +137,3 @@
let updatedConfigs = currentConfigs;
if(newConfigs) {
if(Array.isArray(newConfigs)) {
const removeConfigs = _.map(_.filter(newConfigs, {action: "remove"}), "value.field_key")
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
const addConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "upsert"}), "value")
let updatedConfigs = currentConfig.denorm_fields;
if(newConfig) {
const removeConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "remove"}), "value.denorm_out_field")

Check failure

Code scanning / CodeQL

Loop bound injection High

Iteration over a user-controlled object with a potentially unbounded .length property from a
user-provided value
.

Copilot Autofix AI about 1 month ago

To fix the problem, we need to ensure that newConfig.denorm_fields is a valid array and has a reasonable length before iterating over it. This can be done by adding a check to confirm that newConfig.denorm_fields is an array and limiting its length to a safe maximum value.

  • Add a check to ensure newConfig.denorm_fields is an array.
  • Limit the length of newConfig.denorm_fields to a safe maximum value (e.g., 1000).
Suggested changeset 1
api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts b/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
--- a/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
+++ b/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
@@ -159,2 +159,5 @@
     if(newConfig) {
+        if (!Array.isArray(newConfig.denorm_fields) || newConfig.denorm_fields.length > 1000) {
+            throw new Error("Invalid denorm_fields");
+        }
         const removeConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "remove"}), "value.denorm_out_field")
EOF
@@ -159,2 +159,5 @@
if(newConfig) {
if (!Array.isArray(newConfig.denorm_fields) || newConfig.denorm_fields.length > 1000) {
throw new Error("Invalid denorm_fields");
}
const removeConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "remove"}), "value.denorm_out_field")
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
let updatedConfigs = currentConfig.denorm_fields;
if(newConfig) {
const removeConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "remove"}), "value.denorm_out_field")
const addConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "upsert"}), "value")

Check failure

Code scanning / CodeQL

Loop bound injection High

Iteration over a user-controlled object with a potentially unbounded .length property from a
user-provided value
.

Copilot Autofix AI about 1 month ago

To fix the problem, we need to ensure that newConfig.denorm_fields is an array before using its .length property in the loop. This can be done by adding a check to verify that newConfig.denorm_fields is an array. If it is not, we can either throw an error or handle it gracefully by setting it to an empty array.

Suggested changeset 1
api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts b/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
--- a/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
+++ b/api-service/src/controllers/DatasetUpdate/DatasetUpdate.ts
@@ -159,2 +159,5 @@
     if(newConfig) {
+        if (!Array.isArray(newConfig.denorm_fields)) {
+            throw new Error("Invalid input: denorm_fields should be an array");
+        }
         const removeConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "remove"}), "value.denorm_out_field")
EOF
@@ -159,2 +159,5 @@
if(newConfig) {
if (!Array.isArray(newConfig.denorm_fields)) {
throw new Error("Invalid input: denorm_fields should be an array");
}
const removeConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "remove"}), "value.denorm_out_field")
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
@HarishGangula HarishGangula merged commit 1d2fec8 into main Nov 12, 2024
1 of 3 checks passed
@HarishGangula HarishGangula deleted the hudi-spec-fix branch November 12, 2024 15:15
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