crossplane
crossplane copied to clipboard
`http` `map` not fully supported
Describe the bug
This is similar to #101 but slightly different because of the extra expressiveness of map
compared to types
.
The analyser doesn't take into account the special syntax of http
map
blocks, in which directives are one of a handful of special directives or arbitrary strings. The analyser also doesn't support any of the special directives listed in the ngx_http_map_module
documentation. This means that crossplane doesn't recognise Nginx configurations containing map
blocks as valid when running in strict mode, which verifies that directive names are present in the analyser's allowlist. A similar problem occurs when check_ctx=True
is set via the API.
To Reproduce
Run crossplane parse --strict
on the following Nginx configuration:
http {
map $http_host $name {
hostnames;
volatile;
default 0;
example.com 1;
include map_values.conf;
}
}
# map_values.conf:
*.example.com 2;
\volatile 3;
This outputs:
{"status":"failed","errors":[{"file":"nginx.conf","error":"unknown directive \"hostnames\" in nginx.conf:3","line":3},{"file":"nginx.conf","error":"unknown directive \"volatile\" in nginx.conf:4","line":4},{"file":"nginx.conf","error":"unknown directive \"default\" in nginx.conf:5","line":5},{"file":"nginx.conf","error":"unknown directive \"example.com\" in nginx.conf:6","line":6},{"file":"map_values.conf","error":"unknown directive \"*.example.com\" in map_values.conf:1","line":1},{"file":"map_values.conf","error":"unknown directive \"\\volatile\" in map_values.conf:2","line":2}],"config":[{"file":"nginx.conf","status":"failed","errors":[{"error":"unknown directive \"hostnames\" in nginx.conf:3","line":3},{"error":"unknown directive \"volatile\" in nginx.conf:4","line":4},{"error":"unknown directive \"default\" in nginx.conf:5","line":5},{"error":"unknown directive \"example.com\" in nginx.conf:6","line":6}],"parsed":[{"directive":"http","line":1,"args":[],"block":[{"directive":"map","line":2,"args":["$http_host","$name"],"block":[{"directive":"include","line":7,"args":["map_values.conf"],"includes":[1]}]}]}]},{"file":"map_values.conf","status":"failed","errors":[{"error":"unknown directive \"*.example.com\" in map_values.conf:1","line":1},{"error":"unknown directive \"\\volatile\" in map_values.conf:2","line":2}],"parsed":[]}]}
Expected behavior
No errors are encountered, and an AST is printed.
Your environment
crossplane v0.5.7 (although the problem also exists on master)