Skip to content
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

feat: As a user, I want to be able to set ip-restriction plugin http response code to 404 #12056

Open
papdaniel opened this issue Mar 17, 2025 · 4 comments
Labels
enhancement New feature or request user responded

Comments

@papdaniel
Copy link

Description

Now the default and only response code is 403 in ip-restriction plugin. I'd like to set it to 404 to hide the endpoints from black-listed/not white-listed sources, to not give the attackers a hint that there are some resources that they don't have access to.

@dosubot dosubot bot added the enhancement New feature or request label Mar 17, 2025
@papdaniel
Copy link
Author

I wanted to contribute, but spent a few hours to make the (any existing) tests run locally, but didn't succeed.. Followed these docs:
https://github.com/apache/apisix/blob/master/docs/en/latest/internal/testing-framework.md#run-the-test
https://github.com/apache/apisix/blob/master/docs/en/latest/build-apisix-dev-environment-on-mac.md
for me, none of them worked.

@juzhiyuan
Copy link
Member

Hi @papdaniel, from the description, I didn't know what kind of errors you encountered.

I have two ideas:

  1. You can use https://github.com/api7/apisix-plugin-template to write and run test cases.
  2. Please take some time to organize the steps, expectations, and errors in details so that I or others can try to help you.

@juzhiyuan juzhiyuan added the wait for update wait for the author's response in this issue/PR label Mar 18, 2025
@papdaniel
Copy link
Author

Hello @juzhiyuan!
As I need a simple modification in ip-restriction plugin I'd just add my test cases to t/plugin/ip-restriction.t, and to run I'd go with this https://github.com/apache/apisix/blob/master/docs/en/latest/build-apisix-dev-environment-on-mac.md description which seems quite straightforward with docker. I've done all the steps, and tried to run the test file (first without any modification):
docker exec -it apisix-dev-env prove t/plugin/ip-restriction.t
I'm getting:

t/plugin/ip-restriction.t .. 1/? 
#   Failed test 'ERROR: client socket timed out - t/plugin/ip-restriction.t TEST 1: sanity
# '
#   at /usr/local/share/perl/5.30.0/Test/Nginx/Socket.pm line 2206.

#   Failed test 't/plugin/ip-restriction.t TEST 1: sanity - status code ok'
#   at /usr/local/share/perl/5.30.0/Test/Nginx/Socket.pm line 949.
#          got: ''
#     expected: '200'

#   Failed test 't/plugin/ip-restriction.t TEST 1: sanity - response_body - response is expected (repeated req 0, req 0)'
#   at /usr/local/share/perl/5.30.0/Test/Nginx/Socket.pm line 1660.
#          got: ''
#     expected: '{"message":"Your IP address is not allowed","whitelist":["10.255.254.0/24","192.168.0.0/16"]}
# '
....

@github-actions github-actions bot added user responded and removed wait for update wait for the author's response in this issue/PR labels Mar 18, 2025
@Baoyuantop
Copy link
Contributor

ERROR: client socket timed out

Maybe try increasing the timeout configuration in test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request user responded
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants