File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
tests/plugins/simply/status_page_exposed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,36 @@ class status_page_exposed(Plugin):
1515 )
1616 directives = ["stub_status" ]
1717
18+ def _server_uses_only_unix_sockets (self , directive ):
19+ """Check if the enclosing server block only listens on Unix sockets.
20+
21+ Args:
22+ directive: The directive to check.
23+
24+ Returns:
25+ True if the server block has at least one listen directive and all
26+ of them use Unix sockets.
27+ """
28+ for parent in directive .parents :
29+ if parent .name == "server" :
30+ listen_directives = parent .find ("listen" )
31+ if not listen_directives :
32+ return False
33+ return all (
34+ d .args and d .args [0 ].lower ().startswith ("unix:" )
35+ for d in listen_directives
36+ )
37+ return False
38+
1839 def audit (self , directive ):
1940 """Audit stub_status directive for missing access restrictions.
2041
2142 Args:
2243 directive: The stub_status directive to audit.
2344 """
45+ if self ._server_uses_only_unix_sockets (directive ):
46+ return
47+
2448 parent = directive .parent
2549 if not parent :
2650 return
Original file line number Diff line number Diff line change 1+ server {
2+ listen unix:/run/nginx/status.sock;
3+
4+ location = / {
5+ stub_status;
6+ }
7+
8+ location / {
9+ return 404;
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments