Potential fix for code scanning alert no. 27: Uncontrolled data used in path expression#24
Merged
Merged
Conversation
…in path expression Co-authored-by: Arsh Verma <arshverma.dev@gmail.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
ArshVermaGit
commented
May 21, 2026
Owner
Author
ArshVermaGit
left a comment
There was a problem hiding this comment.
This is a reasonable security hardening change, especially if the goal is to avoid unintentionally broad trust boundaries. Removing the implicit os.getcwd() fallback and requiring SENTINELOPS_REPO_ROOT to be explicitly configured as a valid absolute directory makes the allowed-root model much more predictable and fail-closed by default. The main tradeoff is the stricter operational requirement, since deployments that previously relied on the fallback will now need configuration updates, but from a security standpoint that feels justified. As long as the configuration expectation is clearly documented and startup/logging makes misconfiguration obvious, this looks like a solid improvement.
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.
Potential fix for https://github.com/ArshVermaGit/SentinelOps-Autonomous-DevOps-AI/security/code-scanning/27
Best fix: keep the existing normalization + containment logic, but make it fail closed unless
SENTINELOPS_REPO_ROOTis explicitly configured to a valid absolute existing directory. This prevents uncontrolled probing against an implicit, potentially broad root (os.getcwd()).Concretely in
sentinelops-backend/app/services/local_git_service.py:ALLOWED_REPO_ROOTinitialization so it does not default toos.getcwd()._is_within_allowed_root, keep current checks; they will now correctly reject when env is unset.No new methods or third-party libraries are required; only a constant initialization change in the shown file.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.