Glob Pattern Matching Algorithm

Reference of the Glob Pattern Matching Algorithm

The glob pattern matching algorithm describes the rules and behavior for matching file paths against glob patterns on the Ketryx Platform, specifically for restricting dependency file locations and detecting Git-based items for repositories.


Matching a file path when multiple glob patterns have been provided

  • Matching occurs from the first defined pattern to the last defined pattern

  • During the matching, it keeps a match / no match state that is updated based on the current matching result of each glob pattern

  • The given file path is matched against each glob pattern

  • As soon as a non-negated glob pattern matches the file path, the matching state would be true

  • From there on, negated patterns (starting with !) matching the file path may set the matching state back to false

  • Following negation, subsequent matches of non-negated patterns can revert the matching state back to true, allowing for toggling between inclusion and exclusion of files or paths

  • Alternating matches of negated and non-negated patterns can toggle the matching state, allowing fine-grained control over which files or paths are ultimately selected

  • The final matching result will be returned, i.e. "the last match wins", and whether the file is included in the analysis is based on whether that match is negated or not

Last updated

© 2024 Ketryx Corporation