From 6f87129846387488b441ae76932238ddcd404dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=8F=E2=80=8FDave?= <47663767+cydave@users.noreply.github.com> Date: Tue, 14 Apr 2020 19:26:50 +0000 Subject: [PATCH 001/112] Replace flask_restful with flask_restx (#1282) Co-authored-by: Kevin Chung --- CTFd/api/__init__.py | 2 +- CTFd/api/v1/awards.py | 2 +- CTFd/api/v1/challenges.py | 2 +- CTFd/api/v1/config.py | 2 +- CTFd/api/v1/files.py | 2 +- CTFd/api/v1/flags.py | 2 +- CTFd/api/v1/hints.py | 2 +- CTFd/api/v1/notifications.py | 2 +- CTFd/api/v1/pages.py | 2 +- CTFd/api/v1/scoreboard.py | 2 +- CTFd/api/v1/statistics/__init__.py | 2 +- CTFd/api/v1/statistics/challenges.py | 2 +- CTFd/api/v1/statistics/submissions.py | 2 +- CTFd/api/v1/statistics/teams.py | 2 +- CTFd/api/v1/statistics/users.py | 2 +- CTFd/api/v1/submissions.py | 2 +- CTFd/api/v1/tags.py | 2 +- CTFd/api/v1/teams.py | 2 +- CTFd/api/v1/tokens.py | 2 +- CTFd/api/v1/unlocks.py | 2 +- CTFd/api/v1/users.py | 2 +- requirements.txt | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/CTFd/api/__init__.py b/CTFd/api/__init__.py index efe51c3..5834750 100644 --- a/CTFd/api/__init__.py +++ b/CTFd/api/__init__.py @@ -1,5 +1,5 @@ from flask import Blueprint, current_app -from flask_restplus import Api +from flask_restx import Api from CTFd.api.v1.awards import awards_namespace from CTFd.api.v1.challenges import challenges_namespace diff --git a/CTFd/api/v1/awards.py b/CTFd/api/v1/awards.py index a77b36f..14dd65f 100644 --- a/CTFd/api/v1/awards.py +++ b/CTFd/api/v1/awards.py @@ -1,5 +1,5 @@ from flask import request -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.cache import clear_standings from CTFd.utils.config import is_teams_mode diff --git a/CTFd/api/v1/challenges.py b/CTFd/api/v1/challenges.py index a8f1fc9..bbdc57b 100644 --- a/CTFd/api/v1/challenges.py +++ b/CTFd/api/v1/challenges.py @@ -1,7 +1,7 @@ import datetime from flask import abort, request, url_for -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from sqlalchemy.sql import and_ from CTFd.cache import clear_standings diff --git a/CTFd/api/v1/config.py b/CTFd/api/v1/config.py index 5b9be70..ff7fd9d 100644 --- a/CTFd/api/v1/config.py +++ b/CTFd/api/v1/config.py @@ -1,5 +1,5 @@ from flask import request -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.cache import clear_config, clear_standings from CTFd.models import Configs, db diff --git a/CTFd/api/v1/files.py b/CTFd/api/v1/files.py index 731f267..394cfb0 100644 --- a/CTFd/api/v1/files.py +++ b/CTFd/api/v1/files.py @@ -1,5 +1,5 @@ from flask import request -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.models import Files, db from CTFd.schemas.files import FileSchema diff --git a/CTFd/api/v1/flags.py b/CTFd/api/v1/flags.py index 0819a2e..08fe278 100644 --- a/CTFd/api/v1/flags.py +++ b/CTFd/api/v1/flags.py @@ -1,5 +1,5 @@ from flask import request -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.models import Flags, db from CTFd.plugins.flags import FLAG_CLASSES, get_flag_class diff --git a/CTFd/api/v1/hints.py b/CTFd/api/v1/hints.py index 3bc62e2..5acea7f 100644 --- a/CTFd/api/v1/hints.py +++ b/CTFd/api/v1/hints.py @@ -1,5 +1,5 @@ from flask import request -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.models import Hints, HintUnlocks, db from CTFd.schemas.hints import HintSchema diff --git a/CTFd/api/v1/notifications.py b/CTFd/api/v1/notifications.py index 8dbb94b..0cf63a7 100644 --- a/CTFd/api/v1/notifications.py +++ b/CTFd/api/v1/notifications.py @@ -1,5 +1,5 @@ from flask import current_app, request -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.models import Notifications, db from CTFd.schemas.notifications import NotificationSchema diff --git a/CTFd/api/v1/pages.py b/CTFd/api/v1/pages.py index dedec07..b97bef8 100644 --- a/CTFd/api/v1/pages.py +++ b/CTFd/api/v1/pages.py @@ -1,5 +1,5 @@ from flask import request -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.cache import clear_pages from CTFd.models import Pages, db diff --git a/CTFd/api/v1/scoreboard.py b/CTFd/api/v1/scoreboard.py index 3fb6f52..5d44952 100644 --- a/CTFd/api/v1/scoreboard.py +++ b/CTFd/api/v1/scoreboard.py @@ -1,4 +1,4 @@ -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.cache import cache, make_cache_key from CTFd.models import Awards, Solves, Teams diff --git a/CTFd/api/v1/statistics/__init__.py b/CTFd/api/v1/statistics/__init__.py index 935218c..aff8781 100644 --- a/CTFd/api/v1/statistics/__init__.py +++ b/CTFd/api/v1/statistics/__init__.py @@ -1,4 +1,4 @@ -from flask_restplus import Namespace +from flask_restx import Namespace statistics_namespace = Namespace( "statistics", description="Endpoint to retrieve Statistics" diff --git a/CTFd/api/v1/statistics/challenges.py b/CTFd/api/v1/statistics/challenges.py index 8b6ac64..6a3bbfa 100644 --- a/CTFd/api/v1/statistics/challenges.py +++ b/CTFd/api/v1/statistics/challenges.py @@ -1,4 +1,4 @@ -from flask_restplus import Resource +from flask_restx import Resource from sqlalchemy import func from sqlalchemy.sql import or_ diff --git a/CTFd/api/v1/statistics/submissions.py b/CTFd/api/v1/statistics/submissions.py index 97f76ea..e1c62ba 100644 --- a/CTFd/api/v1/statistics/submissions.py +++ b/CTFd/api/v1/statistics/submissions.py @@ -1,4 +1,4 @@ -from flask_restplus import Resource +from flask_restx import Resource from sqlalchemy import func from CTFd.api.v1.statistics import statistics_namespace diff --git a/CTFd/api/v1/statistics/teams.py b/CTFd/api/v1/statistics/teams.py index 8aa3278..4bfbbf2 100644 --- a/CTFd/api/v1/statistics/teams.py +++ b/CTFd/api/v1/statistics/teams.py @@ -1,4 +1,4 @@ -from flask_restplus import Resource +from flask_restx import Resource from CTFd.api.v1.statistics import statistics_namespace from CTFd.models import Teams diff --git a/CTFd/api/v1/statistics/users.py b/CTFd/api/v1/statistics/users.py index 0632bf6..881d964 100644 --- a/CTFd/api/v1/statistics/users.py +++ b/CTFd/api/v1/statistics/users.py @@ -1,4 +1,4 @@ -from flask_restplus import Resource +from flask_restx import Resource from sqlalchemy import func from CTFd.api.v1.statistics import statistics_namespace diff --git a/CTFd/api/v1/submissions.py b/CTFd/api/v1/submissions.py index a88ac39..7a2e5e6 100644 --- a/CTFd/api/v1/submissions.py +++ b/CTFd/api/v1/submissions.py @@ -1,5 +1,5 @@ from flask import request -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.cache import clear_standings from CTFd.models import Submissions, db diff --git a/CTFd/api/v1/tags.py b/CTFd/api/v1/tags.py index 4693921..2134178 100644 --- a/CTFd/api/v1/tags.py +++ b/CTFd/api/v1/tags.py @@ -1,5 +1,5 @@ from flask import request -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.models import Tags, db from CTFd.schemas.tags import TagSchema diff --git a/CTFd/api/v1/teams.py b/CTFd/api/v1/teams.py index 1213c6d..c0f3dc8 100644 --- a/CTFd/api/v1/teams.py +++ b/CTFd/api/v1/teams.py @@ -1,7 +1,7 @@ import copy from flask import abort, request, session -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.cache import clear_standings from CTFd.models import Awards, Submissions, Teams, Unlocks, Users, db diff --git a/CTFd/api/v1/tokens.py b/CTFd/api/v1/tokens.py index a91f23e..165626f 100644 --- a/CTFd/api/v1/tokens.py +++ b/CTFd/api/v1/tokens.py @@ -1,7 +1,7 @@ import datetime from flask import request, session -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.models import Tokens, db from CTFd.schemas.tokens import TokenSchema diff --git a/CTFd/api/v1/unlocks.py b/CTFd/api/v1/unlocks.py index 61403b5..b1499be 100644 --- a/CTFd/api/v1/unlocks.py +++ b/CTFd/api/v1/unlocks.py @@ -1,5 +1,5 @@ from flask import request -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.cache import clear_standings from CTFd.models import Unlocks, db, get_class_by_tablename diff --git a/CTFd/api/v1/users.py b/CTFd/api/v1/users.py index 71436ba..41694b5 100644 --- a/CTFd/api/v1/users.py +++ b/CTFd/api/v1/users.py @@ -1,5 +1,5 @@ from flask import abort, request, session -from flask_restplus import Namespace, Resource +from flask_restx import Namespace, Resource from CTFd.cache import clear_standings from CTFd.models import ( diff --git a/requirements.txt b/requirements.txt index 2dfe141..d778de5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,7 +21,7 @@ redis==3.3.11 datafreeze==0.1.0 gevent==1.4.0 python-dotenv==0.10.3 -flask-restplus==0.13.0 +flask-restx==0.1.1 pathlib2==2.3.5 flask-marshmallow==0.10.1 marshmallow-sqlalchemy==0.17.0 From c5ec896b38811fb73d43dfd0aba88797b1254ff2 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Tue, 14 Apr 2020 16:58:09 -0400 Subject: [PATCH 002/112] Add Github Action for lint (#1321) --- .github/workflows/lint.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..28eba6a --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,33 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: CTFd CI + +on: + push: + paths: + - '**.py' + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['2.7', '3.6'] + + name: Python ${{ matrix.python-version }} + steps: + - uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r development.txt + - name: Lint + run: | + make lint \ No newline at end of file From 2a90f77ed31a98ec59c81b380bce5b446e58a3c9 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Tue, 14 Apr 2020 17:00:32 -0400 Subject: [PATCH 003/112] Run on any push --- .github/workflows/lint.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 28eba6a..352a66c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,10 +3,7 @@ name: CTFd CI -on: - push: - paths: - - '**.py' +on: [push] jobs: build: From 154e281612e7d53edb6885477b70c649323236d8 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Tue, 14 Apr 2020 17:03:38 -0400 Subject: [PATCH 004/112] Remove Python 2.7 --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 352a66c..3e6bcfb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['2.7', '3.6'] + python-version: ['3.6'] name: Python ${{ matrix.python-version }} steps: From 329e0c0455f1aa03ddc211a512c71e510fe8667f Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Tue, 14 Apr 2020 17:07:31 -0400 Subject: [PATCH 005/112] Remove Github action until 3.0 --- .github/workflows/lint.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 3e6bcfb..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,30 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: CTFd CI - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.6'] - - name: Python ${{ matrix.python-version }} - steps: - - uses: actions/checkout@v2 - - name: Setup python - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - architecture: x64 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r development.txt - - name: Lint - run: | - make lint \ No newline at end of file From c21707c14dd277a1cc81636b34e8bcc791ce013f Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 15 Apr 2020 02:41:23 -0400 Subject: [PATCH 006/112] Add eslint command to yarn (#1324) * Adds a `yarn lint` command that runs `eslint` * Starts work on #1245 --- .eslintrc.js | 17 +++++++++++++++++ package.json | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..edadc67 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,17 @@ +module.exports = { + "env": { + "browser": true, + "es6": true + }, + "extends": "eslint:recommended", + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module" + }, + "rules": { + } +}; \ No newline at end of file diff --git a/package.json b/package.json index 6947ab3..a914a91 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "dev": "node_modules/webpack-cli/bin/cli.js -w --mode=development", "build": "node_modules/webpack-cli/bin/cli.js --mode=development; node_modules/webpack-cli/bin/cli.js --mode=production", "verify": "node_modules/webpack-cli/bin/cli.js --mode=development --display=errors-only; node_modules/webpack-cli/bin/cli.js --mode=production --display=errors-only; git diff --quiet --exit-code", - "clean": "rm -rf CTFd/themes/core/static/css/* CTFd/themes/core/static/js/* CTFd/themes/admin/static/css/* CTFd/themes/admin/static/js/*" + "clean": "rm -rf CTFd/themes/core/static/css/* CTFd/themes/core/static/js/* CTFd/themes/admin/static/css/* CTFd/themes/admin/static/js/*", + "lint": "node_modules/.bin/eslint CTFd/themes/core/assets/ CTFd/themes/admin/assets/" }, "repository": { "type": "git", From 578b5261b2c8308db9e386b8885527a6b43d99b4 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 15 Apr 2020 03:04:18 -0400 Subject: [PATCH 007/112] Deprecates storing user type in session (#1323) * Deprecates storing session["type"] as a means of referring to the user's current level. Instead you should refer to the database. * Adds `CTFd.utils.user.get_current_user_type()` to get the current user's type or return None if the user is unauthed. * Closes #1279 --- CTFd/api/v1/teams.py | 11 +++++++---- CTFd/api/v1/tokens.py | 5 +++-- CTFd/api/v1/users.py | 7 ++++--- CTFd/utils/logging/__init__.py | 1 - CTFd/utils/security/auth.py | 1 - CTFd/utils/user/__init__.py | 11 ++++++++++- tests/challenges/test_dynamic.py | 2 -- tests/helpers.py | 3 --- tests/oauth/test_redirect.py | 1 - 9 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CTFd/api/v1/teams.py b/CTFd/api/v1/teams.py index c0f3dc8..070cbc3 100644 --- a/CTFd/api/v1/teams.py +++ b/CTFd/api/v1/teams.py @@ -13,7 +13,7 @@ from CTFd.utils.decorators.visibility import ( check_account_visibility, check_score_visibility, ) -from CTFd.utils.user import get_current_team, is_admin +from CTFd.utils.user import get_current_team, get_current_user_type, is_admin teams_namespace = Namespace("teams", description="Endpoint to retrieve Teams") @@ -23,7 +23,8 @@ class TeamList(Resource): @check_account_visibility def get(self): teams = Teams.query.filter_by(hidden=False, banned=False) - view = copy.deepcopy(TeamSchema.views.get(session.get("type", "user"))) + user_type = get_current_user_type(fallback="user") + view = copy.deepcopy(TeamSchema.views.get(user_type)) view.remove("members") response = TeamSchema(view=view, many=True).dump(teams) @@ -35,7 +36,8 @@ class TeamList(Resource): @admins_only def post(self): req = request.get_json() - view = TeamSchema.views.get(session.get("type", "self")) + user_type = get_current_user_type() + view = TeamSchema.views.get(user_type) schema = TeamSchema(view=view) response = schema.load(req) @@ -63,7 +65,8 @@ class TeamPublic(Resource): if (team.banned or team.hidden) and is_admin() is False: abort(404) - view = TeamSchema.views.get(session.get("type", "user")) + user_type = get_current_user_type(fallback="user") + view = TeamSchema.views.get(user_type) schema = TeamSchema(view=view) response = schema.dump(team) diff --git a/CTFd/api/v1/tokens.py b/CTFd/api/v1/tokens.py index 165626f..c8eaffa 100644 --- a/CTFd/api/v1/tokens.py +++ b/CTFd/api/v1/tokens.py @@ -7,7 +7,7 @@ from CTFd.models import Tokens, db from CTFd.schemas.tokens import TokenSchema from CTFd.utils.decorators import authed_only, require_verified_emails from CTFd.utils.security.auth import generate_user_token -from CTFd.utils.user import get_current_user, is_admin +from CTFd.utils.user import get_current_user, get_current_user_type, is_admin tokens_namespace = Namespace("tokens", description="Endpoint to retrieve Tokens") @@ -62,7 +62,8 @@ class TokenDetail(Resource): id=token_id, user_id=session["id"] ).first_or_404() - schema = TokenSchema(view=session.get("type", "user")) + user_type = get_current_user_type(fallback="user") + schema = TokenSchema(view=user_type) response = schema.dump(token) if response.errors: diff --git a/CTFd/api/v1/users.py b/CTFd/api/v1/users.py index 41694b5..895c9ea 100644 --- a/CTFd/api/v1/users.py +++ b/CTFd/api/v1/users.py @@ -1,4 +1,4 @@ -from flask import abort, request, session +from flask import abort, request from flask_restx import Namespace, Resource from CTFd.cache import clear_standings @@ -22,7 +22,7 @@ from CTFd.utils.decorators.visibility import ( check_score_visibility, ) from CTFd.utils.email import sendmail, user_created_notification -from CTFd.utils.user import get_current_user, is_admin +from CTFd.utils.user import get_current_user, get_current_user_type, is_admin users_namespace = Namespace("users", description="Endpoint to retrieve Users") @@ -80,7 +80,8 @@ class UserPublic(Resource): if (user.banned or user.hidden) and is_admin() is False: abort(404) - response = UserSchema(view=session.get("type", "user")).dump(user) + user_type = get_current_user_type(fallback="user") + response = UserSchema(view=user_type).dump(user) if response.errors: return {"success": False, "errors": response.errors}, 400 diff --git a/CTFd/utils/logging/__init__.py b/CTFd/utils/logging/__init__.py index faad380..7827568 100644 --- a/CTFd/utils/logging/__init__.py +++ b/CTFd/utils/logging/__init__.py @@ -13,7 +13,6 @@ def log(logger, format, **kwargs): "id": session.get("id"), "name": session.get("name"), "email": session.get("email"), - "type": session.get("type"), "date": time.strftime("%m/%d/%Y %X"), "ip": get_ip(), } diff --git a/CTFd/utils/security/auth.py b/CTFd/utils/security/auth.py index 21a7676..077e414 100644 --- a/CTFd/utils/security/auth.py +++ b/CTFd/utils/security/auth.py @@ -12,7 +12,6 @@ from CTFd.utils.security.csrf import generate_nonce def login_user(user): session["id"] = user.id session["name"] = user.name - session["type"] = user.type session["email"] = user.email session["nonce"] = generate_nonce() diff --git a/CTFd/utils/user/__init__.py b/CTFd/utils/user/__init__.py index 62bff16..81762ba 100644 --- a/CTFd/utils/user/__init__.py +++ b/CTFd/utils/user/__init__.py @@ -24,13 +24,22 @@ def get_current_team(): return None +def get_current_user_type(fallback=None): + if authed(): + user = Users.query.filter_by(id=session["id"]).first() + return user.type + else: + return fallback + + def authed(): return bool(session.get("id", False)) def is_admin(): if authed(): - return session["type"] == "admin" + user = get_current_user() + return user.type == "admin" else: return False diff --git a/tests/challenges/test_dynamic.py b/tests/challenges/test_dynamic.py index 13f9dd5..e34bb0e 100644 --- a/tests/challenges/test_dynamic.py +++ b/tests/challenges/test_dynamic.py @@ -213,7 +213,6 @@ def test_dynamic_challenge_loses_value_properly(): with client.session_transaction() as sess: sess["id"] = team_id sess["name"] = name - sess["type"] = "user" sess["email"] = email sess["nonce"] = "fake-nonce" @@ -306,7 +305,6 @@ def test_dynamic_challenge_value_isnt_affected_by_hidden_users(): with client.session_transaction() as sess: sess["id"] = team_id sess["name"] = name - sess["type"] = "user" sess["email"] = email sess["nonce"] = "fake-nonce" diff --git a/tests/helpers.py b/tests/helpers.py index c14ae71..65f2be9 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -150,7 +150,6 @@ def register_user( with client.session_transaction() as sess: assert sess["id"] assert sess["name"] == name - assert sess["type"] assert sess["email"] assert sess["nonce"] @@ -178,7 +177,6 @@ def login_as_user(app, name="user", password="password", raise_for_error=True): with client.session_transaction() as sess: assert sess["id"] assert sess["name"] - assert sess["type"] assert sess["email"] assert sess["nonce"] return client @@ -237,7 +235,6 @@ def login_with_mlc( with client.session_transaction() as sess: assert sess["id"] assert sess["name"] - assert sess["type"] assert sess["email"] assert sess["nonce"] return client diff --git a/tests/oauth/test_redirect.py b/tests/oauth/test_redirect.py index 183e163..55ae1ef 100644 --- a/tests/oauth/test_redirect.py +++ b/tests/oauth/test_redirect.py @@ -72,7 +72,6 @@ def test_oauth_configured_flow(): with client.session_transaction() as sess: assert sess["id"] assert sess["name"] - assert sess["type"] assert sess["email"] assert sess["nonce"] destroy_ctfd(app) From 0cfbf9020140ba4a46ac984f416bfe0aaf9b9102 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 15 Apr 2020 03:24:16 -0400 Subject: [PATCH 008/112] Closes #1256 --- CTFd/utils/exports/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CTFd/utils/exports/__init__.py b/CTFd/utils/exports/__init__.py index 06b59b1..5092a57 100644 --- a/CTFd/utils/exports/__init__.py +++ b/CTFd/utils/exports/__init__.py @@ -16,6 +16,7 @@ from flask_migrate import upgrade from sqlalchemy.exc import OperationalError, ProgrammingError from sqlalchemy.sql import sqltypes +from CTFd import __version__ as CTFD_VERSION from CTFd.cache import cache from CTFd.models import db, get_class_by_tablename from CTFd.utils import get_app_config, set_config @@ -348,3 +349,4 @@ def import_ctf(backup, erase=True): # Set default theme in case the current instance or the import does not provide it set_config("ctf_theme", "core") + set_config("ctf_version", CTFD_VERSION) From e113b2d627d23b7b7b1863dd599fc973bc8842c1 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 15 Apr 2020 03:38:25 -0400 Subject: [PATCH 009/112] Fix Admin Panel link from deprecating session type --- CTFd/themes/core/templates/base.html | 2 +- CTFd/utils/initialization/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CTFd/themes/core/templates/base.html b/CTFd/themes/core/templates/base.html index 0a6f9e2..a6c023d 100644 --- a/CTFd/themes/core/templates/base.html +++ b/CTFd/themes/core/templates/base.html @@ -82,7 +82,7 @@