Repository navigation
fix(engine): resolve the project root before naming its files - #212
Merged
Merged
Conversation
Module sources are loaded by their resolved path, while dependency files, configuration files, advisory files and the policy file were named from the root as given. With a relative root, their findings were reported relative to the working directory and their baseline fingerprints changed with it. Refs #206
The --advisories and --policy paths reached the source manager as given, so their syntax-error notes were still located relative to the working directory. Cover them and a root reached through a symbolic link. Refs #206
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #206.
With
--checkgiven a relative directory, findings located in dependency files (uv.lock,poetry.lock,pyproject.toml,requirements*.txt) and configuration files (config-secrets) were reported relative to the working directory instead of the analysed root, unlike module findings. Their baseline fingerprints carried the same prefix, so a baseline recorded with--check projdid not match a check of the same project by absolute path.Change
engine.analyze_projectresolvesroot, and the explicit--advisoriesand--policypaths, once, before any file is named. Module sources were already loaded by their resolved path (SourceManager.load_file); manifests, configuration files, the default and explicit advisory files and the policy file now follow the same convention, soReport.locateand the baseline place them under the root. A root reached through a symbolic link is covered by the same resolution.config_literals, so everySourceIdkeeps a single naming convention.Validation
tests/test_relative_root.py(no existing test changed): dependency and configuration findings are located atuv.lockandsettings.jsonfor a relative and an absolute root, and through a symbolic link;syntax-errornotes of explicit--policyand--advisoriesfiles are located relative to the root; a baseline recorded with a relative root matches an absolute check. The relative cases failed before the fix for the expected reason (the explicit-file cases were added after review and failed on the first version of this branch).test_packaging::test_the_version_has_one_source_of_truth, comes from a stale local editable install (metadata 0.8.0 vs 0.21.0) and fails identically without this change.ruff checkandmypypass.ruff format --checkreports pre-existing formatting ofengine.py, not the added lines.be75825, enterprise plugins atac35460,[email protected], no baseline: the same 87 results as the 2026-10-02 reference (rule, line, severity, confidence, message); only the 36 paths prefixed withtests-project/mitmproxy/are now root-relative. Plugin digests and SBOM are identical; the VEX differs only by its timestamp.Release note
Baselines recorded with a relative root hold entries such as
proj/uv.lock; after this change those findings are located atuv.lock, so they resurface once and the baseline should be re-recorded. A cache built with a relative root misses once for the same reason. Plugins that name files fromProjectContext.root(config-secrets, Enterpriseserverless-declarations) now receive the resolved root.Not covered
syntax-errormessages still embed the absolute path of the file in their text. That is message content, not a location, and is left out of this change.