example(q03-q04-q06): 新增範例 - #68
Conversation
| if "請幫我找零" not in msg_str: | ||
| return |
There was a problem hiding this comment.
Unrestricted messages trigger inventory drops
When a player sends a chat message containing 請幫我找零 and an integer, this catch-all messagestr handler ignores the supplied position and sender metadata and uses the value to drop inventory; state 2 also allocates one DP entry per requested unit, so a large value can exhaust memory or stall processing. How this was verified: The message-controlled integer flows without source validation into both the DP allocation and bot.drop calls.
Knowledge Base Used: Example Quests and the Unit Test Suite
Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/quests/q06_restaurant/state_2/main.py
Line: 10-11
Comment:
**Unrestricted messages trigger inventory drops**
When a player sends a chat message containing `請幫我找零` and an integer, this catch-all `messagestr` handler ignores the supplied position and sender metadata and uses the value to drop inventory; state 2 also allocates one DP entry per requested unit, so a large value can exhaust memory or stall processing. **How this was verified:** The message-controlled integer flows without source validation into both the DP allocation and `bot.drop` calls.
**Knowledge Base Used:** [Example Quests and the Unit Test Suite](https://app.greptile.com/xinshoutw/-/custom-context/knowledge-base/hack-the-sdgs/minethon/-/docs/testing-quests.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Greptile SummaryAdds runnable examples for the dance and restaurant quests, plus setup notes and an item-giving command for the library quest.
Confidence Score: 4/5The PR is not yet safe to merge because unrestricted matching messages can still consume substantial resources and cause the restaurant bot to drop inventory. The state-2 handler still ignores available message metadata, uses the parsed message amount to size and execute an unbounded dynamic-programming calculation, and then passes the resulting counts to live inventory-drop operations. Files Needing Attention: examples/quests/q06_restaurant/state_2/main.py
|
| Filename | Overview |
|---|---|
| examples/quests/q03_dance/state_1/main.py | Adds a direct movement response loop driven by four lit-block states. |
| examples/quests/q03_dance/state_2/main.py | Adds a queued dance sequence that records lit-block inputs and replays them after the state marker changes. |
| examples/quests/q04_library/README.md | Documents seven book locations, their hints, and the command used to distribute the written book. |
| examples/quests/q06_restaurant/state_1/main.py | Adds a greedy change-calculation example with message deduplication and inventory drops. |
| examples/quests/q06_restaurant/state_2/main.py | Adds dynamic-programming change calculation and inventory dispensing; the previously reported unrestricted message path remains present. |
Reviews (4): Last reviewed commit: "fix: 修正 q03_dance 第二關 example" | Re-trigger Greptile
q03_dance 第一、二關優化 q04_library 新增指令,給予書本 q06_restaurant 錯字修正
No description provided.