Skip to content

Comments

chore: resolutions underscore#133

Open
GeoDaoyu wants to merge 1 commit intoant-design:masterfrom
GeoDaoyu:fix/underscore-version
Open

chore: resolutions underscore#133
GeoDaoyu wants to merge 1 commit intoant-design:masterfrom
GeoDaoyu:fix/underscore-version

Conversation

@GeoDaoyu
Copy link

@GeoDaoyu GeoDaoyu commented Jul 12, 2025

Fix #132

我在package.json中看到是锁定了underscore的版本,已经升级到1.12.0了

  "resolutions": {
    "underscore": "1.12.0"
  },

但是我安装之后发现版本还是1.7.0

geodaoyu@anonymous playground % yarn why underscore 
yarn why v1.22.22
[1/4] 🤔  Why do we have the module "underscore"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "underscore@1.7.0"
info Reasons this module exists
   - "@ant-design#pro-cli#pngjs-image" depends on it
   - Hoisted from "@ant-design#pro-cli#pngjs-image#underscore"
   - Hoisted from "@ant-design#pro-cli#blink-diff#preceptor-core#underscore"
info Disk size without dependencies: "76KB"
info Disk size with unique dependencies: "76KB"
info Disk size with transitive dependencies: "76KB"
info Number of shared dependencies: 0
✨  Done in 0.23s.

应该是yarn 深层嵌套依赖之后的范围问题。我把resolutions写成**了。但是没有test指令,我不能确定功能是否正常。

Summary by CodeRabbit

  • 杂项
    • 扩大了对 "underscore" 依赖项的版本锁定范围,现在将应用于所有层级的 "underscore" 包。

@coderabbitai
Copy link

coderabbitai bot commented Jul 12, 2025

📝 Walkthrough

Walkthrough

本次变更仅修改了 package.json 文件,将 "resolutions" 字段中的 "underscore" 键修改为 "**/underscore",以确保依赖树中所有层级的 underscore 包都能被统一锁定到指定版本。除此之外未做其他更改。

Changes

文件 变更摘要
package.json 修改 "resolutions" 字段,将 "underscore" 改为 "**/underscore",并新增文件末尾换行符

Assessment against linked issues

Objective Addressed Explanation
确保所有依赖树中的 underscore 包均不再使用受漏洞影响的 1.7.0 版本(#132

Assessment against linked issues: Out-of-scope changes

(无发现超出已关联 issue 目标范围的更改)

Poem

小兔挥笔改 package,
星号点亮全依赖。
underscore 不再怕,
漏洞远离家门外。
依赖安全齐欢笑,
代码森林更自在!
🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
package.json (1)

16-18: 考虑直接锁定到 1.13.x 以修复已知安全漏洞
underscore ≤1.12 系列仍存在 Prototype Pollution 等 CVE,社区目前维护的安全版本为 1.13.6(2024-05 发布)。如果上游依赖未限制主版本,建议改为:

-    "**/underscore": "1.12.0"
+    "**/underscore": "1.13.6"

以提前消除安全隐患,再通过 CI 验证兼容性。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26890f4 and dba76bc.

📒 Files selected for processing (1)
  • package.json (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (1)
package.json (1)

16-18: 确认已同步更新 yarn.lock 并验证生效
underscore 改成 "**/underscore" 能覆盖深层依赖,思路正确。但只有在重新执行 yarn install 并把生成的 yarn.lock 变更一起提交后,团队才能真正得到 1.12.0 的锁定效果。请运行

yarn install --check-files
yarn why underscore

确认输出只剩 1.12.0,再把 yarn.lock 的变更一并提交。

@afc163
Copy link
Member

afc163 commented Jul 12, 2025

删掉 resolutions 如何?

@GeoDaoyu
Copy link
Author

删除resolutions???我没有明白,是要换解决方案来升级underscore吗?比如换用依赖了低版本underscore的库?

我单独写了一个简单的测试
package.json:

  "dependencies": {
    "pngjs-image": "^0.11.7",
    "underscore": "1.13.0"
  }

不写resolutions时

输出:

geodaoyu@anonymous resolutions % yarn list underscore                  
yarn list v1.22.22
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ pngjs-image@0.11.7
│  └─ underscore@1.7.0
└─ underscore@1.13.0
✨  Done in 0.04s.

resolutions不写嵌套时

即:

  "resolutions": {
    "underscore": "1.12.0"
  },

输出:

geodaoyu@anonymous resolutions % yarn list underscore
yarn list v1.22.22
warning Resolution field "underscore@1.12.0" is incompatible with requested version "underscore@1.7.0"
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ pngjs-image@0.11.7
│  └─ underscore@1.12.0
└─ underscore@1.13.0
✨  Done in 0.04s.

resolutions写嵌套时

即:

  "resolutions": {
    "**/underscore": "1.12.0"
  },

输出:

geodaoyu@anonymous resolutions % yarn list underscore
yarn list v1.22.22
warning Resolution field "underscore@1.12.0" is incompatible with requested version "underscore@1.7.0"
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ pngjs-image@0.11.7
│  └─ underscore@1.12.0
└─ underscore@1.13.0
✨  Done in 0.06s.

结论

resolutions中需要加**处理嵌套依赖。可以解决问题。
但是不知道对pro-cli的影响。

@GeoDaoyu
Copy link
Author

删掉 resolutions 如何?

你想用pnpm.overrides?

@GeoDaoyu
Copy link
Author

@afc163 还有一种办法,就是重写 screenshot 模块,把 blink-diff 和 pngjs-image 这两个9年前就停止更新的库取消了。那么整个项目都没有依赖underscore了。

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.

Security issue: underscore@1.7.0 with critical vulnerability used

2 participants