Skip to content

Add validation for safe-outputs.allowed-domains#9017

Merged
pelikhan merged 5 commits intomainfrom
copilot/add-safe-outputs-validation
Jan 5, 2026
Merged

Add validation for safe-outputs.allowed-domains#9017
pelikhan merged 5 commits intomainfrom
copilot/add-safe-outputs-validation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 5, 2026

Implements validation for domain patterns in safe-outputs.allowed-domains configuration to catch malformed domains at compile time.

Changes

  • Validation logic (pkg/workflow/safe_outputs_domains_validation.go)

    • Validates plain domains (github.com) and wildcard patterns (*.github.com)
    • Rejects invalid patterns: multiple wildcards, misplaced wildcards, special characters, malformed syntax
    • Returns actionable error messages with examples
    • Uses comprehensive regex pattern for domain validation
  • Compiler integration (pkg/workflow/compiler.go)

    • Added validation call in CompileWorkflowData() after sandbox validation
    • Errors formatted consistently with existing compilation errors
  • Test coverage (pkg/workflow/safe_outputs_domains_validation_test.go)

    • 240+ test cases covering valid/invalid patterns and edge cases
    • Integration tests with realistic workflow configurations
    • Comprehensive regex validation tests (60+ cases) covering:
      • Valid patterns: plain domains, wildcards, numbers, hyphens, case variations, length limits
      • Invalid patterns: special characters, dot placement errors, wildcard position rules, hyphen placement rules
      • Edge cases: 63-character labels, single-label domains, IP-like formats, multiple nesting levels
  • JavaScript wildcard tests (actions/setup/js/sanitize_content.test.cjs)

    • Added comprehensive tests for wildcard domain pattern matching in JavaScript sanitization
    • Verifies existing wildcard support in sanitize_content_core.cjs works correctly with patterns like *.example.com
    • Tests confirm wildcard, base domain, and mixed configuration scenarios

Example

Valid configuration:

safe-outputs:
  allowed-domains:
    - github.com
    - "*.githubusercontent.com"
    - api.example.com

Error for invalid pattern:

error: safe-outputs.allowed-domains[1]: domain pattern '*.*.github.com' contains multiple wildcards, only one wildcard at the start is allowed (e.g., '*.example.com')

[!WARNING]

Original prompt

Add support for safe-outputs.allowed-domain validation.

safe-outputs:
   allowed-domain:
      - *.github.com

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 5, 2026 17:18
- Create validation function for domain patterns (plain and wildcard)
- Add comprehensive test coverage for domain validation
- Integrate validation into compiler workflow
- Support wildcards like *.github.com
- Validate against invalid patterns (multiple wildcards, empty, etc.)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Apply De Morgan's law to character validation logic
- Use require for error assertions as per testifylint rules

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for safe-outputs.allowed-domain validation Add validation for safe-outputs.allowed-domains Jan 5, 2026
Copilot AI requested a review from pelikhan January 5, 2026 17:32
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Jan 5, 2026

@copilot add support in the javascript secret redaction code to also support the wildcards and filter domains accordingly.

Copy link
Copy Markdown
Collaborator

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply

Comment thread pkg/workflow/safe_outputs_domains_validation.go
- Add tests for wildcard domain patterns (*.example.com)
- Test wildcard matching with subdomains and base domains
- Test mixed wildcard and plain domain configurations
- Verify redaction for non-matching domains
- Confirm existing wildcard implementation works correctly

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot add support in the javascript secret redaction code to also support the wildcards and filter domains accordingly.

The JavaScript sanitization code already has wildcard support implemented in sanitize_content_core.cjs (lines 210-214). I've added comprehensive tests in commit 9bb3125 to verify wildcard patterns like *.github.com work correctly with domain filtering and redaction.

The tests confirm:

  • Wildcard patterns (*.example.com) match subdomains correctly
  • Base domain is allowed when using wildcard patterns
  • Mixed wildcard and plain domains work together
  • Non-matching domains are properly redacted

- Add 60+ test cases for domain pattern regex validation
- Test valid patterns: plain domains, wildcards, numbers, hyphens, case variations
- Test invalid patterns: special chars, dot placement, wildcard rules, hyphen rules
- Test edge cases: length limits (63 chars), single labels, IP-like formats
- Verify regex correctly handles all domain validation scenarios

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review January 5, 2026 18:49
@pelikhan pelikhan merged commit a3f64c2 into main Jan 5, 2026
4 checks passed
@pelikhan pelikhan deleted the copilot/add-safe-outputs-validation branch January 5, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants