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

ahocorasick: improve matching with subdomains #2331

Merged
merged 1 commit into from
Mar 6, 2024

Commits on Mar 6, 2024

  1. ahocorasick: improve matching with subdomains

    The basic idea is to have the following logic:
    * pattern "DOMAIN" matches the domain itself (i.e exact match) *and* any
    subdomains (i.e. "ANYTHING.DOMAIN")
    * pattern "DOMAIN." matches *also* any strings for which is a prefix
    [please, note that this kind of match is handy but it is quite
    dangerous...]
    * pattern "-DOMAIN" matches *also* any strings for which is a postfix
    
    Examples:
    * pattern "wikipedia.it":
      * "wikipiedia.it" -> OK
      * "foo.wikipedia.it -> OK
      * "foowikipedia.it -> NO MATCH
      * "wikipedia.it.com -> NO MATCH
    * pattern "wikipedia.":
      * "wikipedia.it" -> OK
      * "foo.wikipedia.it -> OK
      * "foowikipedia.it -> NO MATCH
      * "wikipedia.it.com -> OK
    * pattern "-wikipedia.it":
      * "wikipedia.it" -> NO MATCH
      * "foo.wikipedia.it -> NO MATCH
      * "0001-wikipedia.it -> OK
      * "foo.0001-wikipedia.it -> OK
    
    Bottom line:
    * exact match
    * prefix with "." (always, implicit)
    * prefix with "-" (only if esplicitly set)
    * postfix with "." (only if esplicitly set)
    
    That means that the patterns cannot start with '.' anymore.
    
    Close ntop#2330
    IvanNardi committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    6025ee0 View commit details
    Browse the repository at this point in the history