Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make map and types directives analysable #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chrisnovakovic
Copy link

Proposed changes

The map directive (from ngx_http_map_module and ngx_stream_map_module) and types directive (from ngx_http_core_module) are distinct from other directives, in that their child directives may be arbitrary strings that aren't known to Nginx. This causes crossplane to report unrecognised/misused directive errors when analysing them with strict or check_ctx enabled; it also means that no meaningful analysis can be performed when check_args is enabled because the arity of child directives is unknown.

Add support for map's special directives (default, hostnames, and volatile) to the analyser. Recognise that arbitrary directive names inside a map or types block are valid and that they accept either one argument (if used in map) or one or more arguments (if used in types).

Fixes #101 and #103.


The restructuring of the bit masks in analyzer.py is necessary because there's no space left in the combined one on 32-bit architectures. Exploiting the fact that there isn't actually a need for the valid contexts and arguments information to be represented by the same bit mask, I've separated them into individual bit masks for each directive, restructured DIRECTIVES so each directive has a pair of bit masks (contexts + arguments) instead of an individual one, and modified analyze so it inspects the relevant one depending on the check being performed. This restructuring also creates space for 12 further new fields in the contexts bit mask and 19 further new fields in the arguments bit mask.

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch from my own fork

The `map` directive (from ngx_http_map_module and ngx_stream_map_module)
and `types` directive (from ngx_http_core_module) are distinct from
other directives, in that their child directives may be arbitrary
strings that aren't known to Nginx. This causes crossplane to report
unrecognised/misused directive errors when analysing them with `strict`
or `check_ctx` enabled; it also means that no meaningful analysis can be
performed when `check_args` is enabled because the arity of child
directives is unknown.

Add support for `map`'s special directives (`default`, `hostnames`, and
`volatile`) to the analyser. Recognise that arbitrary directive names
inside a `map` or `types` block are valid and that they accept either
one argument (if used in `map`) or one or more arguments (if used in
`types`).

Fixes nginxinc#101 and nginxinc#103.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http types blocks trigger various analyser failures
1 participant