Skip to content

Adding a Pre-Commit Hook - #334

Merged
cs-raj merged 6 commits into
developmentfrom
fix/snyk
Jul 31, 2025
Merged

Adding a Pre-Commit Hook#334
cs-raj merged 6 commits into
developmentfrom
fix/snyk

Conversation

@cs-raj

@cs-raj cs-raj commented Apr 17, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@cs-raj
cs-raj requested a review from a team as a code owner April 17, 2025 11:29
@cs-raj
cs-raj requested review from harshithad0703 and nadeem-cs and removed request for a team and nadeem-cs April 17, 2025 11:29
Comment thread src/core/lib/utils.js
} else if (self._type(source[key]) == 'array' && self._type(target[key]) == self._type(source[key])) {
target[key] = target[key].concat(source[key]);
} else {
target[key] = source[key];

Check warning

Code scanning / CodeQL

Prototype-polluting function

Properties are copied from [source](1) to [target](2) without guarding against prototype pollution.

Copilot Autofix

AI about 1 year ago

To fix the issue, we need to prevent prototype pollution by adding safeguards in the _merge_recursive function. Specifically:

  1. Block the special keys __proto__ and constructor from being copied.
  2. Ensure that only "own" properties of the source object are processed by using Object.hasOwnProperty.

This fix will ensure that the function does not inadvertently modify Object.prototype or other sensitive objects.


Suggested changeset 1
src/core/lib/utils.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/src/core/lib/utils.js b/src/core/lib/utils.js
--- a/src/core/lib/utils.js
+++ b/src/core/lib/utils.js
@@ -68,2 +68,4 @@
     for (const key in source) {
+      if (!Object.prototype.hasOwnProperty.call(source, key)) continue;
+      if (key === '__proto__' || key === 'constructor') continue;
       if (self._type(source[key]) == 'object' && self._type(target[key]) == self._type(source[key])) {
EOF
@@ -68,2 +68,4 @@
for (const key in source) {
if (!Object.prototype.hasOwnProperty.call(source, key)) continue;
if (key === '__proto__' || key === 'constructor') continue;
if (self._type(source[key]) == 'object' && self._type(target[key]) == self._type(source[key])) {
Copilot is powered by AI and may make mistakes. Always verify output.

@sunil-lakshman sunil-lakshman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cs-raj
cs-raj merged commit 998b450 into development Jul 31, 2025
@cs-raj
cs-raj deleted the fix/snyk branch July 31, 2025 05:01
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