Skip to content

fix: check file names and zip entries when installing the language server - #592

Open
dungdong-aws wants to merge 4 commits into
Amazon-Q-Developer:mainfrom
dungdong-aws:fix/lsp-artifact-path-validation
Open

dungdong-aws wants to merge 4 commits into
Amazon-Q-Developer:mainfrom
dungdong-aws:fix/lsp-artifact-path-validation

Conversation

@dungdong-aws

@dungdong-aws dungdong-aws commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The language server installer uses server versions and content file names from the manifest as folder and file names under the download location, and writes zip entries under the folder a zip is extracted to. This change checks those names before they are used.

Change

  • RemoteLspFetcher: a version is selected only when its name is a single path segment, and a content file is downloaded or reused from the cache only when its name is a single path segment.
  • RemoteLspFetcher: a zip is extracted to a folder named after the zip, and it is extracted only when that folder name is a single path segment (resolveUnzipFolder). This applies to every zip that is extracted.
  • ArtifactUtils.extractFile and copyMissingFilesFromZip: every zip entry must be located inside its destination folder, and only a directory entry may be the destination folder itself (ArtifactUtils.resolveZipEntry).
  • A content file or zip that does not pass is handled like a failed download, so the next compatible cached version is used.
  • The fallback version is selected without reading the name of manifest entries that have none.

Behavior after this change

  • Installing, reusing the cache, falling back to an older cached version and cleaning up old versions work as before for the published manifest (versions such as 1.87.0, files servers.zip and clients.zip) and for pre-release versions such as 1.83.0-branch.sha.
  • Installed files and extracted zip entries are located inside the version folder being installed.

Testing

  • ArtifactUtilsTest: entries with relative segments that are located inside the destination are extracted; entries located elsewhere, and file entries at the destination folder itself, fail the extraction and nothing is written for them; copyMissingFilesFromZip keeps existing files and adds the missing ones.
  • RemoteLspFetcherTest: content file names, zip folder names and server versions that are not a single path segment are not downloaded, not reused from the cache, and not selected; a content file name that starts with a dot installs; fallback works when a manifest entry has no version name.
  • mvn -B clean package: build passes, 562 tests, 0 Checkstyle violations.

…rver

Server versions and content file names from the manifest are used as
folder and file names under the download location, and zip entries are
written under the folder the zip is extracted to.

Select a version only when its name is a single path segment, download
or reuse a content file only when its name is a single path segment, and
extract a zip only when every entry is located inside its destination
folder. A content file or zip that does not pass is handled like a
failed download.
A file entry in a zip is extracted only when it is located below the
destination folder. A directory entry may still be the destination
folder itself.
A zip content file is extracted to a folder named after the zip without
its extension. Use the content file only when that folder name is a
single path segment as well.
The folder a zip is extracted to is named after the zip, also for a zip
that is found inside an extracted zip. Extract a zip only when that
folder name is a single path segment.

Also select the fallback version without reading the name of manifest
entries that have none.
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.

1 participant