[K9CODESEC-2546] Fetch Rego libraries from backend API with embedded fallback#213
Merged
Merged
Conversation
|
🎯 Code Coverage (details) 🔗 Commit SHA: 863bff6 | Docs | Datadog PR Page | Give us feedback! |
whitemerch
marked this pull request as ready for review
June 26, 2026 08:25
whitemerch
force-pushed
the
chakib.hamie/serve_libraries_from_backend
branch
from
June 26, 2026 09:07
3a60b53 to
863bff6
Compare
NathanGallet-dd
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Librarytype andGetLibraries(ctx) (map[string]Library, error)method are added to theClientinterface and implemented ondatadogClient. The implementation callsGET /api/v2/static-analysis/iac/libraries, unmarshals the JSON:API response, and returns a map keyed by library ID.DatadogSource library loading
DatadogSourcenow fetches libraries from the backend on first use via async.Once-guardedloadLibrariescall.GetQueryLibrarychecks the backend result first; when the backend is unreachable (or returns no entry for the requested platform) it falls back transparently to the existingQueriesSourcebacked by the embedded./assets/librariesdirectory.The internal field
librarySourceis renamed tolibraryFallbackto make intent clear; the existingWithLibrarySourceoption 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.