(lines []string, sandboxLines []string)
| 127 | } |
| 128 | |
| 129 | func insertSandboxAfterNetworkBlock(lines []string, sandboxLines []string) []string { |
| 130 | insertIndex := -1 |
| 131 | inNetworkBlock := false |
| 132 | for i, line := range lines { |
| 133 | trimmed := strings.TrimSpace(line) |
| 134 | if strings.HasPrefix(trimmed, "network:") { |
| 135 | inNetworkBlock = true |
| 136 | continue |
| 137 | } |
| 138 | if inNetworkBlock && len(trimmed) > 0 && isTopLevelKey(line) { |
| 139 | insertIndex = i |
| 140 | break |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | if insertIndex >= 0 { |
| 145 | newLines := make([]string, 0, len(lines)+len(sandboxLines)) |
| 146 | newLines = append(newLines, lines[:insertIndex]...) |
| 147 | newLines = append(newLines, sandboxLines...) |
| 148 | newLines = append(newLines, lines[insertIndex:]...) |
| 149 | return newLines |
| 150 | } |
| 151 | |
| 152 | return append(lines, sandboxLines...) |
| 153 | } |
| 154 | |
| 155 | func mergeFirewallIntoExistingSandbox(lines []string, fieldValue any) ([]string, bool) { |
| 156 | agentLines := sandboxAgentLinesForExistingSandbox(fieldValue) |
no test coverage detected