feat: add vscode-extensions-cataloger (anchore/grype#2851)#4864
Open
ChrisJr404 wants to merge 1 commit into
Open
feat: add vscode-extensions-cataloger (anchore/grype#2851)#4864ChrisJr404 wants to merge 1 commit into
ChrisJr404 wants to merge 1 commit into
Conversation
Catalogs Visual Studio Code extensions installed in user profiles by parsing the registry file at .vscode/extensions/extensions.json (and the equivalent .vscode-server path for remote/SSH/Codespaces installs). This lands the syft side of anchore/grype#2851. Each extension becomes a pkg.Package with: - Name = canonical "<publisher>.<name>" id (matches what `code --install-extension` accepts and what settings.json references) - Version = installed version - Type = new pkg.VscodeExtensionPkg ("vscode-extension") - PURL = pkg:vscode-extension/<publisher>/<name>@<version> - Metadata = new pkg.VscodeExtensionEntry with publisher, marketplace uuid, isBuiltin, isPreReleaseVersion, and targetPlatform when set There is no formally registered package-url type for VSCode extensions in the upstream PURL spec yet; "vscode-extension" is the descriptive form already used in community SBOM tooling. If/when the spec adopts a different name, the change is local to syft/pkg/type.go and the cataloger's packageURL helper. Selectors: directory, image, installed, vscode, vscode-extension, editor — so default scans pick it up without explicit opt-in. Tests cover: - a realistic extensions.json with marketplace, builtin, prerelease, scoped publisher, and platform-specific entries - a malformed fixture mixing valid and invalid records (missing dot in id, leading/trailing dot, missing version) — only valid records are emitted, malformed ones silently skipped - splitExtensionID unit tests covering edge cases Worth noting: as @westonsteimel pointed out on the issue, the GHSA advisories for VSCode are not currently structured for direct package- name matching, so grype won't surface vulns for these extensions today. The cataloger output is still useful on its own for SBOM coverage of developer tooling that bypasses distro/admin package controls. Signed-off-by: Chris (ChrisJr404) <11917633+ChrisJr404@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the syft side of anchore/grype#2851 — a cataloger for installed Visual Studio Code extensions, sourced from the user-extensions registry file
.vscode/extensions/extensions.json(and the matching.vscode-server/...path used by remote / SSH / Codespaces installs, which has the identical schema).@spiffcs marked the issue as good-first-issue and noted SBOM coverage of developer tooling installed outside the distro / admin path is the value here. @westonsteimel correctly flagged that the GHSA advisories for VSCode aren't currently structured for direct package-name matching, so grype won't surface vulnerabilities for these extensions today — but the catalog half is still useful on its own and unblocks any future matcher work.
What's added
syft/pkg/cataloger/vscode/cataloger.govscode-extensions-catalogerregistered against**/.vscode/extensions/extensions.jsonand**/.vscode-server/extensions/extensions.jsonsyft/pkg/cataloger/vscode/parse_extensions_json.gopkg.Packagematerializationsyft/pkg/cataloger/vscode/parse_extensions_json_test.gosplitExtensionIDunit testssyft/pkg/cataloger/vscode/testdata/...syft/pkg/vscode.gopkg.VscodeExtensionEntrymetadata typesyft/pkg/type.goVscodeExtensionPkgwith PURL type\"vscode-extension\"internal/task/package_tasks.godirectory,installed,image,vscode,vscode-extension,editorPer-extension
pkg.Packageshape<publisher>.<name>id, e.g.github.copilot-chat. Matches whatcode --install-extensionaccepts and whatsettings.jsonreferences.pkg.VscodeExtensionPkg(vscode-extension)pkg:vscode-extension/<publisher>/<name>@<version>pkg.VscodeExtensionEntrywith publisher, marketplace UUID,publisherDisplayName,isBuiltin,isPreReleaseVersion, andtargetPlatform(when not the cross-platform sentinel\"undefined\")PURL choice
There's no formally registered PURL type for VSCode extensions in the upstream package-url spec yet. I went with
pkg:vscode-extension/...because:vscode-extensionis unambiguous (won't collide with hypothetical futurevscode-*types)syft/pkg/type.goand one helperOpen to renaming to
pkg:vscode/...(shorter) orpkg:generic/...?type=vscode-extension(most conservative) if maintainers prefer one of those.Tests
TestParseExtensionsJSONms-vscode.cpptools-extension-pack), prerelease flag, target-platform handlingTestParseExtensionsJSON_MalformedTestSplitExtensionID<publisher>.<name>parser — first-dot delimiter, multi-dot names, empty / leading-dot / trailing-dot inputsTestTypeFromPURL(extended)Test plan
go test ./syft/pkg/cataloger/vscode/...passesgo test ./syft/pkg ./internal/packagemetadata ./internal/taskpassesgo generate ./internal/...produces only intended diffs (capabilities + metadata generated; reverted the unrelated whitespace churngofmt -s -wintroduces ininternal/spdxlicense/license_list.go)cd internal/jsonschema && go run .cleanly emits the newschema-16.1.4.json(additive bump per SchemaVer; only addsJavascriptBunLockEntry... wait no, only addsVscodeExtensionEntry)