Skip to content

Poetry cache detection uses substring matching on path instead of path components #398

@karthiknadig

Description

@karthiknadig

Summary

is_poetry_cache_environment in crates/pet-poetry/src/lib.rs checks if a path contains the substrings "pypoetry" and "virtualenvs" using .contains(). This could false-match on unusual directory names like C:\Users\pypoetry_user\virtualenvs_backup\something.

Details

The function combines substring matching with POETRY_ENV_NAME_PATTERN (regex on the final directory name), which adds precision. However, the path containment check is overly permissive.

Proposed Fix

Check actual path components rather than substring matching — e.g., verify that "pypoetry" and "virtualenvs" appear as separate path segments.

Impact

Low in practice, since the regex pattern on the directory name provides additional filtering. But it's a defense-in-depth improvement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions