Compare commits

..
3 Commits
Author SHA1 Message Date
Matte23 e0338e6438 Merge pull request 'Fix/review findings' (#1) from fix/review-findings into main
Reviewed-on: #1
2026-11-18 20:51:39 +00:00
Matte23andClaude Opus 5.5 a42e7f2823 fix: Silence CTFd's Flags polymorphic-identity warning on flag creation
CTFd's Flags model sets polymorphic_on without mapping any type, so every
flag flush warns. Mapping "personal" would break loading the other types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 18:38:48 +01:00
Matte23andClaude Opus 5.5 396c7afb9f refactor: Drop a redundant sentence from the cheaters page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 18:31:21 +01:00
2 changed files with 14 additions and 3 deletions

No files matched your search

+13 -1
View File
@@ -1,3 +1,5 @@
import warnings
from CTFd.models import Flags, Users, db from CTFd.models import Flags, Users, db
from CTFd.plugins import ( from CTFd.plugins import (
register_admin_plugin_menu_bar, register_admin_plugin_menu_bar,
@@ -8,6 +10,7 @@ from CTFd.plugins.migrations import upgrade
from CTFd.utils.config import is_teams_mode from CTFd.utils.config import is_teams_mode
from CTFd.utils.decorators import admins_only from CTFd.utils.decorators import admins_only
from flask import Blueprint, redirect, render_template, request, url_for from flask import Blueprint, redirect, render_template, request, url_for
from sqlalchemy.exc import SAWarning
from sqlalchemy.orm import joinedload from sqlalchemy.orm import joinedload
from .flags import PersonalFlag from .flags import PersonalFlag
@@ -41,7 +44,16 @@ def create_flag_if_missing(challenge_id: int, user_id: int, flag_content: str) -
data=data, data=data,
) )
db.session.add(flag) db.session.add(flag)
db.session.commit() # CTFd's Flags model sets polymorphic_on without mapping any type, so
# SQLAlchemy warns on every flag flush (static flags too). Mapping
# "personal" would break loading the other types: ignore it here.
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
message="Flushing object .* with incompatible polymorphic identity",
category=SAWarning,
)
db.session.commit()
return flag.id return flag.id
+1 -2
View File
@@ -5,8 +5,7 @@
<div class="container"> <div class="container">
<h1>Cheat Monitor</h1> <h1>Cheat Monitor</h1>
<p class="text-muted mb-0"> <p class="text-muted mb-0">
Personal flags submitted by an account they don't belong to. The Personal flags submitted by an account they don't belong to.
submission still counts: review the reports and act on the scoreboard.
</p> </p>
</div> </div>
</div> </div>