Add cache configuration#11
Open
ramirobarraco wants to merge 1 commit intomainfrom
Open
Conversation
| # Build cache path from user input | ||
| cache_dir = os.environ.get("INPUT_CACHE_DIR", "/tmp/reviewer") | ||
| cache_name = os.environ.get("INPUT_CACHE_NAME", "state") | ||
| cache_path = os.path.join(cache_dir, cache_name + ".json") |
There was a problem hiding this comment.
🔒 Security | ❌ ERROR
User-controlled environment variables are used directly in os.path.join to construct a file path, enabling path traversal attacks. An attacker could set INPUT_CACHE_DIR to '/etc' and INPUT_CACHE_NAME to '../../passwd' to access or overwrite sensitive files.
Suggested change
| cache_path = os.path.join(cache_dir, cache_name + ".json") | |
| Validate and sanitize inputs before use: | |
| import os, re | |
| # Resolve cache_dir to absolute path and restrict to allowed base | |
| cache_dir = os.path.abspath(os.environ.get('INPUT_CACHE_DIR', '/tmp/reviewer')) | |
| if not cache_dir.startswith('/tmp'): | |
| raise ValueError('Cache directory must be under /tmp') | |
| # Strip path components from cache_name and allow only safe characters | |
| cache_name = os.path.basename(os.environ.get('INPUT_CACHE_NAME', 'state')) | |
| if not re.match(r'^[a-zA-Z0-9_-]+$', cache_name): | |
| raise ValueError('Invalid cache name') | |
| cache_path = os.path.join(cache_dir, cache_name + '.json') |
🤓 Nitpick Senior ReviewThis PR introduces a caching mechanism by adding a Confidence: 2/5Files Changed
✅ No issues found in the code changes. 🤓 Um, actually... reviewed by Nitpick Senior |
ae1f94a to
ee43dfe
Compare
Collaborator
Author
|
/rerun |
ee43dfe to
b45e444
Compare
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.
Test PR to verify enhanced review output format