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

Function TestSecurityDoSViaLargeInputs

pkg/workflow/security_regression_test.go:219–269  ·  view source on GitHub ↗

============================================================================= DoS Prevention Tests ============================================================================= TestSecurityDoSViaLargeInputs validates that excessively large inputs are handled without causing denial of service.

(t *testing.T)

Source from the content-addressed store, hash-verified

217// TestSecurityDoSViaLargeInputs validates that excessively large inputs
218// are handled without causing denial of service.
219func TestSecurityDoSViaLargeInputs(t *testing.T) {
220 tests := []struct {
221 name string
222 contentFunc func() string
223 description string
224 }{
225 {
226 name: "very_long_expression",
227 contentFunc: func() string {
228 // Create a very long but valid expression
229 expr := "${{ "
230 for i := 0; i < 100; i++ {
231 expr += "github.workflow && "
232 }
233 expr += "github.repository }}"
234 return expr
235 },
236 description: "Very long expression should be handled",
237 },
238 {
239 name: "many_expressions",
240 contentFunc: func() string {
241 // Many repeated expressions
242 var sb strings.Builder
243 for i := 0; i < 1000; i++ {
244 sb.WriteString("${{ github.workflow }} ")
245 }
246 return sb.String()
247 },
248 description: "Many expressions should be handled",
249 },
250 {
251 name: "excessive_whitespace",
252 contentFunc: func() string {
253 return "${{" + strings.Repeat(" ", 10000) + "github.workflow" + strings.Repeat(" ", 10000) + "}}"
254 },
255 description: "Excessive whitespace should be handled",
256 },
257 }
258
259 for _, tt := range tests {
260 t.Run(tt.name, func(t *testing.T) {
261 content := tt.contentFunc()
262
263 // The parser should handle these without panic or timeout
264 // We don't require a specific result, just that it doesn't hang
265 err := validateExpressionSafety(content)
266 _ = err // We don't care about the result, just that it completes
267 })
268 }
269}
270
271// TestSecurityDoSViaNestedYAML validates that deeply nested YAML structures
272// don't cause stack overflow or excessive resource consumption.

Callers

nothing calls this directly

Calls 3

validateExpressionSafetyFunction · 0.85
StringMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected