MCPcopy Create free account
hub / github.com/github/gh-aw / allowedEngineEnvSecretKeys

Function allowedEngineEnvSecretKeys

pkg/cli/codemod_engine_env_secrets.go:89–129  ·  view source on GitHub ↗
(engineID string)

Source from the content-addressed store, hash-verified

87}
88
89func allowedEngineEnvSecretKeys(engineID string) map[string]struct {
90} {
91 allowed := make(map[string]struct {
92 })
93 // Keep only required, engine-specific secret names here.
94 // We intentionally exclude system secrets (for example GH_AW_GITHUB_TOKEN)
95 // and optional secrets so this codemod only
96 // preserves strict-mode-safe engine credential overrides.
97 for _, req := range getSecretRequirementsForEngine(
98 engineID,
99 false, // includeSystemSecrets
100 false, // includeOptional
101 ) {
102 allowed[req.Name] = struct {
103 }{}
104 }
105 // Also include all secrets returned by the engine's GetRequiredSecretNames so that
106 // BYOK credentials (e.g. COPILOT_PROVIDER_API_KEY) are treated the same way as they
107 // are during compile-time strict-mode validation and are not removed by this codemod.
108 if engineID != "" {
109 registry := workflow.GetGlobalEngineRegistry()
110 if engine, err := registry.GetEngine(engineID); err == nil {
111 // Use a minimal WorkflowData so we get only the engine's unconditional secrets.
112 // GetRequiredSecretNames only adds extra secrets when non-nil MCP tools
113 // (ParsedTools.GitHub, ParsedTools.Playwright, etc.) are set, or when
114 // MCPScripts is populated. By passing empty Tools/ParsedTools we get just the
115 // base engine secrets without any optional/conditional ones.
116 minimalData := &workflow.WorkflowData{
117 Tools: map[string]any{},
118 ParsedTools: &workflow.ToolsConfig{},
119 }
120 for _, name := range engine.GetRequiredSecretNames(minimalData) {
121 allowed[name] = struct {
122 }{}
123 }
124 } else {
125 engineEnvSecretsCodemodLog.Printf("Could not look up engine '%s' for allowlist expansion: %v", engineID, err)
126 }
127 }
128 return allowed
129}
130
131func findUnsafeEngineEnvSecretKeys(envMap map[string]any, allowed map[string]struct {
132}) map[string]struct {

Callers 1

Calls 5

GetGlobalEngineRegistryFunction · 0.92
GetEngineMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected