getDIFCProxyPolicyJSON returns a JSON-encoded guard policy for the DIFC proxy. Unlike the gateway policy (which includes dynamic blocked-users and approval-labels from step outputs), the proxy policy only includes the static fields available at compile time: min-integrity and repos. This is because
(githubTool map[string]any, data *WorkflowData, gatewayConfig *MCPGatewayRuntimeConfig)
| 169 | // |
| 170 | // Returns an empty string if no guard policy fields are found. |
| 171 | func getDIFCProxyPolicyJSON(githubTool map[string]any, data *WorkflowData, gatewayConfig *MCPGatewayRuntimeConfig) string { |
| 172 | policy := make(map[string]any) |
| 173 | |
| 174 | // Support both 'allowed-repos' (preferred) and deprecated 'repos' |
| 175 | repos, hasRepos := githubTool["allowed-repos"] |
| 176 | if !hasRepos { |
| 177 | repos, hasRepos = githubTool["repos"] |
| 178 | } |
| 179 | integrity, hasIntegrity := githubTool["min-integrity"] |
| 180 | |
| 181 | if !hasRepos && !hasIntegrity { |
| 182 | return "" |
| 183 | } |
| 184 | |
| 185 | if hasRepos { |
| 186 | policy["repos"] = normalizeGitHubRepositoryInReposScope(repos) |
| 187 | } else { |
| 188 | // Default repos to "all" when min-integrity is specified without repos |
| 189 | policy["repos"] = "all" |
| 190 | } |
| 191 | |
| 192 | if hasIntegrity { |
| 193 | policy["min-integrity"] = integrity |
| 194 | } |
| 195 | |
| 196 | // Inject reaction fields when the feature flag is enabled and MCPG supports it. |
| 197 | injectIntegrityReactionFields(policy, githubTool, data, gatewayConfig) |
| 198 | |
| 199 | guardPolicy := map[string]any{ |
| 200 | "allow-only": policy, |
| 201 | } |
| 202 | |
| 203 | jsonBytes, err := json.Marshal(guardPolicy) |
| 204 | if err != nil { |
| 205 | difcProxyLog.Printf("Failed to marshal DIFC proxy policy: %v", err) |
| 206 | return "" |
| 207 | } |
| 208 | |
| 209 | return string(jsonBytes) |
| 210 | } |
| 211 | |
| 212 | // resolveProxyContainerImage returns the full container image reference (container:version) |
| 213 | // for the DIFC/CLI proxy, falling back to the default MCP gateway version if none is configured. |