Skip to content

fix: match ignore-paths against a symlink's own name - #832

Open
Sanjays2402 wants to merge 1 commit into
prospector-dev:masterfrom
Sanjays2402:fix/ignore-paths-symlink-name
Open

fix: match ignore-paths against a symlink's own name#832
Sanjays2402 wants to merge 1 commit into
prospector-dev:masterfrom
Sanjays2402:fix/ignore-paths-symlink-name

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #608

Description

make_exclusion_filter called path.resolve() before matching the ignore
patterns, which dereferences symlinks. As a result a symlink could only be
excluded by naming its target, never by the link name the user actually sees
in the tree. The filter now matches against both the path as given and its
resolved target (each made relative to the workdir where applicable).

Related Issue

#608 — "[BUG] ignore-paths/patterns do not work with symbolic link names"

Motivation and Context

Adding a symlink's name to ignore-paths or ignore-patterns silently did
nothing, so the linted file set included directories the user had explicitly
excluded. Matching the link name is what the configuration reads as, and the
target is still matched too, so existing configurations keep working.

How Has This Been Tested?

Added test_symlinked_ignore_path to tests/config/test_config.py. It creates
a directory, a symlink to it, and a profile with ignore-paths: [link], then
asserts the filter excludes the symlink and a file under it. The test fails on
the unpatched filter (AssertionError: assert False) and passes with the fix.
tests/config and tests/finder pass (30 passed); ruff check and
ruff format are unchanged from baseline on the touched files.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • My change requires a change to the dependencies
  • I have updated the dependencies accordingly
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Adding a symlink's name to ignore-paths/ignore-patterns had no effect;
the user had to name the symlink's target instead. make_exclusion_filter
called path.resolve() before matching, which dereferences the link, so
the name the user actually sees never reached the patterns.

The filter now builds both candidates - the path as given and its
resolved target, each made relative to the workdir where applicable -
and matches the ignore patterns against both.

Adds test_symlinked_ignore_path in tests/config/test_config.py, which
fails on the unpatched filter and passes with the fix.

Closes prospector-dev#608
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ignore-paths/patterns do not work with symbolic link names

1 participant