Skip to content

feat(nodejs): add a bun.lock analyzer #8897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 28, 2025

Conversation

sneaky-potato
Copy link
Contributor

@sneaky-potato sneaky-potato commented May 21, 2025

Description

This PR adds an analyzer for bun.lock file; thereby adding support to scan repositories developed using bun

Run trivy fs . in a repository containing bun.lock file to generate a summary report of vulnerabilities. You may also use trivy fs . --include-dev-deps to include scanned information about development dependencies.

$ ./trivy -q fs ./pkg/fanal/analyzer/language/nodejs/bun/testdata/happy -f json --list-all-pkgs | jq '.Results[].Packages[]'                                       
{
  "ID": "[email protected]",
  "Name": "typescript",
  "Identifier": {
    "PURL": "pkg:npm/[email protected]",
    "UID": "4aa84f523f4d97b2"
  },
  "Version": "5.8.3",
  "Licenses": [
    "Apache-2.0"
  ],
  "Relationship": "direct",
  "Layer": {},
  "Locations": [
    {
      "StartLine": 24,
      "EndLine": 24
    }
  ]
}
{
  "ID": "[email protected]",
  "Name": "zod",
  "Identifier": {
    "PURL": "pkg:npm/[email protected]",
    "UID": "12b7c6a46de41c88"
  },
  "Version": "3.24.4",
  "Licenses": [
    "MIT"
  ],
  "Relationship": "direct",
  "Layer": {},
  "Locations": [
    {
      "StartLine": 28,
      "EndLine": 28
    }
  ]
}

Related issues

Related PRs

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@sneaky-potato sneaky-potato marked this pull request as draft May 21, 2025 12:43
@DmitriyLewen
Copy link
Contributor

Hello @sneaky-potato
Thanks for your work!

Don't forget to update docs and purl package.
Also will be great if you add testcase in repo_test.go for bun.lock file.

@sneaky-potato sneaky-potato marked this pull request as ready for review May 23, 2025 10:29
@knqyf263 knqyf263 requested a review from Copilot May 26, 2025 05:33
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for analyzing bun.lock files for vulnerability scanning by adding a dedicated analyzer for Bun.

  • Added support for ftypes.Bun in package URL handling and vulnerability detection.
  • Implemented a new bun analyzer with accompanying test cases and integration test fixtures.
  • Updated various constants, imports, and routing logic to accommodate Bun analysis.

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/purl/purl_test.go Added a new test case for converting bun package URLs.
pkg/purl/purl.go Extended URL handling to include ftypes.Bun.
pkg/fanal/types/const.go Defined a new constant for bun.lock filenames.
pkg/fanal/analyzer/language/nodejs/bun/bun_test.go Added tests for the bun analyzer functionality.
pkg/fanal/analyzer/language/nodejs/bun/bun.go Implemented the bun analyzer including file parsing logic.
pkg/fanal/analyzer/const.go Added a new analyzer type constant for bun.
pkg/fanal/analyzer/all/import.go Included the new bun analyzer in the analyzer registry.
pkg/detector/library/driver.go Updated vulnerability detection to recognize Bun.
integration/testdata/fixtures/repo/bun/package.json Added fixture package.json for Bun-based repositories.
integration/testdata/bun.json.golden Introduced a new golden file for Bun test results.
integration/repo_test.go Included integration test case for the Bun analyzer.

Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

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

@sneaky-potato left small comments.

Can you also add a small example of how these changes work in the PR description?
We'll include this example in the release notes.

Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

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

Sorry, looks like I didn't hit the submit button...

Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

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

LGTM

Left small comments

Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

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

@sneaky-potato Thanks a lot for your contribution.
LGTM

Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

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

Thanks for your great contribution!

@knqyf263 knqyf263 added this pull request to the merge queue May 28, 2025
Merged via the queue into aquasecurity:main with commit 7ca656d May 28, 2025
17 checks passed
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.

feat(nodejs): add a bun.lock analyzer
3 participants