gittuf icon indicating copy to clipboard operation
gittuf copied to clipboard

Wildcard in rule pattern doesn't apply to subdirectories

Open adityasaky opened this issue 1 year ago • 5 comments

What happened?

gittuf currently uses glob-style patterns. This means that file:foo/* will apply to all files in the foo/ directory but not in the foo/bar/ directory. The glob-style patterns are based off the upstream TUF specification but they're not ideal for gittuf. Instead, I propose we switch our patterns to align with gitignore. This should be a drop-in replacement. Note that with this change, file:foo/* will still not match other /, but we can at least support file:foo/**.

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

adityasaky avatar Feb 23 '24 20:02 adityasaky

Thinking aloud, but I think what we really want is just fnmatch? No need of ** then, fnmatch doesn't special case directory separaters. It operates strictly on strings as well.

adityasaky avatar Feb 23 '24 21:02 adityasaky

So what would the behavior be in this case then?

JustinCappos avatar Feb 24 '24 05:02 JustinCappos

I think fnmatch would meet the original expectation trivially. No need for **, * would match / supporting subdirectories as well.

adityasaky avatar Feb 28 '24 19:02 adityasaky

What if you don't want to match subdirectories? Is that use case important?

On Wed, Feb 28, 2024 at 2:00 PM Aditya Sirish @.***> wrote:

I think fnmatch would meet the original expectation trivially. No need for **, * would match / supporting subdirectories as well.

— Reply to this email directly, view it on GitHub https://github.com/gittuf/gittuf/issues/309#issuecomment-1969652272, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGRODZS5BHQP26V5MESQI3YV55FDAVCNFSM6AAAAABDXKMET2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRZGY2TEMRXGI . You are receiving this because you commented.Message ID: @.***>

JustinCappos avatar Feb 29 '24 13:02 JustinCappos

Do you mean where foo has three subdirectories a, b, c and you want a pattern to only apply to a and b and not c? fnmatch doesn't make this trivial (regex may be a better option here but I don't know if we want the complexity of regex). I want to note though that you could support this by explicitly defining a terminating rule for foo/c and then include a rule for foo/*. Either way, you're explicitly declaring the subdirectory you do not want to match.

adityasaky avatar Feb 29 '24 17:02 adityasaky