Skip to content

【WIP】Refactor/remove vgrammar#3748

Merged
xiaoluoHe merged 11 commits intodev/2.0.0from
refactor/remove-vgrammar
Mar 19, 2025
Merged

【WIP】Refactor/remove vgrammar#3748
xiaoluoHe merged 11 commits intodev/2.0.0from
refactor/remove-vgrammar

Conversation

@xile611
Copy link
Contributor

@xile611 xile611 commented Feb 20, 2025

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Release
  • Site / documentation update
  • Demo update
  • Workflow
  • Other (about what?)

🔗 Related issue link

🔗 Related PR link

🐞 Bugserver case id

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@xile611 xile611 force-pushed the refactor/remove-vgrammar branch 14 times, most recently from 1cd8f99 to 5eefaad Compare February 26, 2025 07:59
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
stateStyle[state][attr] = {
this.stateStyle[state][attr] = {

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
stateStyle[state][key as keyof T] = stateStyle.normal[key];
this.stateStyle[state][key as keyof T] = this.stateStyle.normal[key];

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.

Copilot Autofix

AI 12 months ago

To fix the prototype pollution vulnerability, we need to ensure that the state parameter cannot be one of the special property names (__proto__, constructor, prototype). We can achieve this by adding a validation check before using the state parameter as a key in the this.stateStyle object. If the state parameter matches any of these special property names, we should throw an error or handle it appropriately.

Suggested changeset 1
packages/vchart/src/mark/base/base-mark.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/packages/vchart/src/mark/base/base-mark.ts b/packages/vchart/src/mark/base/base-mark.ts
--- a/packages/vchart/src/mark/base/base-mark.ts
+++ b/packages/vchart/src/mark/base/base-mark.ts
@@ -681,2 +681,5 @@
   ) {
+    if (state === '__proto__' || state === 'constructor' || state === 'prototype') {
+      throw new Error('Invalid state value');
+    }
     if (this.stateStyle[state] === undefined) {
EOF
@@ -681,2 +681,5 @@
) {
if (state === '__proto__' || state === 'constructor' || state === 'prototype') {
throw new Error('Invalid state value');
}
if (this.stateStyle[state] === undefined) {
Copilot is powered by AI and may make mistakes. Always verify output.
@xile611 xile611 force-pushed the refactor/remove-vgrammar branch 7 times, most recently from ad58075 to 168aff6 Compare February 27, 2025 10:56
@xile611 xile611 changed the base branch from develop to dev/2.0.0 March 19, 2025 02:05
@xiaoluoHe xiaoluoHe merged commit 2c1355e into dev/2.0.0 Mar 19, 2025
4 of 5 checks passed
@xiaoluoHe xiaoluoHe deleted the refactor/remove-vgrammar branch March 19, 2025 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants