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

Function TestSecurityUnauthorizedAccess

pkg/workflow/security_regression_test.go:399–419  ·  view source on GitHub ↗

============================================================================= Authorization Tests ============================================================================= TestSecurityUnauthorizedAccess validates that unauthorized expression contexts are properly rejected.

(t *testing.T)

Source from the content-addressed store, hash-verified

397// TestSecurityUnauthorizedAccess validates that unauthorized expression
398// contexts are properly rejected.
399func TestSecurityUnauthorizedAccess(t *testing.T) {
400 unauthorizedPatterns := []struct {
401 pattern string
402 description string
403 }{
404 {"${{ secrets.GITHUB_TOKEN }}", "GITHUB_TOKEN secret access"},
405 {"${{ secrets.API_KEY }}", "Custom secret access"},
406 {"${{ secrets.MY_SECRET_VALUE }}", "Underscore secret access"},
407 {"${{ github.token }}", "github.token access"},
408 {"${{ github.event.token }}", "event token access"},
409 }
410
411 for _, tt := range unauthorizedPatterns {
412 t.Run(tt.description, func(t *testing.T) {
413 err := validateExpressionSafety(tt.pattern)
414 if err == nil {
415 t.Errorf("Security violation: %s should be blocked", tt.pattern)
416 }
417 })
418 }
419}
420
421// TestSecurityTokenLeakage validates that tokens cannot be leaked through
422// various expression paths.

Callers

nothing calls this directly

Calls 3

validateExpressionSafetyFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected