Skip to content

Add divide function for Graphite review demo#2

Open
hjjj1 wants to merge 5 commits into
masterfrom
graphite-review-demo
Open

Add divide function for Graphite review demo#2
hjjj1 wants to merge 5 commits into
masterfrom
graphite-review-demo

Conversation

@hjjj1

@hjjj1 hjjj1 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

hjjj1 commented Jun 3, 2026

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@hjjj1
hjjj1 marked this pull request as ready for review June 3, 2026 04:16

@hjjj1 hjjj1 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

1

Comment thread calc.py
Comment on lines +188 to +191
def load_user_file(filename):
# 文件路径未校验,可能导致路径遍历攻击
with open(filename, "r") as f:
return f.read()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Critical security vulnerability: unrestricted file path allows directory traversal attacks (e.g., ../../etc/passwd).

Fix by validating the file path:

import os

def load_user_file(filename):
    # Validate filename to prevent path traversal
    if '..' in filename or filename.startswith('/'):
        raise ValueError("Invalid filename")
    safe_path = os.path.join('/safe/directory/', filename)
    with open(safe_path, 'r') as f:
        return f.read()
Suggested change
def load_user_file(filename):
# 文件路径未校验,可能导致路径遍历攻击
with open(filename, "r") as f:
return f.read()
import os
def load_user_file(filename):
# Validate filename to prevent path traversal
if ".." in filename or filename.startswith("/"):
raise ValueError("Invalid filename")
safe_path = os.path.join("/safe/directory/", filename)
with open(safe_path, "r") as f:
return f.read()

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

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