-
Notifications
You must be signed in to change notification settings - Fork 0
Implement application-level IP filtering with allowlist/blocklist support #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: GrantBirki <[email protected]>
…port Co-authored-by: GrantBirki <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive application-level IP filtering to the Hooks service, enabling both global and endpoint-specific allowlist/blocklist support with CIDR notation and configurable headers.
- Introduces a new
IpFiltering
class with core allowlist/blocklist logic and CIDR support - Integrates IP filtering into the API request pipeline
- Updates configuration schemas and adds extensive unit and acceptance tests
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
lib/hooks/app/network/ip_filtering.rb | Core IP filtering logic with allowlist, blocklist, CIDR support |
lib/hooks/app/api.rb | Hooks IP filtering into request pipeline |
lib/hooks/core/config_validator.rb | Adds ip_filtering schema for global and endpoint configs |
lib/hooks/app/helpers.rb | Adds helper method to invoke IP filtering |
spec/unit/app/network/ip_filtering_spec.rb | Unit tests covering IP filtering scenarios |
spec/acceptance/config/endpoints/*.yml | Acceptance configs for direct and custom-header examples |
spec/acceptance/acceptance_tests.rb | Acceptance tests validating IP filtering behavior |
.bundle/config | CI bundle path/deployment settings update |
Comments suppressed due to low confidence (2)
lib/hooks/app/network/ip_filtering.rb:21
- The docstring says missing or invalid config raises an error, but the code simply returns for missing config and skips invalid patterns. Update the comment to reflect the actual behavior.
# If the IP filtering configuration is missing or invalid, it raises an error.
.bundle/config:3
- This CI-specific bundle configuration may not be relevant to all contributors. Consider removing or git-ignoring
.bundle/config
changes to avoid environmental drift.
BUNDLE_PATH: "/home/runner/work/hooks/hooks/vendor/bundle"
@copilot please pickup where you left off. Everything looks great but test coverage is not at 100%. Run |
…ation Co-authored-by: GrantBirki <[email protected]>
Done! Fixed the test coverage issue and completed the documentation. Changes made:
All tests pass, coverage is now 100% (971/971 lines), and linting passes. The IP filtering feature is fully documented and ready for use. Commit: 05a6dc8 |
This PR implements comprehensive application-level IP filtering functionality for the Hooks service, allowing both global and endpoint-specific IP-based access control.
Overview
The implementation adds IP filtering as a "pre-flight" operation in the request processing pipeline, supporting both allowlist and blocklist configurations with CIDR notation support.
Key Features
192.168.1.0/24
)X-Forwarded-For
but supports custom headersConfiguration Examples
Endpoint-Level Configuration
Global Configuration
Implementation Details
lib/hooks/app/network/ip_filtering.rb
- Main IP filtering functionalitylib/hooks/app/api.rb
lib/hooks/core/config_validator.rb
to validate IP filtering configHooks::Plugins::Handlers::Error
for consistent error responsesSecurity Considerations
X-Forwarded-For
. It should only be used by those who understand the security implications and have proper network-level controls in place. For production security, consider implementing IP filtering at the network or load balancer level.Testing
Example Usage
Fixes #56.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.