desloppify icon indicating copy to clipboard operation
desloppify copied to clipboard

Relative scan roots produce relative Bandit exclusions and include excluded worktrees

Open afiler-sp opened this issue 1 month ago • 0 comments

With desloppify 1.0 / upstream 3a7735d, collect_exclude_dirs(Path("."), extra_exclusions=(".claude",)) returns .claude rather than an absolute directory, despite its documented contract. The Python security adapter supplies an absolute scan target to Bandit.

Bandit expands an existing excluded directory into a glob such as .claude/*; that does not match absolute discovered filenames. On a repository with nested worktrees, scan --path . consequently imported tens of thousands of security findings from the explicitly excluded worktrees. Running Bandit directly with absolute exclusions produced zero findings from those directories.

Minimal regression: chdir to a temporary directory, call collect_exclude_dirs(Path("."), extra_exclusions=(".claude",)), and assert the result contains str(tmp_path / ".claude") and all returned paths are absolute. Repeat with Path("project"). Both fail before the fix and pass after it.

The local fix is one line in base/discovery/source.py: use scan_root.resolve() / p rather than scan_root / p. Two new relative-root regression cases and the existing absolute-path/glob-filtering tests pass. This also benefits external duplication tools using the same helper.

One recovery concern: security detector cache fingerprints do not include exclusion configuration; previously contaminated cached results can survive an exclusion-path repair unless the security cache is invalidated before rescanning. No source findings or review assessments need to be manually changed.

afiler-sp avatar Oct 30 '26 19:10 afiler-sp