Skip to content

Add cache configuration#11

Open
ramirobarraco wants to merge 1 commit intomainfrom
test-cache-config
Open

Add cache configuration#11
ramirobarraco wants to merge 1 commit intomainfrom
test-cache-config

Conversation

@ramirobarraco
Copy link
Copy Markdown
Collaborator

Test PR to verify enhanced review output format

Comment thread src/config.py
# 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")
Copy link
Copy Markdown

@github-actions github-actions Bot Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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')

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

🤓 Nitpick Senior Review

This PR introduces a caching mechanism by adding a cache_path to the configuration, derived from environment variables INPUT_CACHE_DIR and INPUT_CACHE_NAME.

Confidence: 2/5

⚠️ Changes needed - significant issues

Files Changed

File Type Overview
src/config.py Enhancement Adds cache_path to the configuration, derived from environment variables for cache directory and name.

✅ No issues found in the code changes.


🤓 Um, actually... reviewed by Nitpick Senior

@ramirobarraco
Copy link
Copy Markdown
Collaborator Author

/rerun

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