Repository navigation
Conversation
rumblefrog
reviewed
Jun 1, 2026
rumblefrog
reviewed
Jun 1, 2026
There was a problem hiding this comment.
Pull request overview
This PR refactors the two SourceBans++ SourceMod plugins to standardize SQL query construction and error handling, primarily by replacing manual escaping + Format/FormatEx patterns with Database.Format/SQLiteDB.Format and adding consistent truncation guards.
Changes:
- Migrated query building to
DB.Format/db.Format/SQLiteDB.Formatwith consistent placeholder usage and truncation checks. - Standardized truncation diagnostics to
LogErrorand increased some query buffer sizes. - Adjusted
DataPackallocation timing in some paths to avoid unnecessary allocation when query formatting fails.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 35 comments.
| File | Description |
|---|---|
| game/addons/sourcemod/scripting/sbpp_main.sp | Reworked multiple ban/unban and queue queries to use DB.Format, added truncation guards, and adjusted some DataPack lifecycle decisions. |
| game/addons/sourcemod/scripting/sbpp_comms.sp | Reworked comms queries to use Database.Format, added truncation guards, and moved DataPack allocation in unblock paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1517
to
+1520
| { | ||
| LogError("SelectAddbanCallback insert query truncated"); | ||
| return; | ||
| } |
Contributor
Author
|
… DataPack lifecycle - replace Escape + Format patterns with DB.Format/SQLiteDB.Format in main and comms - enforce placeholder policy: %!s for internal SQL identifiers/fragments, %s for runtime/user input - add/keep query buffer truncation guards before query execution - standardize truncation diagnostics on LogError across both plugins
Added deletion of newDataPack on query truncation.
Removed unnecessary delete statements for dataPack. Added cleanup function for DataPack.
Rushaway
added a commit
to srcdslab/sourcebans-pp
that referenced
this pull request
Sep 3, 2026
…taPack lifecycle Port of upstream sbpp#1492, adapted to keep the fork's admin_name column/subquery in the bans and comms INSERT statements. - replace Escape + Format patterns with DB.Format/SQLiteDB.Format in main and comms - enforce placeholder policy: %!s for internal SQL identifiers/fragments, %s for runtime/user input - add query buffer truncation guards before query execution, standardized on LogError - allocate DataPack only after successful query formatting; add CleanupBanDataPack helper Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Rushaway <rushaway@hotmail.fr>
Rushaway
added a commit
to srcdslab/sourcebans-pp
that referenced
this pull request
Sep 3, 2026
…prebuilt SQL fragments Two defects found while reviewing the port of sbpp#1492. 1. Truncation guards were dead code. Database.Format / SQL_FormatQuery goes through InternalFormat -> atcprintf, which starts with llen = maxlen - 1 and returns (maxlen - llen - 1). The return value is therefore capped at maxlength - 1 and can never be >= sizeof(buffer), so every "if (db.Format(...) >= sizeof(buf))" check (and the inverted "< sizeof(buf)" variants in VerifyBan) could never trigger. All 34 guards in sbpp_main.sp and sbpp_comms.sp now compare against sizeof(buf) - 1 (and iQueryLen - 1 for the dynamically sized report query), which is the standard truncation test. 2. sbpp_comms.sp InsertTempBlock escaped its own SQL. The queue2 INSERT passed the prebuilt sQueryMute/sQueryGag value tuples through %s, so SQLiteDB.Format escaped the single quotes inside them and produced a syntactically invalid statement, silently dropping temp comm blocks queued while the main database was down. Switched to %!s%!s%!s to match the equivalent statement in SavePunishment. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Rushaway <rushaway@hotmail.fr>
Rushaway
added a commit
to srcdslab/sourcebans-pp
that referenced
this pull request
Sep 6, 2026
…taPack lifecycle Port of upstream sbpp#1492, adapted to keep the fork's admin_name column/subquery in the bans and comms INSERT statements. - replace Escape + Format patterns with DB.Format/SQLiteDB.Format in main and comms - enforce placeholder policy: %!s for internal SQL identifiers/fragments, %s for runtime/user input - add query buffer truncation guards before query execution, standardized on LogError - allocate DataPack only after successful query formatting; add CleanupBanDataPack helper Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Rushaway <rushaway@hotmail.fr>
Rushaway
added a commit
to srcdslab/sourcebans-pp
that referenced
this pull request
Sep 6, 2026
…prebuilt SQL fragments Two defects found while reviewing the port of sbpp#1492. 1. Truncation guards were dead code. Database.Format / SQL_FormatQuery goes through InternalFormat -> atcprintf, which starts with llen = maxlen - 1 and returns (maxlen - llen - 1). The return value is therefore capped at maxlength - 1 and can never be >= sizeof(buffer), so every "if (db.Format(...) >= sizeof(buf))" check (and the inverted "< sizeof(buf)" variants in VerifyBan) could never trigger. All 34 guards in sbpp_main.sp and sbpp_comms.sp now compare against sizeof(buf) - 1 (and iQueryLen - 1 for the dynamically sized report query), which is the standard truncation test. 2. sbpp_comms.sp InsertTempBlock escaped its own SQL. The queue2 INSERT passed the prebuilt sQueryMute/sQueryGag value tuples through %s, so SQLiteDB.Format escaped the single quotes inside them and produced a syntactically invalid statement, silently dropping temp comm blocks queued while the main database was down. Switched to %!s%!s%!s to match the equivalent statement in SavePunishment. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Rushaway <rushaway@hotmail.fr>
Rushaway
added a commit
to srcdslab/sourcebans-pp
that referenced
this pull request
Sep 6, 2026
* fix(game): harmonize SQL query formatting, truncation logging, and DataPack lifecycle Port of upstream sbpp#1492, adapted to keep the fork's admin_name column/subquery in the bans and comms INSERT statements. - replace Escape + Format patterns with DB.Format/SQLiteDB.Format in main and comms - enforce placeholder policy: %!s for internal SQL identifiers/fragments, %s for runtime/user input - add query buffer truncation guards before query execution, standardized on LogError - allocate DataPack only after successful query formatting; add CleanupBanDataPack helper * review fixes: make truncation guards actually fire and stop escaping prebuilt SQL fragments Two defects found while reviewing the port of sbpp#1492. 1. Truncation guards were dead code. Database.Format / SQL_FormatQuery goes through InternalFormat -> atcprintf, which starts with llen = maxlen - 1 and returns (maxlen - llen - 1). The return value is therefore capped at maxlength - 1 and can never be >= sizeof(buffer), so every "if (db.Format(...) >= sizeof(buf))" check (and the inverted "< sizeof(buf)" variants in VerifyBan) could never trigger. All 34 guards in sbpp_main.sp and sbpp_comms.sp now compare against sizeof(buf) - 1 (and iQueryLen - 1 for the dynamically sized report query), which is the standard truncation test. 2. sbpp_comms.sp InsertTempBlock escaped its own SQL. The queue2 INSERT passed the prebuilt sQueryMute/sQueryGag value tuples through %s, so SQLiteDB.Format escaped the single quotes inside them and produced a syntactically invalid statement, silently dropping temp comm blocks queued while the main database was down. Switched to %!s%!s%!s to match the equivalent statement in SavePunishment.
8 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR updates both SourceBans++ scripting plugins to apply a consistent SQL construction and error-handling pattern.
Updated files:
Key changes:
Motivation and Context
This change improves safety and consistency in SQL handling across plugins:
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
Note: If your PR touches
web/**and this is your firstcontribution to the web panel, the CLA bot will comment within
~30 seconds with one-line sign instructions. You only need to sign
once per repo. See
CLA.mdfor the full text andCONTRIBUTING.mdfor the rationale.