Skip to content

Emit server.kb_version in component scan (-C) output #119

Description

@mscasso-scanoss

Problem

scanoss -C (component_scan in src/purl_scan.c) serves /scan/components, the call batchScanner uses to fetch component details for a scan. Its output has no KB version:

{"results": [{"url_hash": "...", "component": {...}}, ...]}

Because of that, batchScanner cannot fill server.knowledge_base in its report (scanoss/batchScanner#7). Clients such as Earnie need the KB version to reuse cached OSS matches between scans. Today they work around it with a dummy POST /scan/direct, because only that path emits server.kb_version.

-P (/scan/raw) and the snippet scan don't emit it either.

Proposal

Add a server block to the -C output, after results:

{
  "results": [ ... ],
  "server": {
    "version": "6.0.0-crc64",
    "kb_version": {"monthly": "26.09", "daily": "26.09.27"}
  }
}
  • The data is already there: initialize_ldb_tables() calls kb_version_get() before -C runs, so the global kb_version is loaded. version is SCANOSS_VERSION.
  • Emit only version and kb_version. Do not add hostname, flags or elapsed as print_server_stats() does. batchScanner calls -C in several batches, and every batch should return the same block.
  • Keep the current fallback. When /var/lib/ldb/<db>/version.json is missing, kb_version is the string "N/A". Consumers must accept both the object and that string.
  • Respect quiet in the same way results does.

The change is additive. Existing consumers read only results.

Acceptance

  • scanoss -C <hash>[,<hash>...] returns valid JSON with results and server.{version,kb_version}.
  • kb_version matches the contents of version.json for the loaded DB, or is "N/A" when that file is missing.
  • The output is unchanged for invalid or empty input (exit code and message).

Follow-up

  • batchScanner maps this block to its report schema: api_version, knowledge_base.monthly_version and knowledge_base.daily_version (scanoss/batchScanner#7).
  • Check that the HTTP layer serving /scan/components passes the server key through unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions