Skip to content

example(q03-q04-q06): 新增範例 - #68

Merged
xinshoutw merged 6 commits into
Hack-the-SDGs:devfrom
huangtank:feature/examples-q03-q04-q06
Aug 2, 2026
Merged

xinshoutw merged 6 commits into
Hack-the-SDGs:devfrom
huangtank:feature/examples-q03-q04-q06

Conversation

@huangtank

Copy link
Copy Markdown
Contributor

No description provided.

Comment on lines +10 to +11
if "請幫我找零" not in msg_str:
return

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 security 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-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown

Greptile Summary

Adds runnable examples for the dance and restaurant quests, plus setup notes and an item-giving command for the library quest.

  • Adds two dance implementations covering immediate movement and queued movement sequences.
  • Adds two restaurant implementations that calculate and dispense change using greedy and dynamic-programming approaches.
  • Documents the library quest’s book locations, hints, and command-block setup.

Confidence Score: 4/5

The 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

Important Files Changed

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

Comment thread examples/quests/q06_restaurant/state_2/main.py Outdated
Comment thread examples/quests/q06_restaurant/state_2/main.py Outdated
Comment thread examples/quests/q06_restaurant/state_2/main.py Outdated
q03_dance 第一、二關優化
q04_library 新增指令,給予書本
q06_restaurant 錯字修正
@xinshoutw
xinshoutw merged commit 5fef82b into Hack-the-SDGs:dev Aug 2, 2026
4 checks passed
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.

2 participants