Skip to content

[Go Support] GoFrameworkAdapter base class #175

Description

@KanishkThamman

Expected Behavior

A GoFrameworkAdapter base class exists at
nuguard/sbom/adapters/go/_go_base.py that all Go framework adapters subclass,
providing Go-appropriate can_handle() semantics and shared helper methods —
analogous to TSFrameworkAdapter in
nuguard/sbom/adapters/typescript/_ts_regex.py.

Current Behavior

No Go adapter base class exists. If individual Go adapters were written without
a shared base, they would each re-implement can_handle() logic and helper
utilities, diverging from the Python/TypeScript pattern and making maintenance
harder.

Possible Solution

Create nuguard/sbom/adapters/go/_go_base.py:

  1. Define GoFrameworkAdapter(FrameworkAdapter) — subclass of the shared
    FrameworkAdapter from nuguard/sbom/adapters/base.py. All shared
    fields (ComponentDetection, RelationshipHint, _framework_node(),
    priority, name) are inherited unchanged.
  2. Override can_handle() to use substring/prefix matching against full Go
    module paths (e.g. "github.com/tmc/langchaingo" in mod), mirroring the
    substring matching that TSFrameworkAdapter.can_handle() uses for scoped
    npm packages.
  3. Port the shared helpers from TSFrameworkAdapter (_resolve(), _clean(),
    _fw_node(), _template_vars()) so all Go adapters get the same toolkit
    without duplication.
  4. extract() contract: receives GoParseResult as parse_result.

Steps to Reproduce (for bugs)

N/A — this is a feature addition.

Context

Part of #172 (Add Golang Support to NuGuard Pipeline).
Depends on sub-issues 1 and 2.
Blocking: all individual Go framework adapter sub-issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions