Skip to content

[fix] bind llm credentials to host policy (STAR-103) - #19

Merged
vt128 merged 8 commits into
masterfrom
codex/fix-star-103
Sep 23, 2026
Merged

vt128 merged 8 commits into
masterfrom
codex/fix-star-103

Conversation

@vt128

@vt128 vt128 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Problem

NewModule and NewModuleWithConfig intentionally let a script choose the LLM provider and endpoint. That behavior is useful for trusted scripts, but a host-injected credential could then be sent to a script-selected endpoint; image_file could also read any host-readable file.

Change

  • Add NewModuleWithHostPolicy(HostPolicy{...}) for opt-in host-controlled embedding.
  • Keep provider, endpoint, and API key host-only while leaving model and request options script-configurable.
  • Reject redirects outside the configured scheme, host, and port, independent of Go's cross-origin header behavior.
  • Resolve an optional FileRoot once and reject traversal, symlink escapes, non-regular files, and file access when the root is empty.
  • Preserve the historical behavior of NewModule and NewModuleWithConfig.
  • Document the two trust modes and their path-level boundary.

The change keeps Go 1.19, the existing Starlark pin, and all module dependencies unchanged.

Validation

  • go test -race -count=2 ./...
  • Go 1.19 linux/amd64 offline container: go test -race -count=1 ./..., go build ./..., go vet ./...
  • go vet ./..., go build ./..., gofmt, git diff --check
  • doccov: 3/3 builtins and 12/12 config accessors
  • Local mock coverage includes blocking chat, streaming chat, draw, all three image_file entry points, traversal/symlink rejection, redirect rejection, invalid policy errors, and the legacy constructors.

@codacy-production

codacy-production Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 56 complexity · 2 duplication

Metric Results
Complexity 56
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.70079% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
openai.go 93.70% 4 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@vt128
vt128 merged commit abac269 into master Sep 23, 2026
29 checks passed
@vt128
vt128 deleted the codex/fix-star-103 branch September 23, 2026 16:56
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.

1 participant