Make map
and types
directives analysable
#104
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
The
map
directive (from ngx_http_map_module and ngx_stream_map_module) andtypes
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 withstrict
orcheck_ctx
enabled; it also means that no meaningful analysis can be performed whencheck_args
is enabled because the arity of child directives is unknown.Add support for
map
's special directives (default
,hostnames
, andvolatile
) to the analyser. Recognise that arbitrary directive names inside amap
ortypes
block are valid and that they accept either one argument (if used inmap
) or one or more arguments (if used intypes
).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, restructuredDIRECTIVES
so each directive has a pair of bit masks (contexts + arguments) instead of an individual one, and modifiedanalyze
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