mirror of
https://github.com/YunoHost/package_linter.git
synced 2024-09-03 20:06:12 +02:00
Report incorrect syntax for more_set_headers
This commit is contained in:
parent
813b244f01
commit
d66362f08f
1 changed files with 27 additions and 0 deletions
|
@ -631,6 +631,33 @@ class Configurations(TestSuite):
|
||||||
"and https://github.com/openresty/headers-more-nginx-module#more_set_headers )"
|
"and https://github.com/openresty/headers-more-nginx-module#more_set_headers )"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@test()
|
||||||
|
def misc_nginx_more_set_headers(self):
|
||||||
|
|
||||||
|
app = self.app
|
||||||
|
|
||||||
|
for filename in os.listdir(app.path + "/conf") if os.path.exists(app.path + "/conf") else []:
|
||||||
|
# Ignore subdirs or filename not containing nginx in the name
|
||||||
|
if not os.path.isfile(app.path + "/conf/" + filename) or "nginx" not in filename:
|
||||||
|
continue
|
||||||
|
|
||||||
|
content = open(app.path + "/conf/" + filename).read()
|
||||||
|
if "location" in content and "more_set_headers" in content:
|
||||||
|
|
||||||
|
lines = content.split("\n")
|
||||||
|
more_set_headers_lines = [l for l in lines if "more_set_headers" in l]
|
||||||
|
def right_syntax(line):
|
||||||
|
return re.search(r"more_set_headers [\"\'][\w-]+\s?: .*[\"\'];", line)
|
||||||
|
|
||||||
|
if any(not right_syntax(line) for line in more_set_headers_lines):
|
||||||
|
yield Warning(
|
||||||
|
"It looks like the syntax for the more_set_headers "
|
||||||
|
"instruction is incorrect in the nginx conf (N.B. "
|
||||||
|
": it's different than the add_header syntax!) ... "
|
||||||
|
"The syntax should look like: "
|
||||||
|
"more_set_headers \"Header-Name: value\""
|
||||||
|
)
|
||||||
|
|
||||||
@test()
|
@test()
|
||||||
def misc_nginx_path_traversal(self):
|
def misc_nginx_path_traversal(self):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue