Skip to content

fix: handle empty Gradle project group in root PURL construction - #644

Open
Strum355 wants to merge 1 commit into
guacsec:mainfrom
Strum355:TC-6400
Open

Strum355 wants to merge 1 commit into
guacsec:mainfrom
Strum355:TC-6400

Conversation

@Strum355

@Strum355 Strum355 commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Description

When a Gradle project does not set the group property, the JS client threw "Artifact coordinates should have a non-empty group ID" instead of scanning the manifest. Mirror the Java client's fallback: default to "unknown" for empty group and "0.0.0" for empty version.

Resolves: TC-6400

Checklist

  • I have followed this repository's contributing guidelines.
  • I will adhere to the project's code of conduct.

Additional information

Anything else?

Summary by Sourcery

Handle missing Gradle project metadata so manifest scanning succeeds with stable fallback coordinates.

Bug Fixes:

  • Allow Gradle projects without a group or version to be scanned by constructing root package URLs with fallback coordinates.

Tests:

  • Update Groovy and Kotlin Gradle provider coverage to validate successful SBOM generation for projects with an empty group.

When a Gradle project does not set the `group` property, the JS client
threw "Artifact coordinates should have a non-empty group ID" instead of
scanning the manifest. Mirror the Java client's fallback: default to
"unknown" for empty group and "0.0.0" for empty version.

Resolves: TC-6400

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Strum355
Strum355 requested review from a-oren and ruromero September 24, 2026 16:02
@sourcery-ai

sourcery-ai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR fixes Gradle root PURL construction by centralizing coordinate generation and applying Java-client-compatible fallbacks for missing group and version metadata, while adding Groovy and Kotlin regression coverage that verifies successful SBOM generation for projects without a group.

Sequence diagram for Gradle root PURL fallback construction

sequenceDiagram
    participant Gradle as Gradle manifest
    participant Provider as Java_gradle
    participant SBOM as Sbom
    participant PURL as parseDep

    Gradle->>Provider: #buildSbom(content, properties, manifestPath, opts, hashMap)
    Provider->>Provider: #buildRootCoordinate(properties)
    alt group or version is empty
        Provider->>PURL: parseDep(unknown:rootName:jar:0.0.0)
    else metadata is present
        Provider->>PURL: parseDep(group:rootName:jar:version)
    end
    PURL-->>Provider: rootPurl
    Provider->>SBOM: addRoot(rootPurl, license)

    Gradle->>Provider: #buildDirectDependenciesSbom(content, properties, manifestPath, opts, hashMap)
    Provider->>Provider: #buildRootCoordinate(properties)
    Provider->>PURL: parseDep(rootCoordinate)
    PURL-->>Provider: rootPurl
    Provider->>SBOM: addRoot(rootPurl, license)
Loading

File-Level Changes

Change Details Files
Centralize Gradle root coordinate construction with fallbacks for missing project metadata.
  • Default an empty group to unknown and an empty version to 0.0.0.
  • Safely extract the root project name and fall back to unknown when unavailable.
  • Use the shared coordinate builder for both full and direct-dependency SBOM generation.
src/providers/java_gradle.js
Convert the empty-group scenario into a successful regression test for both Gradle DSL providers.
  • Add the scenario to the standard Groovy and Kotlin provider test cases.
  • Replace assertions expecting an exception with committed component and stack SBOM fixtures.
test/providers/java_gradle_groovy.test.js
test/providers/java_gradle_kotlin.test.js
test/providers/tst_manifests/gradle/deps_with_empty_project_group/expected_component_sbom.json
test/providers/tst_manifests/gradle/deps_with_empty_project_group/expected_stack_sbom.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the fallback coordinate or project-name parsing is wrong, generated SBOMs can contain an incorrect or colliding root PURL, affecting downstream dependency identification. Reverting stops the behavior, and affected SBOMs can be regenerated, so the impact is bounded and repairable.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.09%. Comparing base (031fd7f) to head (9447690).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #644      +/-   ##
==========================================
- Coverage   92.11%   92.09%   -0.02%     
==========================================
  Files          45       45              
  Lines       10675    10682       +7     
  Branches     1932     1935       +3     
==========================================
+ Hits         9833     9838       +5     
- Misses        842      844       +2     
Flag Coverage Δ
unit-tests 92.09% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/providers/java_gradle.js 94.43% <100.00%> (+0.05%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
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