Conversation
WalkthroughBumps docker CLI indirect dependency, adds go-containerregistry to router-tests, introduces OCI test helpers and three OCI integration tests that build/push plugin images to an in-memory registry, and extends testenv PluginConfig with a RegistryURL field plus an embedded OCI config template. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
Comment |
Router-nonroot image scan passed✅ No security vulnerabilities found in image: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2589 +/- ##
==========================================
+ Coverage 62.27% 62.81% +0.54%
==========================================
Files 243 243
Lines 25746 25746
==========================================
+ Hits 16033 16173 +140
+ Misses 8371 8202 -169
- Partials 1342 1371 +29 🚀 New features to boost your workflow:
|
dkorittki
left a comment
There was a problem hiding this comment.
docker cli is an indirect dependency used by go-containerregistry. When you update it without updating go-containerregistry that library is using the updated library without us knowing wether that works or not. I think it's better to update go-containerregistry itself but you need to ensure the router uses a newer go version.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@router-tests/router_oci_plugin_test.go`:
- Around line 99-104: The EventuallyWithT retry callback must not call
xEnv.MakeGraphQLRequestOK because it uses fatal assertions and can abort the
test instead of allowing retries; replace the call with the non-fatal request
helper (e.g., xEnv.MakeGraphQLRequest or another variant that returns a response
without calling t.Fatal) and assert the response body using the provided
CollectT (require.Equal(c, ...)) inside the callback so transient failures
during plugin restart are retried by require.EventuallyWithT rather than
terminating the test.
In `@router-tests/testenv/testenv.go`:
- Around line 1499-1503: Validate and reject schema-prefixed registry URLs when
assigning testConfig.Plugins.RegistryURL to pluginsCfg.Registry.URL: check the
string in the setup code that currently assigns testConfig.Plugins.RegistryURL
(the block that sets pluginsCfg.Registry =
config.PluginRegistryConfiguration{URL: ...}) and if it starts with "http://" or
"https://" return an error or fatally fail the test setup with a clear message
instructing that OCI registry URLs must be host-only (no schema). Ensure the
validation triggers before any plugin pull attempts so failures are fast and
actionable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1db695a7-d484-4eef-98aa-97ca6f6a1a26
📒 Files selected for processing (5)
router-tests/go.modrouter-tests/oci_test_helpers.gorouter-tests/router_oci_plugin_test.gorouter-tests/testenv/testdata/configWithOCIPlugins.jsonrouter-tests/testenv/testenv.go
🚧 Files skipped from review as they are similar to previous changes (1)
- router-tests/go.mod
There was a problem hiding this comment.
🧹 Nitpick comments (1)
router-tests/router_oci_plugin_test.go (1)
24-29: Consider extracting duplicated plugin image setup into a helper.The binary path + build/push sequence is repeated across tests; extracting it will reduce drift and simplify future image/tag changes.
♻️ Suggested refactor
+func pushTestPlugins(t *testing.T, registryHost string) { + t.Helper() + projectsBinary := fmt.Sprintf("../router/plugins/projects/bin/%s_%s", runtime.GOOS, runtime.GOARCH) + coursesBinary := fmt.Sprintf("../router/plugins/courses/bin/%s_%s", runtime.GOOS, runtime.GOARCH) + buildAndPushPluginImage(t, registryHost, "test-org/projects", "v1", projectsBinary) + buildAndPushPluginImage(t, registryHost, "test-org/courses", "v1", coursesBinary) +} + func TestOCIPlugin_PullAndRun(t *testing.T) { t.Parallel() registryHost := startTestOCIRegistry(t) - - projectsBinary := fmt.Sprintf("../router/plugins/projects/bin/%s_%s", runtime.GOOS, runtime.GOARCH) - coursesBinary := fmt.Sprintf("../router/plugins/courses/bin/%s_%s", runtime.GOOS, runtime.GOARCH) - - buildAndPushPluginImage(t, registryHost, "test-org/projects", "v1", projectsBinary) - buildAndPushPluginImage(t, registryHost, "test-org/courses", "v1", coursesBinary) + pushTestPlugins(t, registryHost) ... func TestOCIPlugin_Restart(t *testing.T) { t.Parallel() registryHost := startTestOCIRegistry(t) - - projectsBinary := fmt.Sprintf("../router/plugins/projects/bin/%s_%s", runtime.GOOS, runtime.GOARCH) - coursesBinary := fmt.Sprintf("../router/plugins/courses/bin/%s_%s", runtime.GOOS, runtime.GOARCH) - - buildAndPushPluginImage(t, registryHost, "test-org/projects", "v1", projectsBinary) - buildAndPushPluginImage(t, registryHost, "test-org/courses", "v1", coursesBinary) + pushTestPlugins(t, registryHost)Also applies to: 71-75
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@router-tests/router_oci_plugin_test.go` around lines 24 - 29, Duplicate plugin image setup (projectsBinary/coursesBinary + buildAndPushPluginImage calls) should be extracted into a helper to avoid repetition; create a function (e.g., prepareAndPushPluginImage or setupPluginImage) that takes registryHost, org/name, version and OS/ARCH or derives runtime.GOOS/runtime.GOARCH, builds the binary path (like "../router/plugins/%s/bin/%s_%s") and calls buildAndPushPluginImage internally, then replace the repeated lines in router_oci_plugin_test.go (references: projectsBinary, coursesBinary, buildAndPushPluginImage, registryHost) with calls to this helper in both the 24-29 block and the similar 71-75 block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@router-tests/router_oci_plugin_test.go`:
- Around line 24-29: Duplicate plugin image setup (projectsBinary/coursesBinary
+ buildAndPushPluginImage calls) should be extracted into a helper to avoid
repetition; create a function (e.g., prepareAndPushPluginImage or
setupPluginImage) that takes registryHost, org/name, version and OS/ARCH or
derives runtime.GOOS/runtime.GOARCH, builds the binary path (like
"../router/plugins/%s/bin/%s_%s") and calls buildAndPushPluginImage internally,
then replace the repeated lines in router_oci_plugin_test.go (references:
projectsBinary, coursesBinary, buildAndPushPluginImage, registryHost) with calls
to this helper in both the 24-29 block and the similar 71-75 block.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 38c2340d-e986-4b8a-8c5d-f35d5ba3f04e
📒 Files selected for processing (2)
router-tests/router_oci_plugin_test.gorouter-tests/testenv/testenv.go
🚧 Files skipped from review as they are similar to previous changes (1)
- router-tests/testenv/testenv.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@router-tests/testenv/testenv.go`:
- Around line 1499-1505: The RegistryURL validation only checks for lowercase
"http://" and "https://" but must reject any URI scheme (case-insensitive) such
as "oci://", "HTTP://", or other "scheme://" forms; update the check around
testConfig.Plugins.RegistryURL so it rejects inputs containing a scheme by
either parsing with net/url (url.Parse and ensure u.Scheme == "" and u.Host ==
"") or by case-insensitive detection of any "<scheme>://" pattern (e.g.,
strings.Contains(strings.ToLower(testConfig.Plugins.RegistryURL), "://") or a
regex) before assigning pluginsCfg.Registry =
config.PluginRegistryConfiguration{URL: testConfig.Plugins.RegistryURL}; keep
the error message descriptive and include the offending value
(testConfig.Plugins.RegistryURL).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 02622299-f0dc-4e9c-ba5b-ca2a1ea5fa82
📒 Files selected for processing (1)
router-tests/testenv/testenv.go
This PR fixes this vulnerability https://github.com/wundergraph/cosmo/security/code-scanning/323
Summary by CodeRabbit
Chores
Tests
Checklist