feat(config): allow wildcard matches in import statements - #1816
Merged
Conversation
Signed-off-by: Xe Iaso <[email protected]>
…ogical file This is kind of a hack and only really works because of the exact way that the configuration snippets that Anubis uses works. This joins multiple YAML list entries as if they are just one big file that happens to have every YAML list entry in it. Signed-off-by: Xe Iaso <[email protected]>
Signed-off-by: Xe Iaso <[email protected]>
Signed-off-by: Xe Iaso <[email protected]>
Signed-off-by: Xe Iaso <[email protected]>
Signed-off-by: Xe Iaso <[email protected]>
Signed-off-by: Xe Iaso <[email protected]>
Signed-off-by: Xe Iaso <[email protected]>
Signed-off-by: Xe Iaso <[email protected]>
Signed-off-by: Xe Iaso <[email protected]>
Signed-off-by: Xe Iaso <[email protected]>
Contributor
Author
|
Oh heck i hit the wrong button. Oops. I thought this was a different PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Allow importing files matching wildcard patterns using
path/filepath#Match. For example:Supported wildcards
Anubis uses the Go standard library function
filepath.Matchfor matching. It supports four wildcards:*crawlers/*.yamlmatchescrawlers/kagibot.yaml, but notcrawlers/eu/kagibot.yaml.???-allow.yamlmatches00-allow.yamlandxe-allow.yaml, but not1-allow.yaml.[0-9][0-9][0-9]-*.yamlmatches00-monitoring.yaml, but notxe-monitoring.yaml.[^0-9][^0-9]*.yamlmatchesxe.yaml, but not00-xe.yaml.Use this Go playground link to test pattern matches.
Matched files load in natural sort order
Anubis matches requests top to bottom, similar to Apache's
DENY, ALLOWACL. Anubis uses the first rule that matches the request exactly. A rule that loads early can shadow a rule that loads later.When Anubis loads files imported with a wildcard match, it sorts the files in natural sort order. To control the order rules are loaded, put a number at the beginning of each filename:
Natural sort compares numbers numerically and words alphabetically. This makes
02-deny.yamlload before10-deny.yaml.Every matched file must be a top level list
Anubis combines the matched files into one YAML document and then parses that document. Write each file as a list of rules at the top level, with no indentation and no
bots:key.For example, take a folder
known-goodwith two files in it:When importing
known-good/*.yaml, Anubis reads them as if you wrote both lists of rules into one file:Closes: #1815
Checklist:
[Unreleased]section of docs/docs/CHANGELOG.mdnpm run test:integration(unsupported on Windows, please use WSL)