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 don't think allowlist and denylist of ua-restriction can be enabled at the same time #7467

Closed
840963657 opened this issue Jul 15, 2022 · 12 comments · Fixed by #9841
Labels
bug Something isn't working

Comments

@840963657
Copy link
Contributor

Description

I found other restriction plugin has a logic:Either one of whitelist or blacklist attribute must be specified。
But in ua-restriction, both allowlist and denylist can be used on their own.
If User-Agent is neither on the allowlist nor the denylist , the processing logic is the same as that of the allowlist .
So why do we still use the allowlist ?

@tokers
Copy link
Contributor

tokers commented Jul 15, 2022

Fair enough. But if we make allowlist and denylist exclusive, then this is a broken change. We need to evaluate it.

@tzssangglass
Copy link
Member

tzssangglass commented Jul 15, 2022

if allowlist and denylist are both on, ua-restriction only uses allowlist, and User-Agents that are not in allowlist are rejected. How about this?

@spacewander
Copy link
Member

Look like if the allowlist is matched, the denylist will be skipped?
The match rule is via regex, so it is possible for a UA to match both allowlist and denylist.

@840963657
Copy link
Contributor Author

840963657 commented Jul 15, 2022

Another problem: If I only configure allowlist , User-Agent is not on allowlist will also be released.

this code in apisix/plugins/ua-restriction.lua(apisix 2.13)

`
local MATCH_NONE = 0
local MATCH_ALLOW = 1
local MATCH_DENY = 2
......

if match > MATCH_ALLOW then
return 403, { message = conf.message }
end
`

I looked at the code, If User-Agent on allowlist, the value of match becomes MATCH_ALLOW. If User-Agent not on allowlist, the value of match is MATCH_NONE. In both cases, User-Agent will be released.
So I think the allowlist is meaningless.

@spacewander
Copy link
Member

So we need an allowlist-only mode. When only allowlist is given, MATCH_NONE will be rejected.
@840963657
Would you like to work on it?

@github-actions
Copy link

github-actions bot commented Jul 4, 2023

This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jul 4, 2023
@monkeyDluffy6017
Copy link
Contributor

I think the allowlist and denylist should be exclusive, it they exist at the same time, it is very difficult to understand

@monkeyDluffy6017 monkeyDluffy6017 added bug Something isn't working and removed stale discuss labels Jul 11, 2023
@monkeyDluffy6017 monkeyDluffy6017 moved this to 📋 Backlog in Apache APISIX backlog Jul 11, 2023
@bzp2010
Copy link
Contributor

bzp2010 commented Jul 11, 2023

I think it could go either way:

  • Follow some sort of prioritization, e.g., allowlist over denylist. Match requests against each rule in order, and when any of the rules are satisfied, stop matching and either reject or pass them
  • Use exclusion mode to allow only one type of allowlist or denylist to be configured

The second is simpler and easier to understand. I'm not sure there is a need for the first way of this plugin.

@moonming moonming moved this from 📋 Backlog to 🏗 In progress in Apache APISIX backlog Jul 11, 2023
@monkeyDluffy6017
Copy link
Contributor

monkeyDluffy6017 commented Jul 11, 2023

@bzp2010 The first one looks meanless, if you set a allowlist, all you want is for the allowlist to pass, why do you set a blacklist at all? to block the one in the allowlist?

@jiangfucheng
Copy link
Member

I think it could go either way:

  • Follow some sort of prioritization, e.g., allowlist over denylist. Match requests against each rule in order, and when any of the rules are satisfied, stop matching and either reject or pass them
  • Use exclusion mode to allow only one type of allowlist or denylist to be configured

The second is simpler and easier to understand. I'm not sure there is a need for the first way of this plugin.

1.I also agree with second way.
2.For first way, If the request not in both allowlist and denylist, what should we do? passing or rejecting seem not reasonable.

@monkeyDluffy6017
Copy link
Contributor

I think we can work on this now

@jiangfucheng
Copy link
Member

I think we can work on this now

Ok, I will raise a new PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
8 participants