mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Server] Apply card art rules to playmats (#7532)
* [Server] Apply card art rules to playmats Card art DENY rules were only enforced for user card art (SetCardArtParams) while playmats using the same art bypassed them. Move the rule lookup to Servatrice_DatabaseInterface::isCardArtAllowed with a default-allow base on Server_DatabaseInterface, delegate the session check to it, reject DENY-listed Command_SetPlaymat with RespFunctionNotAllowed, and strip DENY-listed deck playmats on DeckSelect so banned art is never broadcast. * [Server] Address review nits on playmat card art rules --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
bbe438b09a
commit
b11b096828
6 changed files with 55 additions and 22 deletions
|
|
@ -3481,26 +3481,6 @@ Response::ResponseCode AbstractServerSocketInterface::cmdAccountImage(const Comm
|
|||
return Response::RespOk;
|
||||
}
|
||||
|
||||
bool AbstractServerSocketInterface::isCardNameAllowed(const QString &cardName, const QString &cardProviderId)
|
||||
{
|
||||
QSqlQuery *q = sqlInterface->prepareQuery(
|
||||
"SELECT mode FROM {prefix}_card_art_name_rules WHERE card_name = :name AND card_provider_id = :provider");
|
||||
|
||||
q->bindValue(":name", cardName);
|
||||
q->bindValue(":provider", cardProviderId);
|
||||
|
||||
if (!sqlInterface->execSqlQuery(q)) {
|
||||
qWarning() << "Card art rule lookup failed; failing open for" << cardName;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!q->next()) {
|
||||
return true; // default allow
|
||||
}
|
||||
|
||||
return q->value(0).toString() != "DENY";
|
||||
}
|
||||
|
||||
Response::ResponseCode AbstractServerSocketInterface::cmdSetCardArtParams(const Command_SetCardArtParams &cmd,
|
||||
ResponseContainer & /* rc */)
|
||||
{
|
||||
|
|
@ -3527,7 +3507,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdSetCardArtParams(const
|
|||
return Response::RespOk;
|
||||
}
|
||||
|
||||
if (!isCardNameAllowed(cardName, cardProviderId)) {
|
||||
if (!sqlInterface->isCardArtAllowed(cardName, cardProviderId)) {
|
||||
return Response::RespFunctionNotAllowed;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue