deriveWriteSinkGuardPolicyFromWorkflow derives a write-sink guard policy for non-GitHub MCP servers from the workflow's GitHub guard-policy configuration. This uses the same derivation as deriveSafeOutputsGuardPolicyFromGitHub, ensuring that as guard policies are rolled out, only GitHub inputs are f
(workflowData *WorkflowData)
| 539 | // Returns nil when workflowData is nil, when no GitHub tool is present, or when a GitHub App is |
| 540 | // configured (auto-lockdown is skipped for GitHub App tokens, which are already repo-scoped). |
| 541 | func deriveWriteSinkGuardPolicyFromWorkflow(workflowData *WorkflowData) map[string]any { |
| 542 | if workflowData == nil || workflowData.Tools == nil { |
| 543 | return nil |
| 544 | } |
| 545 | rawGithubTool, hasGitHub := workflowData.Tools["github"] |
| 546 | if !hasGitHub { |
| 547 | return nil |
| 548 | } |
| 549 | |
| 550 | toolConfig, _ := rawGithubTool.(map[string]any) |
| 551 | |
| 552 | // Try to derive from explicit guard policy first |
| 553 | policy := deriveSafeOutputsGuardPolicyFromGitHub(toolConfig) |
| 554 | if policy != nil { |
| 555 | return policy |
| 556 | } |
| 557 | |
| 558 | // When no explicit guard policy is configured but automatic lockdown detection would run |
| 559 | // (GitHub tool present and not disabled, no GitHub App configured), return accept=["*"] |
| 560 | // because automatic lockdown always sets repos=all at runtime. |
| 561 | if rawGithubTool != false && len(getGitHubGuardPolicies(toolConfig)) == 0 && !hasGitHubApp(toolConfig) { |
| 562 | return map[string]any{ |
| 563 | "write-sink": map[string]any{ |
| 564 | "accept": []string{"*"}, |
| 565 | }, |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | return nil |
| 570 | } |
| 571 | |
| 572 | func getGitHubDockerImageVersion(githubTool map[string]any) string { |
| 573 | githubDockerImageVersion := string(constants.DefaultGitHubMCPServerVersion) // Default Docker image version |