============================================================================= Authorization Tests ============================================================================= TestSecurityUnauthorizedAccess validates that unauthorized expression contexts are properly rejected.
(t *testing.T)
| 397 | // TestSecurityUnauthorizedAccess validates that unauthorized expression |
| 398 | // contexts are properly rejected. |
| 399 | func 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. |
nothing calls this directly
no test coverage detected