Skip to content

[Go Support] Go web framework adapters for API endpoint detection (Gin, Echo, net/http) #178

Description

@KanishkThamman

Expected Behavior

NuGuard detects HTTP route handlers in Go web frameworks (Gin, Echo,
net/http) and emits API_ENDPOINT nodes with chat_payload_key,
auth_required, and request_body_schema metadata — the same metadata
populated by nuguard/sbom/adapters/python/fastapi_adapter.py and
nuguard/sbom/adapters/python/flask_adapter.py for Python applications.
This allows the redteam stage to auto-discover AI chat endpoints.

Current Behavior

Go HTTP servers wrapping LLM calls produce no API_ENDPOINT nodes, so the
redteam executor has no target endpoint to probe even when the SBOM correctly
identifies the underlying model.

Possible Solution

Create nuguard/sbom/adapters/go/http_server.py as a GoFrameworkAdapter
subclass covering:

  1. Gin (github.com/gin-gonic/gin) — detect router.POST("/path", handler)
    and router.GET("/path", handler) calls; inspect the handler function body
    for c.ShouldBindJSON(&req) to infer the request body type.
  2. Echo (github.com/labstack/echo) — detect e.POST("/path", handler)
    and similar patterns.
  3. net/http — detect http.HandleFunc("/path", handler) and
    mux.Handle("/path", ...) patterns.

For each route, emit an API_ENDPOINT node. Attempt to resolve prompt field
names from the bound struct (mirroring _PROMPT_FIELD_NAMES in
fastapi_adapter.py, line 70). Emit an AUTH node when middleware like
gin.BasicAuth() or JWT middleware is detected.

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, 2, and 3.

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