a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package mcp
|
|
|
|
import "github.com/zzet/gortex/internal/review"
|
|
|
|
// maybeRedactConfigLeaf withholds secret-shaped values from the body of a
|
|
// config / data-leaf file before it is served by a content read sink. It
|
|
// returns the (possibly redacted) body and whether anything was withheld.
|
|
// Redaction is skipped when the caller passed allow_secrets, when the file is
|
|
// not a config leaf, when the owning repo disabled it, or when nothing
|
|
// secret-shaped is present — so benign config is returned untouched.
|
|
func (s *Server) maybeRedactConfigLeaf(language, relPath string, allowSecrets bool, content string) (string, bool) {
|
|
if allowSecrets {
|
|
return content, false
|
|
}
|
|
if !review.IsConfigLeafLanguage(language) && !review.IsConfigLeafPath(relPath) {
|
|
return content, false
|
|
}
|
|
if !s.redactConfigSecretsEnabled(relPath) {
|
|
return content, false
|
|
}
|
|
red, hits := review.RedactConfigLeaf(content)
|
|
if hits == 0 {
|
|
return content, false
|
|
}
|
|
return red, true
|
|
}
|
|
|
|
// redactConfigSecretsEnabled reports whether config-leaf secret redaction is
|
|
// active for the repo that owns relPath. It defaults to on (the safe default)
|
|
// when no config manager is wired — the single-repo and test paths.
|
|
func (s *Server) redactConfigSecretsEnabled(relPath string) bool {
|
|
if s.configManager == nil {
|
|
return true
|
|
}
|
|
return s.configManager.GetRepoConfig(repoPrefixForPath(s, relPath)).MCP.RedactConfigSecretsEnabled()
|
|
}
|