Instruction stringlengths 13 145k | input_code stringlengths 35 390k | output_code stringlengths 35 390k |
|---|---|---|
Files not Downloadable
**Environment**:
- CTFd Version/Commit: 2.3.3
- Operating System: Windows
- Web Browser and Version: Chrome 80.0.3987.132
**What happened?**
When building a challenge that has a file, the file is not downloadable.
**What did you expect to happen?**
A file should be downloadable... | CTFd/utils/uploads/uploaders.py
<|code_start|>import os
import string
from shutil import copyfileobj
import boto3
from flask import current_app, redirect, send_file
from flask.helpers import safe_join
from werkzeug.utils import secure_filename
from CTFd.utils import get_app_config
from CTFd.utils.encoding import hexe... | CTFd/utils/uploads/uploaders.py
<|code_start|>import os
import posixpath
import string
from shutil import copyfileobj
import boto3
from flask import current_app, redirect, send_file
from flask.helpers import safe_join
from werkzeug.utils import secure_filename
from CTFd.utils import get_app_config
from CTFd.utils.enc... |
Remove datafreeze depenency
Datafreeze is archived https://github.com/pudo/datafreeze/ and was already a difficult library. This needs to be removed going forward.
| CTFd/utils/exports/__init__.py
<|code_start|>import datetime
import json
import os
import re
import tempfile
import zipfile
import datafreeze
import dataset
import six
from alembic.util import CommandError
from datafreeze.format import SERIALIZERS
from datafreeze.format.fjson import JSONEncoder, JSONSerializer
from fl... | CTFd/utils/exports/__init__.py
<|code_start|>import datetime
import json
import os
import re
import tempfile
import zipfile
import dataset
import six
from alembic.util import CommandError
from flask import current_app as app
from flask_migrate import upgrade
from sqlalchemy.exc import OperationalError, ProgrammingErro... |
Submission search
Search submissions akin to how users are searched
| CTFd/admin/submissions.py
<|code_start|>from flask import render_template, request
from CTFd.admin import admin
from CTFd.models import Challenges, Submissions
from CTFd.utils.decorators import admins_only
from CTFd.utils.modes import get_model
@admin.route("/admin/submissions", defaults={"submission_type": None})
@... | CTFd/admin/submissions.py
<|code_start|>from flask import render_template, request, url_for
from CTFd.admin import admin
from CTFd.models import Challenges, Submissions
from CTFd.utils.decorators import admins_only
from CTFd.utils.modes import get_model
@admin.route("/admin/submissions", defaults={"submission_type":... |
More granular reset
People often request the ability to reset individual tables instead of the current reset approach
| CTFd/__init__.py
<|code_start|>import datetime
import os
import sys
import weakref
from distutils.version import StrictVersion
from flask import Flask, Request
from flask_migrate import upgrade
from jinja2 import FileSystemLoader
from jinja2.sandbox import SandboxedEnvironment
from six.moves import input
from werkzeug... | CTFd/__init__.py
<|code_start|>import datetime
import os
import sys
import weakref
from distutils.version import StrictVersion
from flask import Flask, Request
from flask_migrate import upgrade
from jinja2 import FileSystemLoader
from jinja2.sandbox import SandboxedEnvironment
from six.moves import input
from werkzeug... |
Make IP List be a Tab
I feel like the IP addresses shown at the bottom of the admin Users page should be in a tab like the rest of the data on that page. It feels out of place how it is displayed currently.
| CTFd/cache/__init__.py
<|code_start|>from flask import request
from flask_caching import Cache
cache = Cache()
def make_cache_key(path=None, key_prefix="view/%s"):
"""
This function mostly emulates Flask-Caching's `make_cache_key` function so we can delete cached api responses.
Over time this function ma... | CTFd/cache/__init__.py
<|code_start|>from flask import request
from flask_caching import Cache
cache = Cache()
def make_cache_key(path=None, key_prefix="view/%s"):
"""
This function mostly emulates Flask-Caching's `make_cache_key` function so we can delete cached api responses.
Over time this function ma... |
Handle plugin migrations in import_ctf
This code to create plugins is wrong. It should consider if the plugin has provided migrations now.
https://github.com/CTFd/CTFd/blob/master/CTFd/utils/exports/__init__.py#L171-L177
| CTFd/plugins/__init__.py
<|code_start|>import glob
import importlib
import os
from collections import namedtuple
from flask import current_app as app
from flask import send_file, send_from_directory
from CTFd.utils.config.pages import get_pages
from CTFd.utils.decorators import admins_only as admins_only_wrapper
from... | CTFd/plugins/__init__.py
<|code_start|>import glob
import importlib
import os
from collections import namedtuple
from flask import current_app as app
from flask import send_file, send_from_directory
from CTFd.utils.config.pages import get_pages
from CTFd.utils.decorators import admins_only as admins_only_wrapper
from... |
Prevent importing data that doesn't meet our expected format
People like to manipulate import data despite it being not a great idea. This often leads to problems where the user is trying to import data that doesn't match our expected format.
We should prevent that automatically.
| CTFd/utils/exports/__init__.py
<|code_start|>import datetime
import json
import os
import re
import tempfile
import zipfile
import dataset
import six
from alembic.util import CommandError
from flask import current_app as app
from flask_migrate import upgrade as migration_upgrade
from sqlalchemy.exc import OperationalE... | CTFd/utils/exports/__init__.py
<|code_start|>import datetime
import json
import os
import re
import tempfile
import zipfile
import dataset
import six
from alembic.util import CommandError
from flask import current_app as app
from flask_migrate import upgrade as migration_upgrade
from sqlalchemy.exc import OperationalE... |
API modifications to list all rows regardless of any filters
The API needs a way to list everything for admins. Admins are still subject to filtering mechanisms like hiding/requirements.
For example https://github.com/CTFd/CTFd/pull/1165 shows a solution that someone pulled up. I think a similar approach is possibl... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from flask import abort, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy.sql import and_
from CTFd.cache import clear_standings
from CTFd.models import ChallengeFiles as ChallengeFilesModel
from CTFd.models import Challenges, Fails, ... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from flask import abort, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy.sql import and_
from CTFd.cache import clear_standings
from CTFd.models import ChallengeFiles as ChallengeFilesModel
from CTFd.models import Challenges, Fails, ... |
Reduce usage of the user-side session object
The user side session is very difficult to modify. We should only store the user's ID in it.
1. Next major version, cut out all session data besides the user's ID
2. Make a function that takes user ID and returns the user's properties (name, email, role)
3. Cache that ... | CTFd/constants/sessions.py
<|code_start|><|code_end|>
CTFd/utils/initialization/__init__.py
<|code_start|>import datetime
import logging
import os
import sys
from flask import abort, redirect, render_template, request, session, url_for
from sqlalchemy.exc import IntegrityError, InvalidRequestError
from werkzeug.middle... | CTFd/constants/sessions.py
<|code_start|>from flask import session
class _SessionWrapper:
@property
def id(self):
return session.get("id", 0)
@property
def nonce(self):
return session.get("nonce")
@property
def hash(self):
return session.get("hash")
Session = _Sessi... |
Pagination objects for User interface
Flask sqlalchemy pagination objects should be used for the user interface instead of the custom pagination.
| CTFd/teams.py
<|code_start|>from flask import Blueprint, redirect, render_template, request, url_for
from CTFd.cache import clear_team_session, clear_user_session
from CTFd.models import Teams, db
from CTFd.utils import config, get_config
from CTFd.utils.crypto import verify_password
from CTFd.utils.decorators import ... | CTFd/teams.py
<|code_start|>from flask import Blueprint, redirect, render_template, request, url_for
from CTFd.cache import clear_team_session, clear_user_session
from CTFd.models import Teams, db
from CTFd.utils import config, get_config
from CTFd.utils.crypto import verify_password
from CTFd.utils.decorators import ... |
get_standings should return more flexible data
get_standings is a little inflexible because the data is constrained.
| CTFd/utils/scores/__init__.py
<|code_start|>from sqlalchemy.sql.expression import union_all
from CTFd.cache import cache
from CTFd.models import Awards, Challenges, Solves, Teams, Users, db
from CTFd.utils import get_config
from CTFd.utils.dates import unix_time_to_utc
from CTFd.utils.modes import get_model
@cache.m... | CTFd/utils/scores/__init__.py
<|code_start|>from sqlalchemy.sql.expression import union_all
from CTFd.cache import cache
from CTFd.models import Awards, Challenges, Solves, Teams, Users, db
from CTFd.utils import get_config
from CTFd.utils.dates import unix_time_to_utc
from CTFd.utils.modes import get_model
@cache.m... |
Theme settings
There needs to be some way to change settings in themes themselves. People complain about a lot of nonsensical things that they should fix in their forks and not need to be a concern in master.
| CTFd/constants/config.py
<|code_start|>from CTFd.utils import get_config
from CTFd.utils.helpers import markup
class _ConfigsWrapper:
def __getattr__(self, attr):
return get_config(attr)
@property
def ctf_name(self):
return get_config("theme_header", default="CTFd")
@property
def... | CTFd/constants/config.py
<|code_start|>import json
from CTFd.utils import get_config
from CTFd.utils.helpers import markup
class _ConfigsWrapper:
def __getattr__(self, attr):
return get_config(attr)
@property
def ctf_name(self):
return get_config("theme_header", default="CTFd")
@pro... |
Flags are unable to specify why they failed
In the challenge plugin structure a given flag is unable to relay to the user why a given flag failed.
A potential solution here is to raise an exception and then catch that from the challenge side and then echo out the string.
| CTFd/plugins/challenges/__init__.py
<|code_start|>from flask import Blueprint
from CTFd.models import (
ChallengeFiles,
Challenges,
Fails,
Flags,
Hints,
Solves,
Tags,
db,
)
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.flags import get_flag_class
from CTFd.... | CTFd/plugins/challenges/__init__.py
<|code_start|>from flask import Blueprint
from CTFd.models import (
ChallengeFiles,
Challenges,
Fails,
Flags,
Hints,
Solves,
Tags,
db,
)
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.flags import FlagException, get_flag_c... |
override_template throwing a 500 error
**Environment**:
- CTFd Version/Commit: 2.5.0
- Operating System: Mac OS Mojave
- Web Browser and Version: Google Chrome Version 83.0.4103.106
**What happened?**
Bug/issue using the "override_template" function, inside the __init.py__ file for a plugin, from CTFD.pl... | CTFd/__init__.py
<|code_start|>import datetime
import os
import sys
import weakref
from distutils.version import StrictVersion
from flask import Flask, Request
from flask_migrate import upgrade
from jinja2 import FileSystemLoader
from jinja2.sandbox import SandboxedEnvironment
from six.moves import input
from werkzeug... | CTFd/__init__.py
<|code_start|>import datetime
import os
import sys
import weakref
from distutils.version import StrictVersion
from flask import Flask, Request
from flask_migrate import upgrade
from jinja2 import FileSystemLoader
from jinja2.sandbox import SandboxedEnvironment
from six.moves import input
from werkzeug... |
Show current attempts in challenge view
Showing how many attempts the user has tried on a given challenge. Helps with max attempts as well.
| CTFd/api/v1/challenges.py
<|code_start|>import datetime
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy.sql import and_
from CTFd.cache import clear_standings
from CTFd.models import ChallengeFiles as ChallengeFilesModel
from CTFd.models import Ch... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy.sql import and_
from CTFd.cache import clear_standings
from CTFd.models import ChallengeFiles as ChallengeFilesModel
from CTFd.models import (
... |
Access media library from Challenge UI
Accessing the media library from the challenge UI is a useful idea if you're using images in the challenge interface. Saves some clicks.
| CTFd/admin/pages.py
<|code_start|>from flask import render_template, request
from CTFd.admin import admin
from CTFd.models import Pages
from CTFd.schemas.pages import PageSchema
from CTFd.utils import markdown
from CTFd.utils.config.pages import build_html
from CTFd.utils.decorators import admins_only
@admin.route("... | CTFd/admin/pages.py
<|code_start|>from flask import render_template, request
from CTFd.admin import admin
from CTFd.models import Pages
from CTFd.schemas.pages import PageSchema
from CTFd.utils import markdown
from CTFd.utils.config.pages import build_html
from CTFd.utils.decorators import admins_only
@admin.route("... |
Standardize theme interface
Themes should have a static set of requirements that all themes should have. This really just means we need to provide more guidance on designing themes.
| CTFd/constants/teams.py
<|code_start|>from collections import namedtuple
TeamAttrs = namedtuple(
"TeamAttrs",
[
"id",
"oauth_id",
"name",
"email",
"secret",
"website",
"affiliation",
"country",
"bracket",
"hidden",
"banned"... | CTFd/constants/teams.py
<|code_start|>from collections import namedtuple
TeamAttrs = namedtuple(
"TeamAttrs",
[
"id",
"oauth_id",
"name",
"email",
"secret",
"website",
"affiliation",
"country",
"bracket",
"hidden",
"banned"... |
Add support for GeoIP to determine country
Public CTFs attract users from across the world. It's really cool to see where people are playing from, so we have the ability for teams to declare their country. But with all of the countries in the world, scrolling through a list when you just want to register and play is no... | CTFd/utils/countries/geoip.py
<|code_start|><|code_end|>
CTFd/utils/initialization/__init__.py
<|code_start|>import datetime
import logging
import os
import sys
from flask import abort, redirect, render_template, request, session, url_for
from sqlalchemy.exc import IntegrityError, InvalidRequestError
from werkzeug.mid... | CTFd/utils/countries/geoip.py
<|code_start|>import geoacumen
import maxminddb
from flask import current_app
IP_ADDR_LOOKUP = maxminddb.open_database(
current_app.config.get("GEOIP_DATABASE_PATH", geoacumen.db_path)
)
def lookup_ip_address(addr):
response = IP_ADDR_LOOKUP.get(addr)
try:
return res... |
Change Configs detail API GET/PATCH for a more structured response
The API endpoints for GET, PATCH /api/v1/configs/{config_key} return badly structured data. This should return better structured data.
| CTFd/api/v1/config.py
<|code_start|>from typing import List
from flask import request
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.models import build_model_filters
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.ap... | CTFd/api/v1/config.py
<|code_start|>from typing import List
from flask import request
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.models import build_model_filters
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.ap... |
SQL "Lost connection to MySQL server during query"
<!--
If this is a bug report please fill out the template below.
If this is a feature request please describe the behavior that you'd like to see.
-->
I have encountered the same bug as in #1395 and #467, which were closed because of lack of reproducibility, ho... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
def process_boolean_str(value):
if type(value) is bool:
return value
if value is None:
return False
if value == "":
return None
return bool(strtobool(value))
def empty_str_cast(... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
def process_boolean_str(value):
if type(value) is bool:
return value
if value is None:
return False
if value == "":
return None
return bool(strtobool(value))
def empty_str_cast(... |
solves undefined if visibility is set to hidden
**Environment**:
- CTFd Version/Commit: adc70fb320242d5e4df1a7ce2d107c0e2b8039e7
- Operating System: Ubuntu 18.04
- Web Browser and Version: Safari 13.1.1, Chrome 83.0.4103.106
**What happened?**
When _Score Visibility_ or _Account Visibility_ is not public, us... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy.sql import and_
from CTFd.api.v1.helpers.models import build_model_filters
from CTFd.api.v1.helpers.request import vali... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy.sql import and_
from CTFd.api.v1.helpers.models import build_model_filters
from CTFd.api.v1.helpers.request import vali... |
Move documentation site into seperate repo and site
I am merging help.ctfd.io and docs.ctfd.io into a singular site. It will be on Netlify instead of readthedocs. This is just an issue to track that work.
| CTFd/__init__.py
<|code_start|>import datetime
import os
import sys
import weakref
from distutils.version import StrictVersion
import jinja2
from flask import Flask, Request
from flask_migrate import upgrade
from jinja2 import FileSystemLoader
from jinja2.sandbox import SandboxedEnvironment
from werkzeug.middleware.pr... | CTFd/__init__.py
<|code_start|>import datetime
import os
import sys
import weakref
from distutils.version import StrictVersion
import jinja2
from flask import Flask, Request
from flask_migrate import upgrade
from jinja2 import FileSystemLoader
from jinja2.sandbox import SandboxedEnvironment
from werkzeug.middleware.pr... |
Colon in CTF name breaks emails
This is because of:
https://tools.ietf.org/html/rfc5322#section-2.2
This can probably be fixed with `"HE:tech" <tech@example.com>`.
| CTFd/utils/email/mailgun.py
<|code_start|>import requests
from CTFd.utils import get_app_config, get_config
def sendmail(addr, text, subject):
ctf_name = get_config("ctf_name")
mailfrom_addr = get_config("mailfrom_addr") or get_app_config("MAILFROM_ADDR")
mailfrom_addr = "{} <{}>".format(ctf_name, mailfr... | CTFd/utils/email/mailgun.py
<|code_start|>from email.utils import formataddr
import requests
from CTFd.utils import get_app_config, get_config
def sendmail(addr, text, subject):
ctf_name = get_config("ctf_name")
mailfrom_addr = get_config("mailfrom_addr") or get_app_config("MAILFROM_ADDR")
mailfrom_addr... |
Render hints server side instead of client side
Render hints server side instead of client side to match challenges and pages
| CTFd/api/v1/hints.py
<|code_start|>from typing import List
from flask import request
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.models import build_model_filters
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api... | CTFd/api/v1/hints.py
<|code_start|>from typing import List
from flask import request
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.models import build_model_filters
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api... |
Unify deployment
There is a lot of setup/deployment related code that belongs in a separate repository. We should clean out the random setup files here and move them to a new repo.
This should also come with a single straightforward way to install CTFd.
serve.py should become a simple debugging & development to... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
def process_boolean_str(value):
if type(value) is bool:
return value
if value is None:
return False
if value == "":
return None
return bool(strtobool(value))
def empty_str_cast(... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
def process_boolean_str(value):
if type(value) is bool:
return value
if value is None:
return False
if value == "":
return None
return bool(strtobool(value))
def empty_str_cast(... |
Add way to reference envvars from config.ini
The extra section needs a way to reference environment variables.
IMO this should be restricted to the extra section because in other areas, someone might be inclined to have a password or other value with a `$` in it an accidentally use or leak an environment variable. ... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
def process_boolean_str(value):
if type(value) is bool:
return value
if value is None:
return False
if value == "":
return None
return bool(strtobool(value))
def empty_str_cast(... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
class EnvInterpolation(configparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def before_get(self, parser, section, option, value, defaults):
value = super().b... |
Hidden scores, hides graphs for admins as well
Hidden scores, hides graphs for admins as well.
| CTFd/scoreboard.py
<|code_start|>from flask import Blueprint, render_template
from CTFd.cache import cache, make_cache_key
from CTFd.utils import config
from CTFd.utils.decorators.visibility import check_score_visibility
from CTFd.utils.helpers import get_infos
from CTFd.utils.scores import get_standings
scoreboard =... | CTFd/scoreboard.py
<|code_start|>from flask import Blueprint, render_template
from CTFd.cache import cache, make_cache_key
from CTFd.utils import config
from CTFd.utils.config.visibility import scores_visible
from CTFd.utils.decorators.visibility import check_score_visibility
from CTFd.utils.helpers import get_infos
f... |
Review usage of error components
Looks like there needs to be more usage of the error components jinja snippet. It looks like it's missing in core/teams/public and core/teams/private at least.
| CTFd/teams.py
<|code_start|>from flask import Blueprint, redirect, render_template, request, url_for
from CTFd.cache import clear_team_session, clear_user_session
from CTFd.models import Teams, db
from CTFd.utils import config, get_config
from CTFd.utils.crypto import verify_password
from CTFd.utils.decorators import ... | CTFd/teams.py
<|code_start|>from flask import Blueprint, redirect, render_template, request, url_for
from CTFd.cache import clear_team_session, clear_user_session
from CTFd.models import Teams, db
from CTFd.utils import config, get_config
from CTFd.utils.crypto import verify_password
from CTFd.utils.decorators import ... |
Add email sender address override
Right now the email sender is set to the From address which isn't right in all situations. We need a way to override the email sender if it's not supposed to be the same as the From address.
https://help.mailgun.com/hc/en-us/articles/202236494-What-is-the-difference-between-the-Fro... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
class EnvInterpolation(configparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def before_get(self, parser, section, option, value, defaults):
value = super().b... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
class EnvInterpolation(configparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def before_get(self, parser, section, option, value, defaults):
value = super().b... |
Unnecessary ping event
**Environment**:
- CTFd Version/Commit: 3.1.1, latest commit
- Operating System: any
- Web Browser and Version: any
in the comment you said "Immediately yield a ping event to force Response headers to be set", but this event seems to lies inside the while True loop, which results to an un... | CTFd/utils/events/__init__.py
<|code_start|>import json
from collections import defaultdict
from queue import Queue
from gevent import Timeout, spawn
from tenacity import retry, wait_exponential
from CTFd.cache import cache
from CTFd.utils import string_types
class ServerSentEvent(object):
def __init__(self, da... | CTFd/utils/events/__init__.py
<|code_start|>import json
from collections import defaultdict
from queue import Queue
from gevent import Timeout, spawn
from tenacity import retry, wait_exponential
from CTFd.cache import cache
from CTFd.utils import string_types
class ServerSentEvent(object):
def __init__(self, da... |
Enable Switching Teams
<!--
If this is a bug report please fill out the template below.
If this is a feature request please describe the behavior that you'd like to see.
-->
**Environment**:
- CTFd Version/Commit:
- Kali Linux:
- Chrome 84.0.4147:
**What happened?**
Mistake Made, one person needs to sw... | CTFd/api/v1/teams.py
<|code_start|>import copy
from typing import List
from flask import abort, request, session
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import (
APIDet... | CTFd/api/v1/teams.py
<|code_start|>import copy
from typing import List
from flask import abort, request, session
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import (
APIDet... |
Incorrect update alert in Admin panel
<!--
If this is a bug report please fill out the template below.
If this is a feature request please describe the behavior that you'd like to see.
-->
**Environment**:
- CTFd Version/Commit: 3.1.1
- Operating System: Ubuntu 20.4
- Web Browser and Version: Chrome 85
... | CTFd/utils/updates/__init__.py
<|code_start|>import sys
import time
from distutils.version import StrictVersion
from platform import python_version
import requests
from flask import current_app as app
from CTFd.models import Challenges, Teams, Users, db
from CTFd.utils import get_app_config, get_config, set_config
fr... | CTFd/utils/updates/__init__.py
<|code_start|>import sys
import time
from distutils.version import StrictVersion
from platform import python_version
import requests
from flask import current_app as app
from CTFd.models import Challenges, Teams, Users, db
from CTFd.utils import get_app_config, get_config, set_config
fr... |
Ability to add members to a team via Admin Panel
Hey there!
I'm making a CTF and I am making users and team registration externally. I have seen that you are able to remove players from teams via the Admin Panel, but you are unable to do the reverse. It'd be great to add users from there, and not having to login int... | CTFd/api/v1/users.py
<|code_start|>from typing import List
from flask import abort, request, session
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import (
APIDetailedSuccess... | CTFd/api/v1/users.py
<|code_start|>from typing import List
from flask import abort, request, session
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import (
APIDetailedSuccess... |
CTFd pages route is relative when it shouldn't be
For some reason CTFd page routes are being generated in the navbar as relative when they shouldn't be. E.g. (`page` instead of `/page`).
| CTFd/plugins/__init__.py
<|code_start|>import glob
import importlib
import os
from collections import namedtuple
from flask import current_app as app
from flask import send_file, send_from_directory
from CTFd.utils.config.pages import get_pages
from CTFd.utils.decorators import admins_only as admins_only_wrapper
from... | CTFd/plugins/__init__.py
<|code_start|>import glob
import importlib
import os
from collections import namedtuple
from flask import current_app as app
from flask import send_file, send_from_directory, url_for
from CTFd.utils.config.pages import get_pages
from CTFd.utils.decorators import admins_only as admins_only_wra... |
Changing an Admin back to a unprivileged User raise two exceptions and prevent the page to reload
**Environment**:
- CTFd Version/Commit: 3.2.1
- Operating System: Ubuntu
- Web Browser and Version: Firefox 85.0
**What happened?**
I was playing with the users settings when I found this issue:
- If I chang... | CTFd/api/v1/users.py
<|code_start|>from typing import List
from flask import abort, request, session
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import (
APIDetailedSuccess... | CTFd/api/v1/users.py
<|code_start|>from typing import List
from flask import abort, request, session
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import (
APIDetailedSuccess... |
Invalid model identifier
https://github.com/CTFd/CTFd/blob/master/CTFd/themes/core/templates/scoreboard.html#L26
This should change depending on the mode of the CTF
| CTFd/plugins/__init__.py
<|code_start|>import glob
import importlib
import os
from collections import namedtuple
from flask import current_app as app
from flask import send_file, send_from_directory, url_for
from CTFd.utils.config.pages import get_pages
from CTFd.utils.decorators import admins_only as admins_only_wra... | CTFd/plugins/__init__.py
<|code_start|>import glob
import importlib
import os
from collections import namedtuple
from flask import current_app as app
from flask import send_file, send_from_directory, url_for
from CTFd.utils.config.pages import get_pages
from CTFd.utils.decorators import admins_only as admins_only_wra... |
Feature request: disable team creation
I have a use case where the teams are manually created and the students receive the teamname+passcode. Team creation should be disabled so that they only can join an existing team.
| CTFd/forms/config.py
<|code_start|>from wtforms import BooleanField, SelectField, StringField, TextAreaField
from wtforms.fields.html5 import IntegerField, URLField
from wtforms.widgets.html5 import NumberInput
from CTFd.forms import BaseForm
from CTFd.forms.fields import SubmitField
from CTFd.models import db
class... | CTFd/forms/config.py
<|code_start|>from wtforms import BooleanField, SelectField, StringField, TextAreaField
from wtforms.fields.html5 import IntegerField, URLField
from wtforms.widgets.html5 import NumberInput
from CTFd.forms import BaseForm
from CTFd.forms.fields import SubmitField
from CTFd.models import db
class... |
Add solve count to challenge list API
It would be nice if we could add the number of solves to the challenge list API so themes could render things like first blood or medal availability. We can currently request the solves for each challenge but that'd be extremely wasteful and since we already make queries for solves... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy.sql import and_
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchem... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy import func as sa_func
from sqlalchemy import types as sa_types
from sqlalchemy.sql import and_, cast, false, true
from... |
Submissions should link directly to the user that submitted
Submissions don't link directly to the user in team mode which means you need to search to see what user submitted for a given team.
| CTFd/admin/submissions.py
<|code_start|>from flask import render_template, request, url_for
from CTFd.admin import admin
from CTFd.models import Challenges, Submissions
from CTFd.utils.decorators import admins_only
from CTFd.utils.helpers.models import build_model_filters
from CTFd.utils.modes import get_model
@admi... | CTFd/admin/submissions.py
<|code_start|>from flask import render_template, request, url_for
from CTFd.admin import admin
from CTFd.models import Challenges, Submissions
from CTFd.utils.decorators import admins_only
from CTFd.utils.helpers.models import build_model_filters
from CTFd.utils.modes import get_model
@admi... |
Empty and null prerequisites can be added from admin UI
**Environment**:
- CTFd Version/Commit: 843546b (tip of master)
- Operating System: Linux
- Web Browser and Version: Firefox
**What happened?**
Adding a prerequisite to a challenge without selecting a valid challenge entry in the drop down results in eith... | CTFd/schemas/challenges.py
<|code_start|>from marshmallow import validate
from marshmallow_sqlalchemy import field_for
from CTFd.models import Challenges, ma
class ChallengeSchema(ma.ModelSchema):
class Meta:
model = Challenges
include_fk = True
dump_only = ("id",)
name = field_for(
... | CTFd/schemas/challenges.py
<|code_start|>from marshmallow import validate
from marshmallow.exceptions import ValidationError
from marshmallow_sqlalchemy import field_for
from CTFd.models import Challenges, ma
class ChallengeRequirementsValidator(validate.Validator):
default_message = "Error parsing challenge req... |
Set plugin migration version in between each migration
https://github.com/CTFd/CTFd/blob/e1991e16963b10302baa7cc50d52071a5053bf2f/CTFd/plugins/migrations.py#L72-L77
This code here probably should be setting the plugin version in between each migration so that if a migration fails it doesn't need to be started from t... | CTFd/plugins/migrations.py
<|code_start|>import inspect
import os
from alembic.config import Config
from alembic.migration import MigrationContext
from alembic.operations import Operations
from alembic.script import ScriptDirectory
from flask import current_app
from sqlalchemy import create_engine, pool
from CTFd.uti... | CTFd/plugins/migrations.py
<|code_start|>import inspect
import os
from alembic.config import Config
from alembic.migration import MigrationContext
from alembic.operations import Operations
from alembic.script import ScriptDirectory
from flask import current_app
from sqlalchemy import create_engine, pool
from CTFd.uti... |
Potentially expose user standings in admin scoreboard
This could let people give out awards for users who earn the most points or something like that.
The issue with this is that user standings don't really mean anything. A user that earned all the points in a team might just have been the person to submit all the ... | CTFd/admin/scoreboard.py
<|code_start|>from flask import render_template
from CTFd.admin import admin
from CTFd.scoreboard import get_standings
from CTFd.utils.decorators import admins_only
@admin.route("/admin/scoreboard")
@admins_only
def scoreboard_listing():
standings = get_standings(admin=True)
return r... | CTFd/admin/scoreboard.py
<|code_start|>from flask import render_template
from CTFd.admin import admin
from CTFd.utils.config import is_teams_mode
from CTFd.utils.decorators import admins_only
from CTFd.utils.scores import get_standings, get_user_standings
@admin.route("/admin/scoreboard")
@admins_only
def scoreboard... |
Don't require teams for viewing challenges if challenges are public
Looks like if challenges are set to be public but teams are required then challenges can't be seen. This requirement needs to be relaxed a bit.
| CTFd/challenges.py
<|code_start|>from flask import Blueprint, render_template
from CTFd.utils import config
from CTFd.utils.dates import ctf_ended, ctf_paused, ctf_started
from CTFd.utils.decorators import (
during_ctf_time_only,
require_team,
require_verified_emails,
)
from CTFd.utils.decorators.visibilit... | CTFd/challenges.py
<|code_start|>from flask import Blueprint, redirect, render_template, request, url_for
from CTFd.constants.config import ChallengeVisibilityTypes, Configs
from CTFd.utils.config import is_teams_mode
from CTFd.utils.dates import ctf_ended, ctf_paused, ctf_started
from CTFd.utils.decorators import dur... |
Use pybluemonday instead of the current lxml HTML sanitization approach
This library should be significantly faster about sanitizing HTML compared to lxml or html_santizer.
https://github.com/ColdHeat/pybluemonday
| CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
class EnvInterpolation(configparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def before_get(self, parser, section, option, value, defaults):
value = super().b... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
class EnvInterpolation(configparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def before_get(self, parser, section, option, value, defaults):
value = super().b... |
Hidden users can't see challenges they meet the prerequisites for
**Environment**:
- CTFd Version/Commit: 3.3 dev branch
- Operating System:
- Web Browser and Version:
**What happened?**
Solved a challenge which is a prerequisite for another as the admin user which is hidden by default. The other challenge doe... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy import func as sa_func
from sqlalchemy import types as sa_types
from sqlalchemy.sql import and_, cast, false, true
from... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy import func as sa_func
from sqlalchemy.sql import and_, false, true
from CTFd.api.v1.helpers.request import validate_ar... |
Hidden users can't see challenges they meet the prerequisites for
**Environment**:
- CTFd Version/Commit: 3.3 dev branch
- Operating System:
- Web Browser and Version:
**What happened?**
Solved a challenge which is a prerequisite for another as the admin user which is hidden by default. The other challenge doe... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy import func as sa_func
from sqlalchemy import types as sa_types
from sqlalchemy.sql import and_, cast, false, true
from... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy import func as sa_func
from sqlalchemy.sql import and_, false, true
from CTFd.api.v1.helpers.request import validate_ar... |
Use sqlalchemy Python script to test availability of database.
**Environment**:
- CTFd Version/Commit:
2.0.0 branch
- Operating System:
MacOS X, but building/deploying container images.
- Web Browser and Version:
N/A
**What happened?**
The check using ``mysqladmin`` in ``docker-entrypoint.... | ping.py
<|code_start|><|code_end|>
| ping.py
<|code_start|>"""
Script for checking that a database server is available.
Essentially a cross-platform, database agnostic mysqladmin.
"""
import time
from sqlalchemy import create_engine
from sqlalchemy.engine.url import make_url
from CTFd.config import Config
url = make_url(Config.DATABASE_URL)
# Ignore s... |
Add solves and solved_by_me to the ChallengesList endpoint
Follow up to #1811. We need to update the Pydantic models that generates documentation to include the new solves and solved_by_me properties.
Add solves and solved_by_me to the ChallengesList endpoint
Follow up to #1811. We need to update the Pydantic models th... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy import func as sa_func
from sqlalchemy.sql import and_, false, true
from CTFd.api.v1.helpers.request import validate_ar... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy import func as sa_func
from sqlalchemy.sql import and_, false, true
from CTFd.api.v1.helpers.request import validate_ar... |
The REST API for deleting files does not remove the file's directory and does not update the Media Library list
**Environment**:
- CTFd Version/Commit: 3.2.1
- Operating System: Docker (`python:3.6-slim-buster`)
- Web Browser and Version: NA
**What happened?**
I am using the REST API for deleting files (e.g... | CTFd/utils/uploads/uploaders.py
<|code_start|>import os
import posixpath
import string
from shutil import copyfileobj
import boto3
from flask import current_app, redirect, send_file
from flask.helpers import safe_join
from werkzeug.utils import secure_filename
from CTFd.utils import get_app_config
from CTFd.utils.enc... | CTFd/utils/uploads/uploaders.py
<|code_start|>import os
import posixpath
import string
from pathlib import PurePath
from shutil import copyfileobj, rmtree
import boto3
from flask import current_app, redirect, send_file
from flask.helpers import safe_join
from werkzeug.utils import secure_filename
from CTFd.utils impo... |
Bump pybluemonday to latest
Just tracking this so we don't forget. Latest should be 0.0.6 with bluemonday at 1.0.10. It adds support for comments in the HTML output.
| CTFd/utils/security/sanitize.py
<|code_start|>from pybluemonday import UGCPolicy
# Copied from lxml:
# https://github.com/lxml/lxml/blob/e986a9cb5d54827c59aefa8803bc90954d67221e/src/lxml/html/defs.py#L38
# fmt: off
SAFE_ATTRS = (
'abbr', 'accept', 'accept-charset', 'accesskey', 'action', 'align',
'alt', 'axis'... | CTFd/utils/security/sanitize.py
<|code_start|>from pybluemonday import UGCPolicy
# Copied from lxml:
# https://github.com/lxml/lxml/blob/e986a9cb5d54827c59aefa8803bc90954d67221e/src/lxml/html/defs.py#L38
# fmt: off
SAFE_ATTRS = (
'abbr', 'accept', 'accept-charset', 'accesskey', 'action', 'align',
'alt', 'axis'... |
IP to City Database
I think we can provide an IP to city database now instead of just showing country.
| CTFd/utils/countries/geoip.py
<|code_start|>import geoacumen
import maxminddb
from flask import current_app
IP_ADDR_LOOKUP = maxminddb.open_database(
current_app.config.get("GEOIP_DATABASE_PATH", geoacumen.db_path)
)
def lookup_ip_address(addr):
try:
response = IP_ADDR_LOOKUP.get(addr)
return... | CTFd/utils/countries/geoip.py
<|code_start|>import geoacumen_city
import maxminddb
from flask import current_app
IP_ADDR_LOOKUP = maxminddb.open_database(
current_app.config.get("GEOIP_DATABASE_PATH", geoacumen_city.db_path)
)
def lookup_ip_address(addr):
try:
response = IP_ADDR_LOOKUP.get(addr)
... |
Users in admin scoreboard show user position instead of team position
In teams mode on the admin panel, users are shown with their user position on the scoreboard instead of their teams position. We should be showing both.
| CTFd/admin/users.py
<|code_start|>from flask import render_template, request, url_for
from sqlalchemy.sql import not_
from CTFd.admin import admin
from CTFd.models import Challenges, Tracking, Users
from CTFd.utils import get_config
from CTFd.utils.decorators import admins_only
from CTFd.utils.modes import TEAMS_MODE
... | CTFd/admin/users.py
<|code_start|>from flask import render_template, request, url_for
from sqlalchemy.sql import not_
from CTFd.admin import admin
from CTFd.models import Challenges, Tracking, Users
from CTFd.utils import get_config
from CTFd.utils.decorators import admins_only
from CTFd.utils.modes import TEAMS_MODE
... |
Stub issue for ctfcli #13
https://github.com/CTFd/ctfcli/issues/13
This needs to be resolved in CTFd most likely.
| CTFd/plugins/dynamic_challenges/__init__.py
<|code_start|>from __future__ import division # Use floating point for math calculations
import math
from flask import Blueprint
from CTFd.models import Challenges, Solves, db
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.challenges import CH... | CTFd/plugins/dynamic_challenges/__init__.py
<|code_start|>from __future__ import division # Use floating point for math calculations
import math
from flask import Blueprint
from CTFd.models import Challenges, Solves, db
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.challenges import CH... |
CSV import
We need CSV import of the more often used tables. It seems people are okay with the content being kind of constrained but we need to support the behavior to some degree.
| CTFd/admin/__init__.py
<|code_start|>import csv
import datetime
import os
from io import BytesIO, StringIO
from flask import Blueprint, abort
from flask import current_app as app
from flask import (
redirect,
render_template,
render_template_string,
request,
send_file,
url_for,
)
admin = Bluep... | CTFd/admin/__init__.py
<|code_start|>import csv
import datetime
import os
from io import BytesIO, StringIO
from flask import Blueprint, abort
from flask import current_app as app
from flask import (
redirect,
render_template,
render_template_string,
request,
send_file,
url_for,
)
admin = Bluep... |
Consider passing challenge class over into the view.html context
This makes it a little easier for the challenge view to access Python code. Not sure if this looks best as challenge.class.read() or challenge_class.read().
| CTFd/models/__init__.py
<|code_start|>import datetime
from collections import defaultdict
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import column_property, validates
from CTFd.cache import cache
db = SQLAlch... | CTFd/models/__init__.py
<|code_start|>import datetime
from collections import defaultdict
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import column_property, validates
from CTFd.cache import cache
db = SQLAlch... |
API Error: config is too long - JSON bool values not sent correctly - 400 bad request on PATCH requests
**Environment**:
- CTFd Version/Commit: 3.3.0 (`ctfd/ctfd:latest` image)
- Operating System: Docker on AWS ECS
- Web Browser and Version: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:89.0) Gecko/20100101 Fir... | CTFd/api/v1/config.py
<|code_start|>from typing import List
from flask import request
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import APIDetailedSuccessResponse, APIListSucc... | CTFd/api/v1/config.py
<|code_start|>from typing import List
from flask import request
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import APIDetailedSuccessResponse, APIListSucc... |
Error 500 when visiting /admin/users/1 - AttributeError: 'NoneType' object has no attribute 'get_score'
**Environment**:
- CTFd Version/Commit: HEAD
- Operating System: Docker image based off official Dockerfile
- Web Browser and Version: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML,... | CTFd/admin/users.py
<|code_start|>from flask import render_template, request, url_for
from sqlalchemy.sql import not_
from CTFd.admin import admin
from CTFd.models import Challenges, Tracking, Users
from CTFd.utils import get_config
from CTFd.utils.decorators import admins_only
from CTFd.utils.modes import TEAMS_MODE
... | CTFd/admin/users.py
<|code_start|>from flask import render_template, request, url_for
from sqlalchemy.sql import not_
from CTFd.admin import admin
from CTFd.models import Challenges, Tracking, Users
from CTFd.utils import get_config
from CTFd.utils.decorators import admins_only
from CTFd.utils.modes import TEAMS_MODE
... |
Registration password
Some people have requested the ability for a registration password which I think is a reasonable ask and shouldn't be too hard to implement as a security field.
| CTFd/auth.py
<|code_start|>import base64
import requests
from flask import Blueprint, abort
from flask import current_app as app
from flask import redirect, render_template, request, session, url_for
from itsdangerous.exc import BadSignature, BadTimeSignature, SignatureExpired
from CTFd.cache import clear_team_sessio... | CTFd/auth.py
<|code_start|>import base64
import requests
from flask import Blueprint, abort
from flask import current_app as app
from flask import redirect, render_template, request, session, url_for
from itsdangerous.exc import BadSignature, BadTimeSignature, SignatureExpired
from CTFd.cache import clear_team_sessio... |
Make the distinction between user and team mode clearer during setup
We should probably have some kind of big checkbox div that explains what it means to be in user/teams mode. It would reduce the likelihood of needing to switch.
| CTFd/views.py
<|code_start|>import os
from flask import Blueprint, abort
from flask import current_app as app
from flask import redirect, render_template, request, send_file, session, url_for
from flask.helpers import safe_join
from sqlalchemy.exc import IntegrityError
from CTFd.cache import cache
from CTFd.constants... | CTFd/views.py
<|code_start|>import os
from flask import Blueprint, abort
from flask import current_app as app
from flask import redirect, render_template, request, send_file, session, url_for
from flask.helpers import safe_join
from jinja2.exceptions import TemplateNotFound
from sqlalchemy.exc import IntegrityError
f... |
Add time to export filename
| CTFd/admin/__init__.py
<|code_start|>import csv
import datetime
import os
from io import BytesIO, StringIO
from flask import Blueprint, abort
from flask import current_app as app
from flask import (
redirect,
render_template,
render_template_string,
request,
send_file,
url_for,
)
admin = Bluep... | CTFd/admin/__init__.py
<|code_start|>import csv
import datetime
import os
from io import BytesIO, StringIO
from flask import Blueprint, abort
from flask import current_app as app
from flask import (
redirect,
render_template,
render_template_string,
request,
send_file,
url_for,
)
admin = Bluep... |
Export fields with users
We need a better way to export fields along with users and scoreboard.
| CTFd/admin/__init__.py
<|code_start|>import csv
import datetime
import os
from io import BytesIO, StringIO
from flask import Blueprint, abort
from flask import current_app as app
from flask import (
redirect,
render_template,
render_template_string,
request,
send_file,
url_for,
)
admin = Bluep... | CTFd/admin/__init__.py
<|code_start|>import csv
import datetime
import os
from io import StringIO
from flask import Blueprint, abort
from flask import current_app as app
from flask import (
redirect,
render_template,
render_template_string,
request,
send_file,
url_for,
)
admin = Blueprint("adm... |
Add CSV examples for CSV Import
Add CSV examples for CSV Import
| CTFd/utils/csv/__init__.py
<|code_start|>import csv
import json
from io import BytesIO, StringIO
from CTFd.models import (
Flags,
Hints,
Tags,
TeamFields,
Teams,
UserFields,
Users,
db,
get_class_by_tablename,
)
from CTFd.plugins.challenges import get_chal_class
from CTFd.utils.confi... | CTFd/utils/csv/__init__.py
<|code_start|>import csv
import json
from io import BytesIO, StringIO
from CTFd.models import (
Flags,
Hints,
Tags,
TeamFields,
Teams,
UserFields,
Users,
db,
get_class_by_tablename,
)
from CTFd.plugins.challenges import get_chal_class
from CTFd.utils.confi... |
Consider enabling THEME_FALLBACK by default
In order to improve theme development and usage, I think we should enable THEME_FALLBACK or perhaps create a way for themes to specify their parent theme.
Wordpress has a sort of similar idea: https://developer.wordpress.org/themes/advanced-topics/child-themes/
I am no... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
class EnvInterpolation(configparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def before_get(self, parser, section, option, value, defaults):
value = super().b... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
class EnvInterpolation(configparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def before_get(self, parser, section, option, value, defaults):
value = super().b... |
Make challenge submission attempt rate limiting configurable
Sometimes people end up hitting this rate limit too soon so we should make it configurable in the config panel.
https://github.com/CTFd/CTFd/blob/7fc05bd4e3bf18606871a0ba6ad11f70e2be77e0/CTFd/api/v1/challenges.py#L624-L648
Instead of a hard limit of 10... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy import func as sa_func
from sqlalchemy.sql import and_, false, true
from CTFd.api.v1.helpers.request import validate_ar... | CTFd/api/v1/challenges.py
<|code_start|>import datetime
from typing import List
from flask import abort, render_template, request, url_for
from flask_restx import Namespace, Resource
from sqlalchemy import func as sa_func
from sqlalchemy.sql import and_, false, true
from CTFd.api.v1.helpers.request import validate_ar... |
Deleting User Crashes server.
**Environment**:
- CTFd Version/Commit: https://github.com/CTFd/CTFd/commit/514ab2c8bd3b0687615307c19fa9618b09e3998a
- Operating System: Ubuntu 20
- Web Browser and Version: Chrome
**What happened?**
User registered and logged into the website. The admin then deleted the account ... | CTFd/cache/__init__.py
<|code_start|>from flask import request
from flask_caching import Cache, make_template_fragment_key
cache = Cache()
def make_cache_key(path=None, key_prefix="view/%s"):
"""
This function mostly emulates Flask-Caching's `make_cache_key` function so we can delete cached api responses.
... | CTFd/cache/__init__.py
<|code_start|>from flask import request
from flask_caching import Cache, make_template_fragment_key
cache = Cache()
def make_cache_key(path=None, key_prefix="view/%s"):
"""
This function mostly emulates Flask-Caching's `make_cache_key` function so we can delete cached api responses.
... |
SubmissionSchema needs more nested fields
I'm having trouble accessing a user's name from a SubmissionSchema dump. This is probably because we need more Nested Fields on the Schema in addition to just the nested challenge schema.
| CTFd/schemas/submissions.py
<|code_start|>from marshmallow import fields
from CTFd.models import Submissions, ma
from CTFd.schemas.challenges import ChallengeSchema
from CTFd.utils import string_types
class SubmissionSchema(ma.ModelSchema):
challenge = fields.Nested(ChallengeSchema, only=["name", "category", "va... | CTFd/schemas/submissions.py
<|code_start|>from marshmallow import fields
from CTFd.models import Submissions, ma
from CTFd.schemas.challenges import ChallengeSchema
from CTFd.schemas.teams import TeamSchema
from CTFd.schemas.users import UserSchema
from CTFd.utils import string_types
class SubmissionSchema(ma.ModelS... |
Team Creation before CTF starts
We should prompt users to create their teams before a CTF officially starts so they can just start playing when the time does start.
| CTFd/views.py
<|code_start|>import os
from flask import Blueprint, abort
from flask import current_app as app
from flask import redirect, render_template, request, send_file, session, url_for
from flask.helpers import safe_join
from jinja2.exceptions import TemplateNotFound
from sqlalchemy.exc import IntegrityError
f... | CTFd/views.py
<|code_start|>import os
from flask import Blueprint, abort
from flask import current_app as app
from flask import redirect, render_template, request, send_file, session, url_for
from flask.helpers import safe_join
from jinja2.exceptions import TemplateNotFound
from sqlalchemy.exc import IntegrityError
f... |
Size limits on logo, favicon, image uploads
Sometimes people upload really big images for small things like the logo or the favicon. We should impose some kind of size limit or automatic resizing.
| CTFd/forms/setup.py
<|code_start|>from wtforms import (
FileField,
HiddenField,
PasswordField,
RadioField,
SelectField,
StringField,
TextAreaField,
)
from wtforms.fields.html5 import EmailField
from wtforms.validators import InputRequired
from CTFd.constants.themes import DEFAULT_THEME
from... | CTFd/forms/setup.py
<|code_start|>from wtforms import (
FileField,
HiddenField,
PasswordField,
RadioField,
SelectField,
StringField,
TextAreaField,
)
from wtforms.fields.html5 import EmailField
from wtforms.validators import InputRequired
from CTFd.constants.themes import DEFAULT_THEME
from... |
Cascading Hints
Hints should have a sense of unlocking where one hint cannot be used until a previous one or others are used.
| CTFd/api/v1/hints.py
<|code_start|>from typing import List
from flask import request
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import APIDetailedSuccessResponse, APIListSucce... | CTFd/api/v1/hints.py
<|code_start|>from typing import List
from flask import request
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import APIDetailedSuccessResponse, APIListSucce... |
Next challenge after solve
This could be pulled off with a next column that points to the next ID to be viewed. It would need API changes, Admin Panel changes and a migration.
| CTFd/models/__init__.py
<|code_start|>import datetime
from collections import defaultdict
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import column_property, validates
from CTFd.cache import cache
db = SQLAlch... | CTFd/models/__init__.py
<|code_start|>import datetime
from collections import defaultdict
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import column_property, validates
from CTFd.cache import cache
db = SQLAlch... |
Page preview doesn't consider format
Page preview needs to take into account format when previewing
| CTFd/admin/pages.py
<|code_start|>from flask import render_template, request
from CTFd.admin import admin
from CTFd.models import Pages
from CTFd.schemas.pages import PageSchema
from CTFd.utils import markdown
from CTFd.utils.decorators import admins_only
@admin.route("/admin/pages")
@admins_only
def pages_listing()... | CTFd/admin/pages.py
<|code_start|>from flask import render_template, request
from CTFd.admin import admin
from CTFd.models import Pages
from CTFd.schemas.pages import PageSchema
from CTFd.utils import markdown
from CTFd.utils.decorators import admins_only
@admin.route("/admin/pages")
@admins_only
def pages_listing()... |
500 when calling `api/teams/me` under user mode
<!--
If this is a bug report please fill out the template below.
If this is a feature request please describe the behavior that you'd like to see.
-->
**Environment**:
- CTFd Version/Commit: 3.5.0
- Operating System: irrelevant
- Web Browser and Version: irre... | CTFd/api/v1/teams.py
<|code_start|>import copy
from typing import List
from flask import abort, request, session
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import (
APIDet... | CTFd/api/v1/teams.py
<|code_start|>import copy
from typing import List
from flask import abort, request, session
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import (
APIDet... |
Add a healthcheck endpoint
Add a simple healthcheck endpoint. Likely something like `/healthcheck`. It should likely so a simple `SELECT 1` on the database and do a simple `get_config()` call to validate that everything is working and then return a 200 with "OK". On any failure it should return 500.
| CTFd/cache/__init__.py
<|code_start|>from flask import request
from flask_caching import Cache, make_template_fragment_key
cache = Cache()
def make_cache_key(path=None, key_prefix="view/%s"):
"""
This function mostly emulates Flask-Caching's `make_cache_key` function so we can delete cached api responses.
... | CTFd/cache/__init__.py
<|code_start|>from functools import lru_cache, wraps
from time import monotonic_ns
from flask import request
from flask_caching import Cache, make_template_fragment_key
cache = Cache()
def timed_lru_cache(timeout: int = 300, maxsize: int = 64, typed: bool = False):
"""
lru_cache imple... |
CSV for teams+members+fields
We should have this CSV format to export but for some reason we don't. Should be an easy implementation.
| CTFd/utils/csv/__init__.py
<|code_start|>import csv
import json
from io import BytesIO, StringIO
from CTFd.models import (
Flags,
Hints,
Tags,
TeamFields,
Teams,
UserFields,
Users,
db,
get_class_by_tablename,
)
from CTFd.plugins.challenges import get_chal_class
from CTFd.schemas.cha... | CTFd/utils/csv/__init__.py
<|code_start|>import csv
import json
from io import BytesIO, StringIO
from CTFd.models import (
Flags,
Hints,
Tags,
TeamFields,
Teams,
UserFields,
Users,
db,
get_class_by_tablename,
)
from CTFd.plugins.challenges import get_chal_class
from CTFd.schemas.cha... |
Fix SAFE_MODE
SAFE_MODE isn't working from config.ini apparently at the moment.
| CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
from typing import Union
class EnvInterpolation(configparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def before_get(self, parser, section, option, value, defaults):
... | CTFd/config.py
<|code_start|>import configparser
import os
from distutils.util import strtobool
from typing import Union
class EnvInterpolation(configparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def before_get(self, parser, section, option, value, defaults):
... |
get_standings sorted by sumscore->max(solves.id,awards.id)
Right now the standings are sorted by (sumscore,id).
As can found in `CTFd/utils/scores/__init__.py:get_standings`
```python
standings_query = db.session.query(
Model.id.label('account_id'),
Model.oauth_id.label('oauth_id'),
... | CTFd/models/__init__.py
<|code_start|>import datetime
from collections import defaultdict
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import column_property, validates
from CTFd.cache import cache
db = SQLAlch... | CTFd/models/__init__.py
<|code_start|>import datetime
from collections import defaultdict
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import column_property, validate... |
Health check fails on / despite app being online
<!--
If this is a bug report please fill out the template below.
If this is a feature request please describe the behavior that you'd like to see.
-->
**Environment**:
- CTFd Version/Commit: Latest Docker
- Operating System: Latest Docker
- Web Browser and V... | CTFd/utils/initialization/__init__.py
<|code_start|>import datetime
import logging
import os
import sys
from flask import abort, redirect, render_template, request, session, url_for
from sqlalchemy.exc import IntegrityError, InvalidRequestError
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from CTFd... | CTFd/utils/initialization/__init__.py
<|code_start|>import datetime
import logging
import os
import sys
from flask import abort, redirect, render_template, request, session, url_for
from sqlalchemy.exc import IntegrityError, InvalidRequestError
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from CTFd... |
Controlling static content like robots.txt
Some users seem to wish to be able to control things like their robots.txt. Is this something that we could implement in CTFd? Perhaps as a type of Page with a custom reponse type?
| CTFd/utils/initialization/__init__.py
<|code_start|>import datetime
import logging
import os
import sys
from flask import abort, redirect, render_template, request, session, url_for
from sqlalchemy.exc import IntegrityError, InvalidRequestError
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from CTFd... | CTFd/utils/initialization/__init__.py
<|code_start|>import datetime
import logging
import os
import sys
from flask import abort, redirect, render_template, request, session, url_for
from sqlalchemy.exc import IntegrityError, InvalidRequestError
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from CTFd... |
HTML_SANITIZATION controllable from config panel
We should maybe make HTML_SANITIZATION controlable from the admin panel so that Admins can decide how they want to deal with HTML.
Of course this maybe could be done another way, it's just the general idea about the configuration value.
| CTFd/admin/__init__.py
<|code_start|>import csv # noqa: I001
import datetime
import os
from io import StringIO
from flask import Blueprint, abort
from flask import current_app as app
from flask import (
jsonify,
redirect,
render_template,
render_template_string,
request,
send_file,
url_for... | CTFd/admin/__init__.py
<|code_start|>import csv # noqa: I001
import datetime
import os
from io import StringIO
from flask import Blueprint, abort
from flask import current_app as app
from flask import (
jsonify,
redirect,
render_template,
render_template_string,
request,
send_file,
url_for... |
Set a total user count limit
We can probably create a total user count limit that restricts total user registrations to some number.
| CTFd/auth.py
<|code_start|>import base64 # noqa: I001
import requests
from flask import Blueprint, abort
from flask import current_app as app
from flask import redirect, render_template, request, session, url_for
from itsdangerous.exc import BadSignature, BadTimeSignature, SignatureExpired
from CTFd.cache import cle... | CTFd/auth.py
<|code_start|>import base64 # noqa: I001
import requests
from flask import Blueprint, abort
from flask import current_app as app
from flask import redirect, render_template, request, session, url_for
from itsdangerous.exc import BadSignature, BadTimeSignature, SignatureExpired
from CTFd.cache import cle... |
Hints nonfunctional unless logged in
<!--
If this is a bug report please fill out the template below.
If this is a feature request please describe the behavior that you'd like to see.
-->
**Environment**:
- CTFd Version/Commit: 3.5.0
- Operating System: any
- Web Browser and Version: any
**What happened... | CTFd/api/v1/hints.py
<|code_start|>from typing import List
from flask import request
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import APIDetailedSuccessResponse, APIListSucce... | CTFd/api/v1/hints.py
<|code_start|>from typing import List
from flask import request
from flask_restx import Namespace, Resource
from CTFd.api.v1.helpers.request import validate_args
from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic
from CTFd.api.v1.schemas import APIDetailedSuccessResponse, APIListSucce... |
Challenge Preview Improvements
Challenge Preview should probably preview in the context of a full page. Primarily because it's easier to theme this.
| CTFd/admin/challenges.py
<|code_start|>from flask import abort, render_template, request, url_for
from CTFd.admin import admin
from CTFd.models import Challenges, Flags, Solves
from CTFd.plugins.challenges import CHALLENGE_CLASSES, get_chal_class
from CTFd.utils.decorators import admins_only
@admin.route("/admin/cha... | CTFd/admin/challenges.py
<|code_start|>from flask import abort, render_template, request, url_for
from CTFd.admin import admin
from CTFd.models import Challenges, Flags, Solves
from CTFd.plugins.challenges import CHALLENGE_CLASSES, get_chal_class
from CTFd.schemas.tags import TagSchema
from CTFd.utils.decorators impor... |
Develop "Dynamic Templates"
During SwampCTF we had 28 challenges, all dynamically scored. This means we had to input 4 distinct numbers in the right order for all challenges and keep them in sync. Any changes to the decay limit, minimum, or maximum scores had to be changed on all changes.
This was time consuming and... | CTFd/plugins/dynamic_challenges/__init__.py
<|code_start|>from __future__ import division # Use floating point for math calculations
import math
from flask import Blueprint
from CTFd.models import Challenges, Solves, db
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.challenges import CH... | CTFd/plugins/dynamic_challenges/__init__.py
<|code_start|>from flask import Blueprint
from CTFd.models import Challenges, db
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.challenges import CHALLENGE_CLASSES, BaseChallenge
from CTFd.plugins.dynamic_challenges.decay import DECAY_FUNCTIONS, ... |
Mark wrong key as correct button
| CTFd/api/v1/statistics/challenges.py
<|code_start|>from flask_restx import Resource
from sqlalchemy import func
from sqlalchemy.sql import and_
from CTFd.api.v1.statistics import statistics_namespace
from CTFd.models import Challenges, Solves, db
from CTFd.utils.decorators import admins_only
from CTFd.utils.modes impo... | CTFd/api/v1/statistics/challenges.py
<|code_start|>from flask_restx import Resource
from sqlalchemy import func
from sqlalchemy.sql import and_
from CTFd.api.v1.statistics import statistics_namespace
from CTFd.models import Challenges, Solves, db
from CTFd.utils.decorators import admins_only
from CTFd.utils.modes impo... |
Make core-beta the default choice during setup
The core theme is effectively deprecated for us so it doesn't make much sense to allow for new core theme installs after 3.6.
| CTFd/forms/setup.py
<|code_start|>from flask_babel import lazy_gettext as _l
from wtforms import (
FileField,
HiddenField,
PasswordField,
RadioField,
SelectField,
StringField,
TextAreaField,
)
from wtforms.fields.html5 import EmailField
from wtforms.validators import InputRequired
from CTFd... | CTFd/forms/setup.py
<|code_start|>from flask_babel import lazy_gettext as _l
from wtforms import (
FileField,
HiddenField,
PasswordField,
RadioField,
SelectField,
StringField,
TextAreaField,
)
from wtforms.fields.html5 import EmailField
from wtforms.validators import InputRequired
from CTFd... |
Test Translations & Support Spanish
We need to test translations before release and make sure we support Spanish
| CTFd/constants/languages.py
<|code_start|>from CTFd.constants import RawEnum
class Languages(str, RawEnum):
ENGLISH = "en"
GERMAN = "de"
POLISH = "pl"
LANGUAGE_NAMES = {
"en": "English",
"de": "Deutsch",
"pl": "Polski",
}
SELECT_LANGUAGE_LIST = [("", "")] + [
(str(lang), LANGUAGE_NAMES.... | CTFd/constants/languages.py
<|code_start|>from CTFd.constants import RawEnum
class Languages(str, RawEnum):
ENGLISH = "en"
GERMAN = "de"
POLISH = "pl"
SPANISH = "es"
CHINESE = "zh"
LANGUAGE_NAMES = {
"en": "English",
"de": "Deutsch",
"pl": "Polski",
"es": "Español",
"zh": "中文... |
Setup flow should always use the core theme
This just simplifies theme development. I think would be easier to do after CTFd.js but being optimistic.
| CTFd/forms/setup.py
<|code_start|>from flask_babel import lazy_gettext as _l
from wtforms import (
FileField,
HiddenField,
PasswordField,
RadioField,
SelectField,
StringField,
TextAreaField,
)
from wtforms.fields.html5 import EmailField
from wtforms.validators import InputRequired
from CTFd... | CTFd/forms/setup.py
<|code_start|>from flask_babel import lazy_gettext as _l
from wtforms import (
FileField,
HiddenField,
IntegerField,
PasswordField,
RadioField,
SelectField,
StringField,
TextAreaField,
)
from wtforms.fields.html5 import EmailField
from wtforms.validators import InputR... |
Setup flow should always use the core theme
This just simplifies theme development. I think would be easier to do after CTFd.js but being optimistic.
| CTFd/__init__.py
<|code_start|>import datetime
import os
import sys
import weakref
from distutils.version import StrictVersion
import jinja2
from flask import Flask, Request
from flask_babel import Babel
from flask_migrate import upgrade
from jinja2 import FileSystemLoader
from jinja2.sandbox import SandboxedEnvironme... | CTFd/__init__.py
<|code_start|>import datetime
import os
import sys
import weakref
from distutils.version import StrictVersion
import jinja2
from flask import Flask, Request
from flask_babel import Babel
from flask_migrate import upgrade
from jinja2 import FileSystemLoader
from jinja2.sandbox import SandboxedEnvironme... |
Two identical "id" columns in exported "solves" CSV file
**Environment**:
- CTFd Version: 3.6.0
- This issue **was not** present in CTFd 3.5.3
**What happened?**
When exporting the "solves" CSV, the resulting CSV file contains two "id" columns that are identical.
This is the first line (header) in the CSV file: ... | CTFd/models/__init__.py
<|code_start|>import datetime
from collections import defaultdict
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import column_property, validate... | CTFd/models/__init__.py
<|code_start|>import datetime
from collections import defaultdict
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import column_property, validate... |
Dynamic challenges do not show a Next Challenge
<!--
If this is a bug report please fill out the template below.
If this is a feature request please describe the behavior that you'd like to see.
-->
**Environment**:
- CTFd Version/Commit: 3.6.0/8ead306f8b57c059192cd8b137f37ee41a078a41
- Operating System: Al... | CTFd/plugins/dynamic_challenges/__init__.py
<|code_start|>from flask import Blueprint
from CTFd.models import Challenges, db
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.challenges import CHALLENGE_CLASSES, BaseChallenge
from CTFd.plugins.dynamic_challenges.decay import DECAY_FUNCTIONS, ... | CTFd/plugins/dynamic_challenges/__init__.py
<|code_start|>from flask import Blueprint
from CTFd.models import Challenges, db
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.challenges import CHALLENGE_CLASSES, BaseChallenge
from CTFd.plugins.dynamic_challenges.decay import DECAY_FUNCTIONS, ... |
Expose unix_time_to_utc to Jinja
I have a need for `unix_time_to_utc` in the Jinja template but it isn't currently exposed. Ultimately it's to convert between an Epoch timestamp to ISO 8601.
| CTFd/utils/initialization/__init__.py
<|code_start|>import datetime
import logging
import os
import sys
from flask import abort, redirect, render_template, request, session, url_for
from sqlalchemy.exc import IntegrityError, InvalidRequestError
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from CTFd... | CTFd/utils/initialization/__init__.py
<|code_start|>import datetime
import logging
import os
import sys
from flask import abort, redirect, render_template, request, session, url_for
from sqlalchemy.exc import IntegrityError, InvalidRequestError
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from CTFd... |
Upload to S3 Failing
- CTFd Version/Commit: 3.6.1
- Operating System: Linux (Docker container)
- Web Browser and Version: Chrome
**What happened?**
Upgrading CTFd resulting in S3 file uploads beginning to return 400 (bad request) status codes. I see one of the fixes for 3.6.1 was for S3, so perhaps a new bug wa... | CTFd/utils/uploads/__init__.py
<|code_start|>import hashlib
import shutil
from pathlib import Path
from CTFd.models import ChallengeFiles, Files, PageFiles, db
from CTFd.utils import get_app_config
from CTFd.utils.uploads.uploaders import FilesystemUploader, S3Uploader
UPLOADERS = {"filesystem": FilesystemUploader, "... | CTFd/utils/uploads/__init__.py
<|code_start|>import hashlib
import shutil
from pathlib import Path
from CTFd.models import ChallengeFiles, Files, PageFiles, db
from CTFd.utils import get_app_config
from CTFd.utils.uploads.uploaders import FilesystemUploader, S3Uploader
UPLOADERS = {"filesystem": FilesystemUploader, "... |
CSV hints with commas get split on imports
It seems not possible to supply a hint string that itself contains a comma. Example:
```
"friendly comma-free hint,https://url-hint-also-friendly,""hint, that contains comma"""
```
This would create four hints on import:
* friendly comma-free hint
* https://url-hint-also... | CTFd/utils/csv/__init__.py
<|code_start|>import csv
import json
from io import BytesIO, StringIO
from CTFd.models import (
Flags,
Hints,
Tags,
TeamFields,
Teams,
UserFields,
Users,
db,
get_class_by_tablename,
)
from CTFd.plugins.challenges import get_chal_class
from CTFd.schemas.cha... | CTFd/utils/csv/__init__.py
<|code_start|>import csv
import json
from io import BytesIO, StringIO
from CTFd.models import (
Flags,
Hints,
Tags,
TeamFields,
Teams,
UserFields,
Users,
db,
get_class_by_tablename,
)
from CTFd.plugins.challenges import get_chal_class
from CTFd.schemas.cha... |
Getting dynamic challenges by ID does not return decay function
When getting a dynamic challenge from `GET /api/v1/challenges/<challenge-id>`, the challenge does not return its decay function.
This seems to be caused by [this](https://github.com/CTFd/CTFd/blob/master/CTFd/plugins/dynamic_challenges/__init__.py#L60-L... | CTFd/plugins/dynamic_challenges/__init__.py
<|code_start|>from flask import Blueprint
from CTFd.models import Challenges, db
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.challenges import CHALLENGE_CLASSES, BaseChallenge
from CTFd.plugins.dynamic_challenges.decay import DECAY_FUNCTIONS, ... | CTFd/plugins/dynamic_challenges/__init__.py
<|code_start|>from flask import Blueprint
from CTFd.models import Challenges, db
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.challenges import CHALLENGE_CLASSES, BaseChallenge
from CTFd.plugins.dynamic_challenges.decay import DECAY_FUNCTIONS, ... |
Users cant solve challenge after changing to user mode
**Environment**:
- CTFd Version/Commit: 3.7.0
- Operating System: Ubuntu 22.04.3 LTS
- Web Browser and Version: Bug is occurs in Newest Chrome, Chromium and Firefox. Not tested more.
**What happened?**
Some of our users was not able to submit correct flag ... | CTFd/admin/__init__.py
<|code_start|>import csv # noqa: I001
import datetime
import os
from io import StringIO
from flask import Blueprint, abort
from flask import current_app as app
from flask import (
jsonify,
redirect,
render_template,
render_template_string,
request,
send_file,
url_for... | CTFd/admin/__init__.py
<|code_start|>import csv # noqa: I001
import datetime
import os
from io import StringIO
from flask import Blueprint, abort
from flask import current_app as app
from flask import (
jsonify,
redirect,
render_template,
render_template_string,
request,
send_file,
url_for... |
Add management command for generating a list of speakers without tickets.
See #40 for where the ticket tracking functionality was added.
| wafer/management/commands/pycon_speaker_tickets.py
<|code_start|><|code_end|>
| wafer/management/commands/pycon_speaker_tickets.py
<|code_start|>import sys
import csv
from optparse import make_option
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from wafer.talks.models import ACCEPTED
class Command(BaseCommand):
help = ("List speakers and a... |
Wafer page editing fails on Django 1.8 with ImproperlyConfigured: error
As seen on Travis, and confirmed locally, attempting to edit a page bombs out, ending with
"Specifying both 'fields' and 'form_class' is not permitted."
ImproperlyConfigured: Specifying both 'fields' and 'form_class' is not permitted.
| wafer/pages/views.py
<|code_start|>from django.http import Http404
from django.core.exceptions import PermissionDenied
from django.views.generic import DetailView, TemplateView, UpdateView
from wafer.pages.models import Page
from wafer.pages.forms import PageForm
class ShowPage(DetailView):
template_name = 'wafe... | wafer/pages/views.py
<|code_start|>from django.http import Http404
from django.core.exceptions import PermissionDenied
from django.views.generic import DetailView, TemplateView, UpdateView
from wafer.pages.models import Page
from wafer.pages.forms import PageForm
class ShowPage(DetailView):
template_name = 'wafe... |
Pentabarf export calculates duration incorrectly for items spanning multiple slots
The pentabarf,xml export does the wrong thing if an item spans multiple slots. It calculates the duration from just the first slot, rather than the entire item.
| wafer/schedule/admin.py
<|code_start|>import datetime
from django.conf.urls import url
from django.contrib import admin
from django.contrib import messages
from django.utils.encoding import force_text
from django.utils.translation import ugettext as _
from django import forms
from wafer.schedule.models import Day, Ve... | wafer/schedule/admin.py
<|code_start|>import datetime
from django.conf.urls import url
from django.contrib import admin
from django.contrib import messages
from django.utils.encoding import force_text
from django.utils.translation import ugettext as _
from django import forms
from wafer.schedule.models import Day, Ve... |
Remove'unicode' calls from wafer
Current wafer using python 3 fails on several admin tasks because `UserProfile.__str__` tries to call `unicode`, which is obviously not defined.
We should handle the difference between python 2 and python 3 correctly in this situation.
There are a couple of other calls to unicode() th... | wafer/registration/views.py
<|code_start|>import urllib
from django.contrib.auth import login
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.conf import settings
from django.http import Http404, HttpResponseRedirect
from wafer.registration.sso import SSOError, debian_sso,... | wafer/registration/views.py
<|code_start|>import urllib
from django.contrib.auth import login
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.conf import settings
from django.http import Http404, HttpResponseRedirect
from wafer.registration.sso import SSOError, debian_sso,... |
Duplicate page created
On https://wafertest.debconf.org, I created the following page: https://wafertest.debconf.org/debconf-16-bursaries-instructions, when my Wafer pages page loaded, I saw that there existed two new pages with that title.
When I visit https://wafertest.debconf.org/debconf-16-bursaries-instructions, ... | wafer/pages/admin.py
<|code_start|>from django.contrib import admin
from wafer.pages.models import File, Page
from wafer.compare.admin import CompareVersionAdmin, DateModifiedFilter
class PageAdmin(CompareVersionAdmin, admin.ModelAdmin):
prepopulated_fields = {"slug": ("name",)}
list_display = ('name', 'slu... | wafer/pages/admin.py
<|code_start|>from django.contrib import admin
from wafer.pages.models import File, Page
from wafer.compare.admin import CompareVersionAdmin, DateModifiedFilter
class PageAdmin(CompareVersionAdmin, admin.ModelAdmin):
prepopulated_fields = {"slug": ("name",)}
list_display = ('name', 'slu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.