feat: Store flag id instead of flag content
This commit is contained in:
@@ -15,7 +15,7 @@ directory_name = PLUGIN_PATH.split(os.sep)[-1] # Get the directory name of this
|
|||||||
bp = Blueprint(directory_name, __name__, template_folder="templates")
|
bp = Blueprint(directory_name, __name__, template_folder="templates")
|
||||||
|
|
||||||
|
|
||||||
def add_cheater(challenge_id: int, cheater_id: int, helper_id: int, flag: str):
|
def report_cheater(challenge_id: int, cheater_id: int, helper_id: int, flag_id: int):
|
||||||
cheater = CheaterTeams(challenge_id, cheater_id, helper_id, flag)
|
cheater = CheaterTeams(challenge_id, cheater_id, helper_id, flag)
|
||||||
db.session.add(cheater)
|
db.session.add(cheater)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|||||||
11
models.py
11
models.py
@@ -8,8 +8,8 @@ class CheaterTeams(db.Model):
|
|||||||
)
|
)
|
||||||
cheater_id = db.Column(db.Integer, db.ForeignKey("users.id", ondelete="CASCADE"))
|
cheater_id = db.Column(db.Integer, db.ForeignKey("users.id", ondelete="CASCADE"))
|
||||||
helper_id = db.Column(db.Integer, db.ForeignKey("users.id", ondelete="CASCADE"))
|
helper_id = db.Column(db.Integer, db.ForeignKey("users.id", ondelete="CASCADE"))
|
||||||
|
flag_id = db.Column(db.Integer, db.ForeignKey("flags.id", ondelete="CASCADE"))
|
||||||
|
|
||||||
flag = db.Column(db.String(128), nullable=False)
|
|
||||||
date = db.Column(db.DateTime, default=db.func.current_timestamp())
|
date = db.Column(db.DateTime, default=db.func.current_timestamp())
|
||||||
|
|
||||||
# Relationships
|
# Relationships
|
||||||
@@ -19,6 +19,7 @@ class CheaterTeams(db.Model):
|
|||||||
helper = db.relationship(
|
helper = db.relationship(
|
||||||
"Users", foreign_keys="CheaterTeams.helper_id", lazy="select"
|
"Users", foreign_keys="CheaterTeams.helper_id", lazy="select"
|
||||||
)
|
)
|
||||||
|
flag = db.relationship("Flags", foreign_keys="CheaterTeams.flag_id", lazy="select")
|
||||||
|
|
||||||
challenge = db.relationship(
|
challenge = db.relationship(
|
||||||
"Challenges",
|
"Challenges",
|
||||||
@@ -26,17 +27,19 @@ class CheaterTeams(db.Model):
|
|||||||
lazy="select",
|
lazy="select",
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, challenge_id: int, cheater_id: int, helper_id: int, flag: str):
|
def __init__(
|
||||||
|
self, challenge_id: int, cheater_id: int, helper_id: int, flag_id: str
|
||||||
|
):
|
||||||
self.challenge_id = challenge_id
|
self.challenge_id = challenge_id
|
||||||
self.cheater_id = cheater_id
|
self.cheater_id = cheater_id
|
||||||
self.helper_id = helper_id
|
self.helper_id = helper_id
|
||||||
self.flag = flag
|
self.flag_id = flag_id
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<CheaterTeams User {0} maybe cheated for challenge {1} with the flag {2} belonging to the User {3} at {4} >".format(
|
return "<CheaterTeams User {0} maybe cheated for challenge {1} with the flag {2} belonging to the User {3} at {4} >".format(
|
||||||
self.cheater_id,
|
self.cheater_id,
|
||||||
self.challenge_id,
|
self.challenge_id,
|
||||||
self.flag,
|
self.flag.content,
|
||||||
self.helper_id,
|
self.helper_id,
|
||||||
self.date,
|
self.date,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"include": ["."],
|
"include": ["."],
|
||||||
"extraPaths": ["/home/matteo/Gitted/CTFd"],
|
"extraPaths": ["/home/matteo/Gitted/CTFd"],
|
||||||
"reportMissingImports": true
|
"reportMissingImports": true,
|
||||||
|
"reportUnknownVariableType": false,
|
||||||
|
"reportUnknownMemberType": false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user