Allow a regex whitelist
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start at ServeHTTP and trace how the configured blocklist regular expressions are loaded and matched against req.URL.EscapedPath(). Add the proposed regexWhitelist behavior so matching whitelist expressions override a block, then verify that blocked paths remain forbidden while explicitly whitelisted paths are passed to the next handler.
Written by the indexing model from the issue text.
Description
Would we consider allowing a whitelist to work against the blocklist in this plugin? My use case is that I wish to block all paths beginning with, e.g. /wp-admin (the wordpress admin backend), but allow access to /wp-admin/admin-ajax.php specifically.
As Golang/RE2 expressions do not allow lookaheads, this is a difficult express to write (or impossible depending on the functionality required). I suspect this may be a common request (something that is fairly trivial with, say, .htaccess files).
One option would be to add a second configuration to the plugin, regexWhitelist, with ServeHTTP looking something along the lines of:
currentPath := req.URL.EscapedPath()
blocked := false
for _, re := range b.regexps {
if re.MatchString(currentPath) {
blocked = true
break
}
}
for _, re := range b.regexpsWhitelist {
if re.MatchString(currentPath) {
blocked = false
break
}
}
if (blocked) {
rw.WriteHeader(http.StatusForbidden)
return
}
b.next.ServeHTTP(rw, req)
(may not be perfect, been a while since I wrote some Golang)
Thoughts?
- Dominant language
- Go
- Stars
- 28
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from traefik/plugin-blockpath
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
traefik/plugin-blockpath#14 ·
All issues in traefik/plugin-blockpath
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·