添加web、docker部署方式 - #171
Conversation
breeze303
commented
Nov 1, 2025
There was a problem hiding this comment.
💡 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".
| password = request.form.get('password', '123456') | ||
| wm_type = request.form.get('wm_type', 'text') | ||
|
|
||
| password_int = abs(hash(password)) % (2**32) | ||
|
|
There was a problem hiding this comment.
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 👍 / 👎.
| # Save the cover image | ||
| filename = os.path.join(app.config['UPLOAD_FOLDER'], file.filename) | ||
| file.save(filename) |
There was a problem hiding this comment.
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 👍 / 👎.
| if __name__ == '__main__': | ||
| os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True) | ||
| app.run(debug=True, host='0.0.0.0', port=5891) |
There was a problem hiding this comment.
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 👍 / 👎.