Skip to content

[K9CODESEC-2546] Fetch Rego libraries from backend API with embedded fallback#213

Merged
whitemerch merged 1 commit into
mainfrom
chakib.hamie/serve_libraries_from_backend
Jun 30, 2026
Merged

[K9CODESEC-2546] Fetch Rego libraries from backend API with embedded fallback#213
whitemerch merged 1 commit into
mainfrom
chakib.hamie/serve_libraries_from_backend

Conversation

@whitemerch

@whitemerch whitemerch commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Motivation

Rego library modules (e.g. terraform.rego, common.rego) are currently embedded in the binary at build time. Serving them from the backend instead lets the team update library logic without a scanner release, and keeps the binary smaller over time. The embedded assets remain as a transparent offline fallback so scans still work without network access.

Related Ticket: K9CODESEC-2546

Changes

Datadog client

A new Library type and GetLibraries(ctx) (map[string]Library, error) method are added to the Client interface and implemented on datadogClient. The implementation calls GET /api/v2/static-analysis/iac/libraries, unmarshals the JSON:API response, and returns a map keyed by library ID.

DatadogSource library loading

DatadogSource now fetches libraries from the backend on first use via a sync.Once-guarded loadLibraries call. GetQueryLibrary checks the backend result first; when the backend is unreachable (or returns no entry for the requested platform) it falls back transparently to the existing QueriesSource backed by the embedded ./assets/libraries directory.

The internal field librarySource is renamed to libraryFallback to make intent clear; the existing WithLibrarySource option is kept as an alias so no call sites need updating.

Counterpart PRs

QA Instruction

CI should pass.

Impact

The scan pipeline is the only affected surface. The fallback to embedded assets is automatic, so behaviour for offline or CI environments is unchanged.

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 25, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 51.35%
Overall Coverage: 49.34% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 863bff6 | Docs | Datadog PR Page | Give us feedback!

@whitemerch whitemerch changed the title Fetch Rego libraries from backend API with embedded fallback [K9CODESEC-2546] Fetch Rego libraries from backend API with embedded fallback Jun 25, 2026
@whitemerch
whitemerch marked this pull request as ready for review June 26, 2026 08:25
@whitemerch
whitemerch requested a review from a team as a code owner June 26, 2026 08:25
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@whitemerch
whitemerch force-pushed the chakib.hamie/serve_libraries_from_backend branch from 3a60b53 to 863bff6 Compare June 26, 2026 09:07
@whitemerch
whitemerch merged commit 2cd8823 into main Jun 30, 2026
19 checks passed
@whitemerch
whitemerch deleted the chakib.hamie/serve_libraries_from_backend branch June 30, 2026 06:50
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