-
Notifications
You must be signed in to change notification settings - Fork 9
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: dataset update fix #276
Conversation
const removeConfigs = _.map(_.filter(newConfigs, {action: "remove"}), "value.field_key") | ||
const addConfigs = _.map(_.filter(newConfigs, {action: "upsert"}), "value") | ||
if (newConfigs) { | ||
const removeConfigs = _.map(_.filter(newConfigs, { action: "remove" }), "value.field_key") |
Check failure
Code scanning / CodeQL
Loop bound injection High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to ensure that the newConfigs
object is a valid array and has a reasonable length before using it in the loop. We can achieve this by adding a check to confirm that newConfigs
is an array and limiting its length to a safe maximum value.
- First, we will check if
newConfigs
is an array usingArray.isArray
. - Then, we will limit the length of
newConfigs
to a maximum value (e.g., 1000) to prevent potential DoS attacks.
-
Copy modified lines R158-R162
@@ -157,5 +157,7 @@ | ||
let updatedConfigs = currentConfigs; | ||
if (newConfigs && newConfigs.length) { | ||
const removeConfigs = _.map(_.filter(newConfigs, { action: "remove" }), "value.field_key") | ||
const addConfigs = _.map(_.filter(newConfigs, { action: "upsert" }), "value") | ||
if (Array.isArray(newConfigs) && newConfigs.length > 0) { | ||
const maxLength = 1000; | ||
const validNewConfigs = newConfigs.slice(0, maxLength); | ||
const removeConfigs = _.map(_.filter(validNewConfigs, { action: "remove" }), "value.field_key") | ||
const addConfigs = _.map(_.filter(validNewConfigs, { action: "upsert" }), "value") | ||
|
const addConfigs = _.map(_.filter(newConfigs, {action: "upsert"}), "value") | ||
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
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months 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 Array
. If it is not, we can either initialize it as an empty array or handle the error appropriately.
Steps to fix:
- Add a check to ensure
newConfigs
is an array before using it in the loop. - If
newConfigs
is not an array, initialize it as an empty array or handle the error.
-
Copy modified line R158
@@ -157,3 +157,3 @@ | ||
let updatedConfigs = currentConfigs; | ||
if (newConfigs && newConfigs.length) { | ||
if (Array.isArray(newConfigs) && newConfigs.length) { | ||
const removeConfigs = _.map(_.filter(newConfigs, { action: "remove" }), "value.field_key") |
const removeConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "remove"}), "value.denorm_out_field") | ||
const addConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "upsert"}), "value") | ||
if (newConfig) { | ||
const removeConfigs = _.map(_.filter(newConfig.denorm_fields, { action: "remove" }), "value.denorm_out_field") |
Check failure
Code scanning / CodeQL
Loop bound injection High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to ensure that newConfig.denorm_fields
is an array and limit its length to a reasonable number before iterating over it. This can be done by adding a validation check before the loop.
- Check if
newConfig.denorm_fields
is an array. - Limit the length of
newConfig.denorm_fields
to a reasonable maximum value (e.g., 1000) to prevent potential DoS attacks.
-
Copy modified lines R179-R182
@@ -178,5 +178,6 @@ | ||
let updatedConfigs = currentConfig.denorm_fields; | ||
if (_.get(newConfig, "denorm_fields")) { | ||
const removeConfigs = _.map(_.filter(newConfig.denorm_fields, { action: "remove" }), "value.denorm_out_field") | ||
const addConfigs = _.map(_.filter(newConfig.denorm_fields, { action: "upsert" }), "value") | ||
const denormFields = _.get(newConfig, "denorm_fields"); | ||
if (Array.isArray(denormFields) && denormFields.length <= 1000) { | ||
const removeConfigs = _.map(_.filter(denormFields, { action: "remove" }), "value.denorm_out_field") | ||
const addConfigs = _.map(_.filter(denormFields, { action: "upsert" }), "value") | ||
|
const addConfigs = _.map(_.filter(newConfig.denorm_fields, {action: "upsert"}), "value") | ||
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
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to ensure that newConfig.denorm_fields
is a valid array before using its length property in the loop. This can be done by adding a check to confirm that newConfig.denorm_fields
is an array and has a reasonable length. If it is not, we should handle the error appropriately.
-
Copy modified line R179
@@ -178,3 +178,3 @@ | ||
let updatedConfigs = currentConfig.denorm_fields; | ||
if (_.get(newConfig, "denorm_fields")) { | ||
if (_.get(newConfig, "denorm_fields") && Array.isArray(newConfig.denorm_fields) && newConfig.denorm_fields.length < 1000) { // Validate newConfig.denorm_fields | ||
const removeConfigs = _.map(_.filter(newConfig.denorm_fields, { action: "remove" }), "value.denorm_out_field") |
@@ -178,8 +190,8 @@ | |||
|
|||
const mergeConnectorsConfig = (currConfigs: any, newConfigs: any) => { | |||
|
|||
const removeConfigs = _.map(_.filter(newConfigs, {action: "remove"}), "value.connector_id") | |||
const addConfigs = _.map(_.filter(newConfigs, {action: "upsert"}), "value") | |||
const removeConfigs = _.map(_.filter(newConfigs, { action: "remove" }), "value.connector_id") |
Check failure
Code scanning / CodeQL
Loop bound injection High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months 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 an error response.
-
Copy modified lines R201-R204
@@ -200,2 +200,6 @@ | ||
|
||
if (!Array.isArray(newConfigs)) { | ||
throw new Error("Invalid input: newConfigs should be an array"); | ||
} | ||
|
||
const removeConfigs = _.map(_.filter(newConfigs, { action: "remove" }), "value.connector_id") |
const removeConfigs = _.map(_.filter(newConfigs, {action: "remove"}), "value.connector_id") | ||
const addConfigs = _.map(_.filter(newConfigs, {action: "upsert"}), "value") | ||
const removeConfigs = _.map(_.filter(newConfigs, { action: "remove" }), "value.connector_id") | ||
const addConfigs = _.map(_.filter(newConfigs, { action: "upsert" }), "value") |
Check failure
Code scanning / CodeQL
Loop bound injection High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to ensure that newConfigs
is an array before using its .length
property in a loop. This can be done by adding a check to confirm that newConfigs
is an instance of Array
. If it is not, we should handle the error appropriately, such as returning an empty array or throwing an error.
-
Copy modified lines R201-R204
@@ -200,2 +200,6 @@ | ||
|
||
if (!(newConfigs instanceof Array)) { | ||
throw new Error("Invalid input: newConfigs must be an array"); | ||
} | ||
|
||
const removeConfigs = _.map(_.filter(newConfigs, { action: "remove" }), "value.connector_id") |
) | ||
} | ||
|
||
const mergeTags = (currentTags: any, newConfigs: any) => { | ||
|
||
const tagsToRemove = _.map(_.filter(newConfigs, {action: "remove"}), "value") | ||
const tagsToAdd = _.map(_.filter(newConfigs, {action: "upsert"}), "value") | ||
const tagsToRemove = _.map(_.filter(newConfigs, { action: "remove" }), "value") |
Check failure
Code scanning / CodeQL
Loop bound injection High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to ensure that newConfigs
is an array before using its .length
property in a loop. This can be done by adding a check to verify that newConfigs
is an instance of Array
. If it is not, we should handle the error appropriately, such as returning an empty array or throwing an error.
-
Copy modified lines R223-R226
@@ -222,2 +222,6 @@ | ||
|
||
if (!(newConfigs instanceof Array)) { | ||
throw new Error("Invalid input: newConfigs must be an array"); | ||
} | ||
|
||
const tagsToRemove = _.map(_.filter(newConfigs, { action: "remove" }), "value") |
const tagsToRemove = _.map(_.filter(newConfigs, {action: "remove"}), "value") | ||
const tagsToAdd = _.map(_.filter(newConfigs, {action: "upsert"}), "value") | ||
const tagsToRemove = _.map(_.filter(newConfigs, { action: "remove" }), "value") | ||
const tagsToAdd = _.map(_.filter(newConfigs, { action: "upsert" }), "value") |
Check failure
Code scanning / CodeQL
Loop bound injection High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 months ago
To fix the problem, we need to ensure that newConfigs
is an array before using its .length
property in a loop. This can be done by adding a check to verify that newConfigs
is an instance of an array. If it is not, we should handle the error appropriately, such as returning an empty array or throwing an error.
-
Copy modified lines R223-R226
@@ -222,2 +222,6 @@ | ||
|
||
if (!Array.isArray(newConfigs)) { | ||
throw new Error("Invalid input: newConfigs must be an array"); | ||
} | ||
|
||
const tagsToRemove = _.map(_.filter(newConfigs, { action: "remove" }), "value") |
No description provided.