crossplane icon indicating copy to clipboard operation
crossplane copied to clipboard

`http` `types` blocks trigger various analyser failures

Open chrisnovakovic opened this issue 2 years ago • 0 comments

Describe the bug

The analyser doesn't take into account the special syntax of http types blocks, in which directives are arbitrary MIME types. This means that crossplane doesn't recognise Nginx configurations containing types 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 {
    types {
        text/html  html;
        image/gif  gif;
        image/jpeg jpg jpeg;
    }
}

This outputs:

{"status":"failed","errors":[{"file":"nginx.conf","error":"unknown directive \"text/html\" in nginx.conf:3","line":3},{"file":"nginx.conf","error":"unknown directive \"image/gif\" in nginx.conf:4","line":4},{"file":"nginx.conf","error":"unknown directive \"image/jpeg\" in nginx.conf:5","line":5}],"config":[{"file":"nginx.conf","status":"failed","errors":[{"error":"unknown directive \"text/html\" in nginx.conf:3","line":3},{"error":"unknown directive \"image/gif\" in nginx.conf:4","line":4},{"error":"unknown directive \"image/jpeg\" in nginx.conf:5","line":5}],"parsed":[{"directive":"http","line":1,"args":[],"block":[{"directive":"types","line":2,"args":[],"block":[]}]}]}]}

Expected behavior

No errors are encountered, and an AST is printed.

Your environment

crossplane v0.5.7 (although the problem also exists on master)

chrisnovakovic avatar Jul 18 '22 16:07 chrisnovakovic