-
Notifications
You must be signed in to change notification settings - Fork 24
add:TrCDK #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
add:TrCDK #992
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @THEXN - 我已经审查了你的更改,发现了一些需要解决的问题。
阻塞问题:
- 直接将用户输入插入到 SQL 查询中会引入 SQL 注入风险。(link)
Prompt for AI Agents
请解决此代码审查中的评论:
## 个人评论
### 评论 1
<location> `src/TrCDK/Data.cs:30` </location>
<code_context>
+ DB.Open();
+ Command("create table if not exists Data(CDKname text,Usetime int(32),Utiltime int(64),Grouplimit text,Playerlimit text,Used text, Cmds text)");
+ }
+ public static SqliteDataReader Command(string cmd)
+ {
+ return new SqliteCommand(cmd, DB).ExecuteReader();
</code_context>
<issue_to_address>
直接将用户输入插入到 SQL 查询中会引入 SQL 注入风险。
通过直接插入参数来构建 SQL 查询是不安全的。切换到参数化查询以防止 SQL 注入。
</issue_to_address>
### 评论 2
<location> `src/TrCDK/Data.cs:24` </location>
<code_context>
+{
+ public static SqliteConnection? DB;
+ const string path = "tshock/TrCDK.sqlite";
+ public static void Init()
+ {
+ DB = new SqliteConnection($"Data Source={path};");
</code_context>
<issue_to_address>
数据库连接已打开但从未关闭,这可能会导致资源泄漏。
确保数据库连接已正确关闭,以防止资源耗尽或锁定,尤其是在多次调用 Init() 或在应用程序重新加载期间。
</issue_to_address>Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Original comment in English
Hey @THEXN - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- Directly interpolating user input into SQL queries introduces SQL injection risk. (link)
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/TrCDK/Data.cs:30` </location>
<code_context>
+ DB.Open();
+ Command("create table if not exists Data(CDKname text,Usetime int(32),Utiltime int(64),Grouplimit text,Playerlimit text,Used text, Cmds text)");
+ }
+ public static SqliteDataReader Command(string cmd)
+ {
+ return new SqliteCommand(cmd, DB).ExecuteReader();
</code_context>
<issue_to_address>
Directly interpolating user input into SQL queries introduces SQL injection risk.
Building SQL queries by inserting parameters directly is unsafe. Switch to parameterized queries to prevent SQL injection.
</issue_to_address>
### Comment 2
<location> `src/TrCDK/Data.cs:24` </location>
<code_context>
+{
+ public static SqliteConnection? DB;
+ const string path = "tshock/TrCDK.sqlite";
+ public static void Init()
+ {
+ DB = new SqliteConnection($"Data Source={path};");
</code_context>
<issue_to_address>
Database connection is opened and never closed, which may cause resource leaks.
Ensure the database connection is properly closed to prevent resource exhaustion or locking, particularly if Init() is called multiple times or during application reloads.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces the new TrCDK plugin for managing and redeeming CDKs and makes enhancements to the EssentialsPlus teleport permission handling.
- Adds a CDK redemption system with commands and SQLite database support.
- Introduces helper extension methods and updates the corresponding documentation.
- Upgrades EssentialsPlus version and adjusts TpAllowManager toggle logic.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/TrCDK/manifest.json | Adds manifest definitions for internationalized README descriptions. |
| src/TrCDK/TypeExtensions.cs | Provides helper methods for dynamic invocation with private members. |
| src/TrCDK/TShockCommandExtensions.cs | Adds a method to run commands without permission checks. |
| src/TrCDK/TSPlayerExtensions.cs | Introduces extension methods for TSPlayer, including permissionless invoke. |
| src/TrCDK/README.md & README.en-US.md | Documents the CDK commands and configuration details. |
| src/TrCDK/Main.cs | Registers CDK commands and contains the main plugin logic. |
| src/TrCDK/Data.cs | Implements SQLite operations for storing CDK information. |
| src/EssentialsPlus/README.md | Updates the changelog to document teleport permission changes. |
| src/EssentialsPlus/EssentialsPlus.cs | Bumps the plugin version to 1.1.0. |
| src/EssentialsPlus/Db/TpAllowManager.cs | Adjusts teleport permission toggle behavior. |
| Plugin.sln | Adds the new TrCDK project to the solution. |
Comments suppressed due to low confidence (2)
src/TrCDK/TShockCommandExtensions.cs:18
- The error message text appears garbled, possibly due to an encoding issue. Verify that the source file encoding is set to UTF-8 and that the correct text is used.
ply.SendErrorMessage(GetString("ָ��ִ��ʧ�ܣ�����ϵ����Ա"));
src/TrCDK/TSPlayerExtensions.cs:40
- The displayed error message appears corrupted, indicating a potential encoding issue. Ensure that error message strings are correctly encoded in UTF-8.
player.SendErrorMessage(GetString("�����������Ч.����/help��ȡ��Ч�����б�."));
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@THEXN 需要重新测试一下功能
为了解决waring找ai了() |
|
TODO:
|
添加插件
更新插件/修复BUG
其他
Sourcery 总结
新增一个用于 CDK 管理和兑换的 TrCDK 插件,并通过在没有数据库记录或发生异常时默认允许来增强 EssentialsPlus 的传送权限处理。
新特性:
增强功能:
构建:
文档:
Original summary in English
Summary by Sourcery
Add a new TrCDK plugin for CDK management and redemption and enhance EssentialsPlus teleport permission handling by defaulting to allow when no database record or on exceptions
New Features:
Enhancements:
Build:
Documentation: