feat(config): add DOCKER_IMAGE_SELECTION_MODE=fixed for deterministic pentest image - #400
Open
LuckVd wants to merge 1 commit into
Open
feat(config): add DOCKER_IMAGE_SELECTION_MODE=fixed for deterministic pentest image#400LuckVd wants to merge 1 commit into
LuckVd wants to merge 1 commit into
Conversation
… pentest image DOCKER_DEFAULT_IMAGE_FOR_PENTEST was only injected into the image_chooser prompt; the LLM's raw response was used as the terminal image with no validation and no deterministic fallback. With weaker local models the pen-test image guidance is routinely ignored (e.g. returning node:latest), silently running flows in the wrong environment (issue vxcontrol#392). Add an opt-in DOCKER_IMAGE_SELECTION_MODE setting: 'llm' (default) preserves the current behavior; 'fixed' skips the LLM call entirely and deterministically uses the configured pentest image, falling back to the default docker image when unset.
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.
Description
Fixes #392
DOCKER_DEFAULT_IMAGE_FOR_PENTEST(and theDefaultImageForPentesttemplate variable) was documented and configured as if it constrains which Docker image a flow's terminal container uses. In practice it was only injected as text into theimage_chooserprompt (backend/pkg/templates/prompts/image_chooser.tmpl), and the LLM's raw text response was used directly as the image name (backend/pkg/providers/providers.go,NewFlowProvider) with no validation and no deterministic fallback. The issue reporter demonstrated that weaker/local models (e.g.qwen2.5:7b-instruct) reliably ignore the pentest-image guidance and return e.g.node:latest, silently running pentest flows in the wrong environment.This PR implements the issue's preferred option 1 (deterministic mode switch) as an opt-in setting, keeping the default behavior unchanged:
Change
backend/pkg/config/config.go: newDockerImageSelectionModefield (envDOCKER_IMAGE_SELECTION_MODE, default"llm").backend/pkg/providers/providers.go:NewFlowProvidernow selects the image deterministically whenDOCKER_IMAGE_SELECTION_MODE=fixed: it skips the LLM call entirely and uses the configured pentest image.resolvePentestImage(pentestImage, defaultImage)— lowercases/trims the configured pentest image and falls back to the default docker image when it is unset (mirrors the empty-value handling inpkg/docker/client.go)."fixed"keeps the existing LLM-based selection, so existing deployments are unaffected.backend/pkg/providers/image_selection_test.go: new unit tests covering the helper (configured image, case/whitespace normalization, empty fallback).backend/pkg/config/config_test.go:DOCKER_IMAGE_SELECTION_MODEadded to the hermetic env-clearing list..env.example: new documented setting.Scope note
The LLM path itself is intentionally unchanged (no allow-list validation, no behavior change for default deployments); operators who want a hard guarantee set
DOCKER_IMAGE_SELECTION_MODE=fixed. The issue's suggested option 2 (response allow-list validation) would be a behavioral change for existing deployments and is deliberately not included.Type of Change
Related Issue
DOCKER_DEFAULT_IMAGE_FOR_PENTESTis not enforced — image selection relies entirely on an unverified LLM response, with no deterministic fallback #392Testing
go test ./pkg/providers/ ./pkg/config/ -count=1— ok, both packages pass (includes the 4 newTestResolvePentestImagecases: configured image, case/whitespace normalization, empty-pentest fallback to default image, normalized fallback).go vet ./pkg/providers/ ./pkg/config/— cleangofmt -l pkg/providers/ pkg/config/— no outputgit diff --check— cleango test ./...was not run in this environment (resource-constrained sandbox, 4 cores / 3.6GB RAM; build limited viaGOMAXPROCS=2 GOFLAGS=-p=1 GOMEMLIMIT=1000MiB). The change is confined topkg/providers+pkg/config+.env.example; both affected packages and their tests are exercised.fixedmode is by code review (mode branch skips the only LLM call between image selection and container creation;imageis stored on the flow provider and used verbatim, matching the previous path).Checklist
git diff --check origin/main...HEADpassesgo vet)