Remove embedded Rego libraries and rely on backend delivery#231
Merged
Conversation
|
🎯 Code Coverage (details) 🔗 Commit SHA: 49fb51a | Docs | Datadog PR Page | Give us feedback! |
whitemerch
marked this pull request as ready for review
July 2, 2026 08:54
whitemerch
force-pushed
the
chakib.hamie/remove_embedded_libraries
branch
3 times, most recently
from
July 2, 2026 09:08
46a3bd5 to
06820e0
Compare
whitemerch
marked this pull request as draft
July 2, 2026 09:08
whitemerch
marked this pull request as ready for review
July 2, 2026 09:11
whitemerch
force-pushed
the
chakib.hamie/remove_embedded_libraries
branch
from
July 2, 2026 09:11
06820e0 to
c7c46a8
Compare
whitemerch
force-pushed
the
chakib.hamie/remove_embedded_libraries
branch
from
July 2, 2026 09:21
c7c46a8 to
87f325a
Compare
ChouraquiBen
previously approved these changes
Jul 2, 2026
| } | ||
| } | ||
|
|
||
| func testLibSource() source.QueriesSource { return &stubLibSource{} } |
Contributor
There was a problem hiding this comment.
Question: Why not use the &stubLibSource directly in the functions' arguments
Contributor
Author
There was a problem hiding this comment.
Because it is called 24 times in the file
whitemerch
force-pushed
the
chakib.hamie/remove_embedded_libraries
branch
3 times, most recently
from
July 2, 2026 10:45
6026fe9 to
72c2727
Compare
whitemerch
force-pushed
the
chakib.hamie/remove_embedded_libraries
branch
from
July 2, 2026 11:01
72c2727 to
49fb51a
Compare
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 libraries were previously embedded in the scanner binary via
go:embedand served as a fallback when the backend was unavailable. The libraries are now managed and pushed to the backen, making the embedded copy redundant and a source of drift. This PR removes the embedded libraries entirely and makes the backend the sole delivery path, with--libraries-pathas an explicit local override for development or custom deployments.Changes
Library delivery
Removed all files under
assets/(18.regofiles,common.json, and 4*_test.regofiles). Theassetspackage no longer embeds anything. The OPA unit tests for library helper functions have been ported to the default-rules repository.Backend source
DatadogSource.GetQueryLibrarynow normalizes platform names to lowercase on both storage and lookup, fixing a case mismatch (cloudFormationvscloudformation) that was previously masked by the embedded fallback. The auto-fallback to embedded libraries inNewDatadogSourceis removed; the only library fallback path is when--libraries-pathis explicitly set.Filesystem source
FilesystemSource.GetQueryLibrarynow reads.regoand.jsonfiles directly from disk instead of delegating to the embedded assets package.Scan wiring
pkg/scan/scan.goonly adds a local library fallback source whenChangedDefaultLibrariesPathis true (i.e.--libraries-pathwas explicitly passed). Without that flag, the scanner always fetches libraries from the backend.CLI commands
list-queries,test-rules, and custom Rego evaluation (custom.go) all useDatadogSourcefor library access instead of the embedded filesystem.E2E tests
Removed
useLocalLibrarieshelper and thetestdata/libraries/snapshot. E2E tests now fetch libraries from the public backend endpoint (/api/v2/static-analysis/iac/libraries), which requires no authentication.Tooling
Removed
.github/scripts/update_versions/, theupdate_software_versionsworkflow,rules_generator/classes/CodeProcessor.pymethods that read/wrotecommon.jsonnow raiseNotImplementedError(are they even used? Anyways if so they would need to be ported separetly, and in a different way)Author Checklist
QA Instruction
Build the binary and run a scan against any Terraform fixture, libraries are now fetched from the backend automatically:
Confirm no
library not founderrors appear. To test the explicit local override path:Blast Radius
Affects the scanner binary only. The backend library endpoint is public and requires no authentication
Additional Notes
Companion PR in default-rules: https://github.com/DataDog/datadog-iac-scanner-default-rules/pull/71 (ports the OPA library tests, fixes
tool.sh testto read libraries from disk, bumps scanner dependency to v1.7.0).I submit this contribution under the Apache-2.0 license.