Skip to content

Rule patterns match anywhere in a path, so ~/tmp is treated as /tmp #41

Description

@Muawiya-contact

RulesDb::classify matches patterns with a plain substring test:

if rule.patterns.iter().any(|pat| p.contains(pat.as_str())) {

Nothing anchors the pattern to a path component, so rules fire well outside where they were meant to:

  • /home/user/tmp/tax-return.pdf contains /tmp/ and comes back temp_file
  • ~/photos/target/debug/raw.cr2 matches /target/debug and comes back build_artifact

Both then show up as reclaimable, and both are actionable (review is not gated).

There's already a TODO: replace with proper glob matching (globset crate) on the patterns field. Either that, or at minimum anchor patterns to the start of the path or to a /-delimited component boundary. Whichever way it goes, the existing rules in base.json need re-checking against it — some are written assuming the loose behaviour.

crates/diskern-core/src/rules.rs:43

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is neededrulesThe safety rules databasesafetyTouches the read-only / quarantine guarantees

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions