Skip to content

添加web、docker部署方式 - #171

Open
breeze303 wants to merge 1 commit into
guofei9987:masterfrom
breeze303:master
Open

添加web、docker部署方式#171
breeze303 wants to merge 1 commit into
guofei9987:masterfrom
breeze303:master

Conversation

@breeze303

Copy link
Copy Markdown
image

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web_app.py
Comment on lines +20 to +24
password = request.form.get('password', '123456')
wm_type = request.form.get('wm_type', 'text')

password_int = abs(hash(password)) % (2**32)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Derive passwords with deterministic hashing

The password passed to WaterMark is derived with abs(hash(password)). Python’s built‑in hash() is salted per interpreter run, so the same string produces different integers after every process restart. Any image watermarked before a server redeploy will become undecodable even if the user supplies the same password, because the password integers used by embed and extract will no longer match. A stable hash (e.g. hashlib.sha256) should be used instead. The same issue appears in the extraction path.

Useful? React with 👍 / 👎.

Comment thread web_app.py
Comment on lines +25 to +27
# Save the cover image
filename = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
file.save(filename)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Sanitize uploaded filenames before saving

Uploaded files are saved using os.path.join(app.config['UPLOAD_FOLDER'], file.filename) without normalizing the client‑supplied name. A malicious filename such as ../../web_app.py would cause the save path to escape the uploads directory and overwrite arbitrary files on the server. Use werkzeug.utils.secure_filename (and apply it to the watermark and extracted file paths as well) to avoid directory traversal and shell metacharacters.

Useful? React with 👍 / 👎.

Comment thread web_app.py
Comment on lines +118 to +120
if __name__ == '__main__':
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
app.run(debug=True, host='0.0.0.0', port=5891)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Disable Flask debug mode for exposed server

The application is run with debug=True while listening on 0.0.0.0. In the Dockerfile and compose file this code is used as the production entrypoint, meaning the Werkzeug debugger (which allows arbitrary code execution when accessed with the PIN) is exposed to anyone who can reach the container. The development server should not be used in this deployment path; run with debug=False or behind a WSGI server instead.

Useful? React with 👍 / 👎.

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