Skip to content

fix: recommend when no vulnerabilities are reported#610

Merged
ruromero merged 4 commits into
guacsec:mainfrom
ruromero:chore/serena
May 11, 2026
Merged

fix: recommend when no vulnerabilities are reported#610
ruromero merged 4 commits into
guacsec:mainfrom
ruromero:chore/serena

Conversation

@ruromero
Copy link
Copy Markdown
Collaborator

@ruromero ruromero commented May 11, 2026

Related to #607 and update serena and conventions files

Summary by Sourcery

Update Serena project configuration and developer conventions while enhancing registry enrichment behavior and tests.

Enhancements:

  • Ensure registry enrichment initializes missing or empty provider sources with default structures to safely attach recommendations.
  • Add Serena project memories for project overview and suggested commands, and align Serena config with updated documentation and tooling references.

Documentation:

  • Expand CONVENTIONS.md with registry integration structure, configuration property guidelines, CDI extensibility patterns, Camel integration patterns, testing practices, and PURL construction rules.

Tests:

  • Extend RegistryEnrichmentService tests to cover creation of default sources when provider reports have null or empty sources.

Chores:

  • Refresh Serena language server and tooling documentation references in project config.

ruromero and others added 3 commits May 11, 2026 14:06
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
Co-authored-by: Claude Sonnet <noreply@anthropic.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 11, 2026

Reviewer's Guide

Updates Serena project configuration, expands internal conventions documentation for registry integrations and Camel patterns, adds project memories for Serena, strengthens registry enrichment behavior when provider sources are null/empty, and adds corresponding tests.

Sequence diagram for registry enrichment when provider sources are null or empty

sequenceDiagram
    participant RegistryEnrichmentService
    participant providers
    participant ProviderReport
    participant SourceMap as sources
    participant Source
    participant SourceSummary

    RegistryEnrichmentService->>providers: entrySet()
    loop for each providerEntry
        RegistryEnrichmentService->>ProviderReport: getValue()
        alt providerReport == null
            RegistryEnrichmentService-->>RegistryEnrichmentService: continue
        else providerReport != null
            RegistryEnrichmentService->>ProviderReport: getSources()
            alt getSources() == null
                RegistryEnrichmentService->>ProviderReport: sources(new HashMap)
                RegistryEnrichmentService->>ProviderReport: getSources()
            end
            RegistryEnrichmentService->>ProviderReport: getSources()
            Note right of RegistryEnrichmentService: check isEmpty()
            alt sources.isEmpty()
                RegistryEnrichmentService->>Source: new Source()
                RegistryEnrichmentService->>Source: dependencies(new ArrayList)
                RegistryEnrichmentService->>SourceSummary: new SourceSummary()
                RegistryEnrichmentService->>Source: summary(SourceSummary)
                RegistryEnrichmentService->>ProviderReport: getSources().put(providerEntry.key, Source)
            end
            RegistryEnrichmentService->>ProviderReport: getSources()
            RegistryEnrichmentService->>SourceMap: entrySet()
            loop for each sourceEntry
                RegistryEnrichmentService->>Source: enrichUnreportedDependencies(sourceReport)
            end
        end
    end
Loading

File-Level Changes

Change Details Files
Refresh Serena project configuration and add Serena-specific project memories.
  • Updated language server documentation comments to match current Serena/Language enum list and notes for Angular/SCSS.
  • Replaced inlined tool listing with links to Serena tool documentation for excluded, included_optional, and fixed tools.
  • Clarified mode configuration semantics, added added_modes and additional_workspace_folders options, and reflowed the initial_prompt for readability.
  • Added project_overview and suggested_commands Serena memories describing architecture, tech stack, and common commands.
.serena/project.yml
.serena/memories/project_overview.md
.serena/memories/suggested_commands.md
Extend project conventions for registry integration structure, configuration properties, CDI extensibility, Camel patterns, testing, and PURL handling.
  • Added registry-related package and naming conventions for integration and model packages, including EnrichmentService naming guidance.
  • Documented configuration property patterns for required/optional/timeout properties and discouraged default empty strings for optional values.
  • Introduced CDI extensibility and stateless helper service patterns for multi-ecosystem registry integrations.
  • Documented Camel integration patterns (circuit breaker, fallback, header cleanup, dynamic URLs, route naming) and testing conventions for CDI beans, Camel routes, and WireMock.
  • Added guidelines for PURL construction and qualifier URL-encoding.
CONVENTIONS.md
Harden RegistryEnrichmentService to create default sources when provider reports have null or empty sources and add regression tests.
  • Updated RegistryEnrichmentService.enrichUnreportedDependencies to initialize providerReport.sources when null and to create a default Source with empty dependencies and summary when the sources map is empty.
  • Added tests ensuring enrichment creates a source when provider sources are null or empty and still adds recommendations.
  • Imported Source and SourceSummary API classes required by the new default source creation logic.
src/main/java/io/github/guacsec/trustifyda/integration/registry/RegistryEnrichmentService.java
src/test/java/io/github/guacsec/trustifyda/integration/registry/RegistryEnrichmentServiceTest.java

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

@ruromero ruromero changed the title Chore/serena fix: recommend when no vulnerabilities are reported May 11, 2026
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/test/java/io/github/guacsec/trustifyda/integration/registry/RegistryEnrichmentServiceTest.java" line_range="215-224" />
<code_context>
     assertEquals("expected-hash", capturedHash[0]);
   }

+  @Test
+  void enrichCreatesSourceWhenProvidersHaveEmptySources() {
+    var providerReport = new ProviderReport();
+    providerReport.sources(new HashMap<>());
+    var report = new AnalysisReport();
+    report.providers(new HashMap<>(Map.of("provider1", providerReport)));
+
+    var tree = buildTree("pkg:pypi/amqp@5.3.1", Map.of("SHA-256", "abc123"));
+
+    service.enrichReport(report, tree, PKG_PYPI_PREFIX, alwaysRecommend);
+
+    assertFalse(providerReport.getSources().isEmpty());
+    var deps = providerReport.getSources().values().iterator().next().getDependencies();
+    assertEquals(1, deps.size());
+    assertNotNull(deps.get(0).getRecommendation());
+  }
+
+  @Test
+  void enrichCreatesSourceWhenSourcesIsNull() {
+    var providerReport = new ProviderReport();
+    var report = new AnalysisReport();
</code_context>
<issue_to_address>
**suggestion (testing):** Extend the `enrichCreatesSourceWhenSourcesIsNull` test to assert dependency creation and recommendations, mirroring the empty-sources case.

In `enrichCreatesSourceWhenSourcesIsNull`, we now create a default `Source` and enrich it with dependencies and recommendations when `sources` is null, but the test only asserts that `getSources()` is non-null/non-empty. To fully validate the behavior, please also assert that the created `Source` has exactly one dependency and that this dependency has a non-null recommendation, matching the checks in `enrichCreatesSourceWhenProvidersHaveEmptySources`. This will align coverage for the "null" and "empty" cases and verify the complete enrichment flow, not just map initialization.

Suggested implementation:

```java
    assertNotNull(providerReport.getSources());
    assertFalse(providerReport.getSources().isEmpty());

    var deps = providerReport.getSources().values().iterator().next().getDependencies();
    assertEquals(1, deps.size());
    assertNotNull(deps.get(0).getRecommendation());
  }

```

This edit assumes that in `enrichCreatesSourceWhenSourcesIsNull` the tree-building and `service.enrichReport(...)` invocation already occur before these assertions, similar to `enrichCreatesSourceWhenProvidersHaveEmptySources`. If the method body is currently shorter and only sets up the `providerReport`/`report` and calls `enrichReport`, you should ensure that:
1. `enrichCreatesSourceWhenSourcesIsNull` builds a tree (e.g. via `buildTree("pkg:pypi/amqp@5.3.1", Map.of("SHA-256", "abc123"))`), and
2. Passes that tree into `service.enrichReport(report, tree, PKG_PYPI_PREFIX, alwaysRecommend);`
so that the new dependency/recommendation assertions are meaningful and consistent with the "empty sources" test.
</issue_to_address>

### Comment 2
<location path=".serena/memories/project_overview.md" line_range="7" />
<code_context>
+Trustify Dependency Analytics is a Java/Quarkus backend service for dependency analysis. 
+It accepts SBOMs (CycloneDX/SPDX), queries vulnerability providers (Trustify), resolves 
+licenses via deps.dev, and returns analysis results as JSON, HTML (self-contained React app 
+via Freemarker), or multipart/mixed.
+
+## Tech Stack
</code_context>
<issue_to_address>
**nitpick (typo):** Consider using the official spelling "FreeMarker" for the template engine name.

Here this refers to the FreeMarker templating engine; please change `Freemarker` to `FreeMarker` to match the official name.

Suggested implementation:

```
licenses via deps.dev, and returns analysis results as JSON, HTML (self-contained React app 
via FreeMarker), or multipart/mixed.

```

```
- **UI**: React 18 + PatternFly 5 + TypeScript (compiled into FreeMarker template)

```
</issue_to_address>

### Comment 3
<location path=".serena/memories/project_overview.md" line_range="17" />
<code_context>
+- **ORM**: Hibernate ORM with Panache, PostgreSQL, Flyway
+- **Cache**: Redis
+- **Build**: Maven, Spotless (Google Java Format), Frontend Maven Plugin (Node/Yarn for UI)
+- **Testing**: JUnit 5, REST Assured, WireMock 3.4.2, HTMLUnit
+- **API Models**: `trustify-da-api-model` artifact (version 2.0.7) provides generated model classes
+- **UI**: React 18 + PatternFly 5 + TypeScript (compiled into Freemarker template)
</code_context>
<issue_to_address>
**nitpick (typo):** Align the spelling of "HTMLUnit" with the official project name "HtmlUnit".

Please change `HTMLUnit` to `HtmlUnit` here to match the upstream project’s official capitalization and keep the documentation accurate.

```suggestion
- **Testing**: JUnit 5, REST Assured, WireMock 3.4.2, HtmlUnit
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .serena/memories/project_overview.md Outdated
Comment thread .serena/memories/project_overview.md Outdated
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
Co-authored-by: Claude Sonnet <noreply@anthropic.com>
@ruromero ruromero merged commit 917a4ee into guacsec:main May 11, 2026
3 checks passed
@ruromero ruromero deleted the chore/serena branch May 11, 2026 19:34
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