Skip to content

fix(vscode-ide-companion): correct license generation for workspace dependencies#15004

Merged
skeshive merged 1 commit intomainfrom
fix/vscode-companion-license-generation
Dec 12, 2025
Merged

fix(vscode-ide-companion): correct license generation for workspace dependencies#15004
skeshive merged 1 commit intomainfrom
fix/vscode-companion-license-generation

Conversation

@skeshive
Copy link
Copy Markdown
Contributor

@skeshive skeshive commented Dec 12, 2025

TLDR

Updated packages/vscode-ide-companion/scripts/generate-notices.js to correctly prioritize and resolve workspace-local dependencies (like express@5.1.0) over root dependencies. Regenerated NOTICES.txt to reflect the accurate dependency tree for the VS Code extension.

Dive Deeper

The previous license generation script was incorrectly resolving dependencies by looking at the root node_modules first or defaulting to root entries in package-lock.json. This caused issues where the script would pick up versions of packages used in the root workspace (e.g., express@4.21.2) instead of the versions actually bundled with the extension (e.g., express@5.1.0).

This PR fixes the issue by:

  1. Prioritizing Local Modules: The script now checks for package.json in the workspace's node_modules before falling back to the root.
  2. Scope-Aware Lockfile Lookup: collectDependencies now attempts to find package entries under the workspace's path in package-lock.json (e.g., packages/vscode-ide-companion/node_modules/express) before checking the global scope.
  3. Updating Notices: NOTICES.txt has been regenerated. It now correctly lists express@5.1.0 and its specific transitive dependencies (including new ones like is-promise and excluding unused ones like methods), ensuring compliance for the bundled extension.

@skeshive skeshive requested a review from a team as a code owner December 12, 2025 18:52
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @skeshive, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where the license generation script for the VS Code extension was incorrectly identifying dependency versions, leading to an inaccurate NOTICES.txt file. The changes ensure that workspace-specific dependencies are correctly resolved and prioritized, resulting in a legally compliant and accurate list of bundled software licenses.

Highlights

  • Dependency Resolution Logic: The script for generating license notices (generate-notices.js) has been updated to correctly prioritize and resolve workspace-local dependencies, ensuring that the versions bundled with the VS Code extension are accurately identified.
  • Local Module Prioritization: The getDependencyLicense function now explicitly checks for package.json files within the workspace's node_modules directory before falling back to the root node_modules, preventing incorrect version detection.
  • Scope-Aware Lockfile Lookup: The collectDependencies function has been enhanced to perform package-lock.json lookups with awareness of the workspace's relative path, ensuring that package entries specific to the workspace are found first.
  • NOTICES.txt Regeneration: The NOTICES.txt file has been regenerated to reflect the accurate dependency tree, including the correct express@5.1.0 version and its specific transitive dependencies, ensuring legal compliance for the bundled extension.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@skeshive skeshive enabled auto-merge December 12, 2025 18:53
@github-actions
Copy link
Copy Markdown

Size Change: -2 B (0%)

Total Size: 21.6 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 21.6 MB -2 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug in the license generation script, correcting how it resolves dependencies to prioritize workspace-local package.json and package-lock.json entries. However, a high-severity Path Traversal vulnerability was identified in the generate-notices.js script, which could allow an attacker with commit access to read arbitrary files from the build environment due to unsafe path construction using dependency names from package.json without proper sanitization. Additionally, an area for improvement was noted regarding the robustness of file existence checks, which could benefit from more specific and reliable error handling.

Comment on lines +23 to 34
const localDepPath = path.join(
packagePath,
'node_modules',
depName,
'package.json',
);
const rootDepPath = path.join(
projectRoot,
'node_modules',
depName,
'package.json',
);
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.

security-high high

The depName variable, sourced from package.json, is used directly in path.join to construct file paths. This introduces a Path Traversal vulnerability. A malicious actor with commit access could craft a dependency name in package.json (e.g., "../../../../etc/passwd") to read arbitrary files from the system running the script. The file contents would then be embedded in the generated NOTICES.txt file.

Remediation:
Sanitize depName before use. Ensure the variable contains only valid package name characters and does not contain directory traversal sequences like ../. You can achieve this by validating the name against a strict regular expression or by ensuring that the resolved path is located within the expected parent directory.

Comment thread packages/vscode-ide-companion/scripts/generate-notices.js
@skeshive skeshive added this pull request to the merge queue Dec 12, 2025
Merged via the queue into main with commit e84c4bf Dec 12, 2025
20 checks passed
@skeshive skeshive deleted the fix/vscode-companion-license-generation branch December 12, 2025 19:18
thacio added a commit to thacio/auditaria that referenced this pull request Dec 13, 2025
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.

2 participants