|
1 | 1 | // Package workflow provides strict mode security validation for agentic workflows. |
2 | 2 | // |
3 | | -// # Strict Mode Validation Functions |
| 3 | +// # Strict Mode Validation |
4 | 4 | // |
5 | | -// This file contains the individual validation functions that enforce security |
| 5 | +// This file contains strict mode validation functions that enforce security |
6 | 6 | // and safety constraints when workflows are compiled with the --strict flag. |
7 | | -// These functions are called by validateStrictMode() in strict_mode.go. |
| 7 | +// |
| 8 | +// Strict mode is designed for production workflows that require enhanced security |
| 9 | +// guarantees. It enforces constraints on: |
| 10 | +// - Write permissions on sensitive scopes |
| 11 | +// - Network access configuration |
| 12 | +// - Custom MCP server network settings |
| 13 | +// - Bash wildcard tool usage |
8 | 14 | // |
9 | 15 | // # Validation Functions |
10 | 16 | // |
11 | 17 | // The strict mode validator performs progressive validation: |
12 | | -// 1. validateStrictPermissions() - Refuses write permissions on sensitive scopes |
13 | | -// 2. validateStrictNetwork() - Requires explicit network configuration |
14 | | -// 3. validateStrictMCPNetwork() - Requires network config on custom MCP servers |
| 18 | +// 1. validateStrictMode() - Main orchestrator that coordinates all strict mode checks |
| 19 | +// 2. validateStrictPermissions() - Refuses write permissions on sensitive scopes |
| 20 | +// 3. validateStrictNetwork() - Requires explicit network configuration |
| 21 | +// 4. validateStrictMCPNetwork() - Requires network config on custom MCP servers |
15 | 22 | // |
16 | 23 | // # Integration with Security Scanners |
17 | 24 | // |
|
28 | 35 | // - It enforces tool usage restrictions for security |
29 | 36 | // |
30 | 37 | // For general validation, see validation.go. |
31 | | -// For the main strict mode orchestrator, see strict_mode.go. |
32 | 38 | // For detailed documentation, see specs/validation-architecture.md |
33 | 39 | package workflow |
34 | 40 |
|
@@ -118,3 +124,37 @@ func (c *Compiler) validateStrictMCPNetwork(frontmatter map[string]any) error { |
118 | 124 |
|
119 | 125 | return nil |
120 | 126 | } |
| 127 | + |
| 128 | +// validateStrictMode performs strict mode validations on the workflow |
| 129 | +// |
| 130 | +// This is the main orchestrator that calls individual validation functions. |
| 131 | +// It performs progressive validation: |
| 132 | +// 1. validateStrictPermissions() - Refuses write permissions on sensitive scopes |
| 133 | +// 2. validateStrictNetwork() - Requires explicit network configuration |
| 134 | +// 3. validateStrictMCPNetwork() - Requires network config on custom MCP servers |
| 135 | +// |
| 136 | +// Note: Strict mode also affects zizmor security scanner behavior (see pkg/cli/zizmor.go) |
| 137 | +// When zizmor is enabled with --zizmor flag, strict mode will treat any security |
| 138 | +// findings as compilation errors rather than warnings. |
| 139 | +func (c *Compiler) validateStrictMode(frontmatter map[string]any, networkPermissions *NetworkPermissions) error { |
| 140 | + if !c.strictMode { |
| 141 | + return nil |
| 142 | + } |
| 143 | + |
| 144 | + // 1. Refuse write permissions |
| 145 | + if err := c.validateStrictPermissions(frontmatter); err != nil { |
| 146 | + return err |
| 147 | + } |
| 148 | + |
| 149 | + // 2. Require network configuration and refuse "*" wildcard |
| 150 | + if err := c.validateStrictNetwork(networkPermissions); err != nil { |
| 151 | + return err |
| 152 | + } |
| 153 | + |
| 154 | + // 3. Require network configuration on custom MCP servers |
| 155 | + if err := c.validateStrictMCPNetwork(frontmatter); err != nil { |
| 156 | + return err |
| 157 | + } |
| 158 | + |
| 159 | + return nil |
| 160 | +} |
0 commit comments