Skip to content

Some combinations of wildcards inside alternates fail #50

@hackery

Description

@hackery

This glob library is used for a critical bit of functionality in Telegraf -metric filtering. There appear to be a number of cases where it silently fails to match, and one which has caused us much grief recently involves multiple * wildcards inside a { } alternate construct.

Telegraf is configured with a list of patterns for a namepass/namedrop function, and internally it composes the list into a single pattern with alternates. I've reduced our test case to one similar to the samples in glob_test.go; here is the failing test surrounded by variations which all work:

glob(true, "yandex:*.exe:page.*", "yandex:service.exe:page.12345"),
glob(true, "*yandex:*.exe:page.*", "yandex:service.exe:page.12345"),
glob(true, "{*yandex:*.exe:page.*}", "yandex:service.exe:page.12345"),
glob(true, "{google.*,yandex:*.exe:page.*}", "yandex:service.exe:page.12345"),
glob(true, "{google.*,*yandex:*.exe:page.*}", "yandex:service.exe:page.12345"), // FAIL
glob(true, "{google.?,*yandex:*.exe:page.*}", "yandex:service.exe:page.12345"),
glob(true, "{google.*,*yandex:service.exe:page.*}", "yandex:service.exe:page.12345"),
glob(true, "{google.*,*yandex:*.exe:*.12345}", "yandex:service.exe:page.12345"),

The result of running this test in current master branch is:

--- FAIL: TestGlob (0.00s)
    --- FAIL: TestGlob/#64 (0.00s)
        glob_test.go:190: pattern "{google.*,*yandex:*.exe:page.*}" matching "yandex:service.exe:page.12345" should be true but got false
            <btree:[<nil><-<any_of:[<text:`google.`>,<btree:[<contains:[yandex:]><-<text:`.exe:page.`>-><nil>]>]>-><super>]>
FAIL
exit status 1
FAIL    github.com/gobwas/glob  0.004s

This has become a huge problem for us, with huge numbers of metrics being sent to InfluxDB which over time overwhelm it (and post-hoc deletions are unusably slow).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions