Skip to content

Conversation

sakumoto-shota
Copy link

@sakumoto-shota sakumoto-shota commented Aug 12, 2025

Summary

This PR enhances the DevContainer firewall configuration to better handle modern CDN
and load-balanced services by implementing a hybrid approach for IP management.

Changes

  • Hybrid IP Management:

    • GitHub continues using Meta API for comprehensive CIDR ranges (static IPSet)
    • Other services use dynamic DNS resolution with TTL support (dynamic IPSet)
  • Automatic Updates:

    • IPs expire after 600 seconds (configurable)
    • Automatic refresh script runs every 5 minutes via cron
    • Domain list passed as arguments to refresh script (no duplication)
  • Improved Maintainability:

    • Domain list managed as shell array in single location
    • Clear separation between static and dynamic IP management
    • Reduced verbose logging while keeping essential error messages

Testing

Tested in Docker container with the following results:

  • GitHub API: ✅ Accessible (47 CIDR ranges loaded)
  • NPM Registry: ✅ Accessible
  • Anthropic API: ✅ Accessible
  • External sites (Google, Example.com): ✅ Properly blocked
  • Dynamic IP refresh: ✅ Working with domain arguments
  • TTL expiry: ✅ IPs auto-expire after 600s

Backward Compatibility

  • Fully backward compatible
  • Cleans up legacy allowed-domains IPSet if exists
  • Error handling remains the same
  • All existing functionality preserved

…nagement

- Implement dual IPSet approach (static for GitHub, dynamic for others)
- Add automatic DNS refresh with TTL support (600s default)
- Improve maintainability with single domain array configuration
- Pass domains as arguments to refresh script (avoid duplication)
- Reduce verbose logging while keeping error messages
IFS=$'\n\t' # Stricter word splitting

# Configuration - Domain list as shell array for easy maintenance
declare -a DYNAMIC_DOMAINS=(
Copy link

@MarkS-AL MarkS-AL Aug 29, 2025

Choose a reason for hiding this comment

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

Allow additional domains, eg "pypi.org" to be passed in externally, eg via WHITELIST_DOMAINS env var?
Concat the user whitelist with this list of domain names?

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