Skip to content

fix: return absolute paths from collect_exclude_dirs - #904

Open
derEremit wants to merge 1 commit into
peteromallet:mainfrom
derEremit:fix/absolute-exclude-dirs
Open

derEremit wants to merge 1 commit into
peteromallet:mainfrom
derEremit:fix/absolute-exclude-dirs

Conversation

@derEremit

Copy link
Copy Markdown

Problem

collect_exclude_dirs documents that it returns absolute directories for external tools. When scan_root is relative (the common path of a relative file list), it returned paths like temp. Bandit then turns an existing directory into the glob temp/* and compares it to absolute filenames such as /repo/temp/file.py. That glob does not match, so desloppify exclude temp still let Bandit scan the directory and import those findings as production security issues.

Observed on desloppify 1.0: a project with exclude: ["temp"] still recorded 5517 Bandit findings under temp/ as zone production. File discovery itself honored the exclude (59 project files). Only the Bandit subprocess scanned the vendor tree.

Fix

Resolve scan_root and emit absolute directories. Already-absolute patterns are preserved. A unit test covers a relative scan root plus a runtime temp exclusion.

Verification

pytest desloppify/tests/detectors/test_external_adapters.py::TestCollectExcludeDirs — 7 passed.

Bandit walks an absolute scan target. When the scan root is relative,
exclude entries stayed relative (temp/*) and never matched /repo/temp/...,
so configured excludes were scanned and reported as production security
issues.
github-actions Bot added a commit to citizenadam/desloppify that referenced this pull request Oct 28, 2026

This branch has not been deployed

No deployments
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.

1 participant