Commit Graph

963 Commits

Author SHA1 Message Date
Kevin Chung
9a2f46e182 Fix unclickable label in challenge creation ui (#1554)
* Fix unclickable label in challenge creation ui
2020-07-19 20:17:59 -04:00
Kevin Chung
421dfc169a Allow bootstrap data attributes through the HTML sanitizer (#1553)
* Allow bootstrap data attributes through the HTML sanitizer
2020-07-19 17:19:33 -04:00
Kevin Chung
e5d6d8b36c Codecov GitHub actions (#1551)
* Run workflows more frequently to build status badges
* Add Github status badges to README
2020-07-17 23:31:28 -04:00
Kevin Chung
ddf7ba1cb0 Use codecov-action for codecov and remove travis-ci (#1550)
* Use codecov via a Github Action
* Remove Travis CI as CI provider
2020-07-17 22:35:17 -04:00
dependabot[bot]
b0f278bd97 Bump lodash from 4.17.15 to 4.17.19 (#1546)
Bumps lodash from 4.17.15 to 4.17.19.
2020-07-17 21:09:32 -04:00
Kevin Chung
12857797bb Fix deleting BaseChallenge subclasses by deleting the main Challenge model (#1549)
* Fix deleting `BaseChallenge` subclasses by deleting the main `Challenges` model during deletion
2020-07-17 12:55:44 -04:00
Kevin Chung
6c84a9fa19 3.0.0b1 (#1544)
* CTFd v3 beta
* Documentation extracted into its own repo
* Fix for dynamic challenge flag submission
2020-07-15 15:36:25 -04:00
Marcel Schnideritsch
323badd3ed Fix Challenge View (#1540)
* Closes #1542
2020-07-13 18:29:23 -04:00
Kevin Chung
1725e632cf 3.0.0a2 dev (#1528)
# 3.0.0a2 / 2020-07-09

**General**

* Accept additional profile fields during registration (affiliation, website, country)
  * This does not add additional inputs. Themes or additional JavaScript can add the form inputs.

**Admin Panel**

* Redesign the challenge creation form to use a radio button with challenge type selection instead of a select input

**API**

* Admins can no longer ban themselves through `PATCH /api/v1/users/[user_id]`

**Themes**

* Spinner centering has been switched from a hard coded margin in CSS to flexbox CSS classes from Bootstrap

**Plugins**

* Revert plugin menu (`register_admin_plugin_menu_bar`, `register_user_page_menu_bar`) changes to 2.x code

**Miscellaneous**

* Fix issue with `Configs.ctf_name` returning incorrect value
* Add prerender step back into challenges.js
* Better handling of missing challenge types. Missing challenge types no longer bring down all other challenges.
2020-07-09 13:40:35 -04:00
Koki Takahashi
1bccbf1fdd Fix challenge filter in /api/v1/statistics/challenges/solves (#1529)
* Fix showing hidden challenge solve count in admin statistics page
2020-07-06 16:26:00 -04:00
Kevin Chung
7dcfba40b3 Simple bugfix merges (#1531)
* Closes #1530 
* Clean up some wording and comments
* Pin isort version to fix flake8 issue (https://github.com/gforcada/flake8-isort/issues/88)
2020-07-06 15:34:55 -04:00
Kevin Chung
adc70fb320 3.0.0a1 (#1523)
Alpha release of CTFd v3. 

# 3.0.0a1 / 2020-07-01

**General**

- CTFd is now Python 3 only
- Render markdown with the CommonMark spec provided by `cmarkgfm`
- Render markdown stripped of any malicious JavaScript or HTML.
  - This is a significant change from previous versions of CTFd where any HTML content from an admin was considered safe.
- Inject `Config`, `User`, `Team`, `Session`, and `Plugin` globals into Jinja
- User sessions no longer store any user-specific attributes.
  - Sessions only store the user's ID, CSRF nonce, and an hmac of the user's password
  - This allows for session invalidation on password changes
- The user facing side of CTFd now has user and team searching
- GeoIP support now available for converting IP addresses to guessed countries

**Admin Panel**

- Use EasyMDE as an improved description/text editor for Markdown enabled fields.
- Media Library button now integrated into EasyMDE enabled fields
- VueJS now used as the underlying implementation for the Media Library
- Fix setting theme color in Admin Panel
- Green outline border has been removed from the Admin Panel

**API**

- Significant overhauls in API documentation provided by Swagger UI and Swagger json
- Make almost all API endpoints provide filtering and searching capabilities
- Change `GET /api/v1/config/<config_key>` to return structured data according to ConfigSchema

**Themes**

- Themes now have access to the `Configs` global which provides wrapped access to `get_config`.
  - For example, `{{ Configs.ctf_name }}` instead of `get_ctf_name()` or `get_config('ctf_name')`
- Themes must now specify a `challenge.html` which control how a challenge should look.
- The main library for charts has been changed from Plotly to Apache ECharts.
- Forms have been moved into wtforms for easier form rendering inside of Jinja.
  - From Jinja you can access forms via the Forms global i.e. `{{ Forms }}`
  - This allows theme developers to more easily re-use a form without having to copy-paste HTML.
- Themes can now provide a theme settings JSON blob which can be injected into the theme with `{{ Configs.theme_settings }}`
- Core theme now includes the challenge ID in location hash identifiers to always refer the right challenge despite duplicate names

**Plugins**

- Challenge plugins have changed in structure to better allow integration with themes and prevent obtrusive Javascript/XSS.
  - Challenge rendering now uses `challenge.html` from the provided theme.
  - Accessing the challenge view content is now provided by `/api/v1/challenges/<challenge_id>` in the `view` section. This allows for HTML to be properly sanitized and rendered by the server allowing CTFd to remove client side Jinja rendering.
  - `challenge.html` now specifies what's required and what's rendered by the theme. This allows the challenge plugin to avoid having to deal with aspects of the challenge besides the description and input.
  - A more complete migration guide will be provided when CTFd v3 leaves beta
- Display current attempt count in challenge view when max attempts is enabled
- `get_standings()`, `get_team_stanadings()`, `get_user_standings()` now has a fields keyword argument that allows for specificying additional fields that SQLAlchemy should return when building the response set.
  - Useful for gathering additional data when building scoreboard pages
- Flags can now control the message that is shown to the user by raising `FlagException`
- Fix `override_template()` functionality

**Deployment**

- Enable SQLAlchemy's `pool_pre_ping` by default to reduce the likelihood of database connection issues
- Mailgun email settings are now deprecated. Admins should move to SMTP email settings instead.
- Postgres is now considered a second class citizen in CTFd. It is tested against but not a main database backend. If you use Postgres, you are entirely on your own with regards to supporting CTFd.
- Docker image now uses Debian instead of Alpine. See https://github.com/CTFd/CTFd/issues/1215 for rationale.
- `docker-compose.yml` now uses a non-root user to connect to MySQL/MariaDB
- `config.py` should no longer be editting for configuration, instead edit `config.ini` or the environment variables in `docker-compose.yml`
2020-07-01 12:06:05 -04:00
Kevin Chung
9ca6270752 Bump codecov to 2.1.7 (#1524)
* Bump `codecov` to 2.1.7 to fix coverage reports
2020-06-30 13:20:49 -04:00
Frank
241467c4b3 [fix #1503] override_template cache error (#1505)
* Closes #1503 and fixes override_template
2020-06-22 14:23:02 -04:00
Kevin Chung
aad3d21568 Fix setting the CTFd theme color (#1482)
* Fix setting the CTFd theme color in the Admin Panel by properly getting the current theme header value
2020-06-08 13:55:51 -04:00
Kevin Chung
8b6e91f76c Scoreboard optimizations (#1476)
* Add speed improvements for /api/v1/scoreboard/top/<count>

* Update CHANGELOG

* Fix typo

* Switch back to processing solves and awards seperately

* Fix typo
2.5.0
2020-06-04 16:54:45 -04:00
Kevin Chung
56d7b6d6d0 Scoreboard optimizations (#1475)
* The top scoreboard endpoint `/api/v1/scoreboard/top/<count>` is now more performant (3x) due to better response generation

In local testing I went from 3.5s to 1.2s.
2020-06-04 14:46:36 -04:00
Kevin Chung
409473acc0 Python 2 has been removed from Alpine so install Python 3 deps in Alpine (#1473)
* Closes #1472 

```
docker build --no-cache -t ctfd .
docker run -p 8000:8000 -it ctfd
```
works for me
2020-06-04 10:17:57 -04:00
Kevin Chung
98bf240cc1 Improve response times of /api/v1/scoreboard significantly (#1470)
* Improve response times of `/api/v1/scoreboard` significantly by avoiding hitting the database to get every team member's score
* Fix issue where a hidden/banned user's score could be revealed as a member of a team

From tests I was able to cut this down from 11s to 0.5s. This endpoint also will still be heavily cached which should improve performance for a lot of users.
2020-06-04 02:37:10 -04:00
Kevin Chung
7cf6d2b43a 2.5.0 dev (#1453)
2.5.0 / 2020-06-02
==================

**General**
* Use a session invalidation strategy inspired by Django. Newly generated user sessions will now include a HMAC of the user's password. When the user's password is changed by someone other than the user the previous HMACs will no longer be valid and the user will be logged out when they next attempt to perform an action.
* A user and team's place, and score are now cached and invalidated on score changes.

**API**
* Add `/api/v1/challenges?view=admin` to allow admin users to see all challenges regardless of their visibility state
* Add `/api/v1/users?view=admin` to allow admin users to see all users regardless of their hidden/banned state
* Add `/api/v1/teams?view=admin` to allow admin users to see all teams regardless of their hidden/banned state
* The scoreboard endpoints `/api/v1/scoreboard` & `/api/v1/scoreboard/top/[count]` should now be more performant because score and place for Users/Teams are now cached

**Deployment**
* `docker-compose` now provides a basic nginx configuration and deploys nginx on port 80

**Miscellaneous**
* The `get_config` and `get_page` config utilities now use SQLAlchemy Core instead of SQLAlchemy ORM for slight speedups
* Update Flask-Migrate to 2.5.3 and regenerate the migration environment. Fixes using `%` signs in database passwords.
2020-06-02 11:22:01 -04:00
fjh1997
1a85658678 Update docker-compose.yml (#1443)
* Pin MariaDB to 10.4.12 in `docker-compose.yml`
2020-05-25 11:37:01 -04:00
Kevin Chung
d9a0d78b75 Mark 2.4.3 (#1440)
2.4.3 / 2020-05-24
==================

**Miscellaneous**
* Notifications/Events endpoint will now immediately send a ping instead of waiting a few seconds.
* Upgrade `gunicorn` dependency to `19.10.0`
* Upgrade `boto3` dependency to `1.13.9`
* Improve `import_ctf()` reliability by closing all connections before dropping & recreating database
* Close database session in IP tracking code in failure situations to avoid potential dangling database connections
* Don't allow backups to be imported if they do not have a `db` folder
* Change `import_ctf()` process slightly to import built-in tables first and then plugin tables
* Handle exception where a regex Flag is invalid

**API**
* File deletion endpoint (`DELETE /api/v1/files/[file_id]`) will now correctly delete the associated file

**Plugins**
* Add `CTFd.plugins.get_plugin_names()` to get a list of available plugins
* Add `CTFd.plugins.migrations.current()` to get the current revision of a plugin migration
* Improve `CTFd.plugins.migrations.upgrade()` to be able to upgrade to a specific plugin migration
* Run plugin migrations during import process

**Themes**
* Update jQuery to v3.5.1 to fix mobile hamburger menu
* Upgrade some dependencies in yarn lockfile
* Fix invalid team link being generated in `scoreboard.js`

**Admin Panel**
* Fix sending of user creation notification email
* Fix button to remove users from teams
2.4.3
2020-05-24 20:59:17 -04:00
Nomuken
a9bcaeffc7 fixed incorrect generating team link (#1439) 2020-05-24 16:18:13 -04:00
Kevin Chung
e643834a0c Fix button to remove users from teams in Admin Panel (#1437)
* Fix admin panel button to remove users from teams. 
* Add the data-href attribute to td as well as tr. 
* Closes #1435
2020-05-24 02:06:02 -04:00
Kevin Chung
80df88f25d Revert "Use a ThreadPoolExecutor to concurrently store files dut string import (#1427)" (#1428)
This reverts commit 2245df85f4.
2020-05-21 02:15:16 -04:00
Kevin Chung
2245df85f4 Use a ThreadPoolExecutor to concurrently store files during import (#1427)
* Use a `ThreadPoolExecutor` to concurrently store files during import
2020-05-20 22:03:35 -04:00
Kevin Chung
d3f8441993 Catch situation where Regex flag fails (#1426)
* Catch an exception where a user supplied regex Flag can fail to parse
* Starts on #1425
2020-05-20 19:24:58 -04:00
Kevin Chung
ba887e8952 1422 block imports without db folder (#1424)
* Don't allow backups to be imported if they do not have a `db` folder
* Closes #1422
2020-05-20 15:52:09 -04:00
Kevin Chung
5618f0d04c 1406 plugin migrations improvements (#1420)
* Handle plugin migrations during CTF import
* Closes #1406
2020-05-19 21:21:31 -04:00
Kevin Chung
148bdccf26 Improve import_ctf reliability (#1419)
* Improve `import_ctf()` reliability by closing all connections before dropping & recreating database
* Close database session in IP tracking code in failure situations
2020-05-18 11:46:15 -04:00
Kevin Chung
ac24b83a86 Update deps in yarn.lock to appease Github security alerts (#1417)
* Update deps in yarn.lock to appease Github security alerts
2020-05-18 03:02:21 -04:00
Kevin Chung
b3987f7ead Bump boto3 version to 1.13.9 and install pipdeptree for development (#1415)
* Bump boto3 version to 1.13.9
2020-05-14 15:01:02 -04:00
socketz
a8a7a983e3 fix: requirements.txt to reduce vulnerabilities (#1412)
* Upgrade gunicorn to version 19.10.0
2020-05-14 13:29:38 -04:00
Kevin Chung
03051e8d99 Fix user creation email notification (#1408)
* Fixes user creation email notification
* Closes #1398
2020-05-14 12:20:59 -04:00
Kevin Chung
7a3028857c Update jquery and rebuild assets (#1409)
* Update jQuery to v3.5.1 to fix mobile menu bar
* Closes #1401
2020-05-14 10:46:00 -04:00
Ernesto Serrano
912016f6f8 Fix file deletion. Related to #1393 (#1396)
* Delete files when the database reference is also deleted Related to #1393
2020-05-13 21:35:46 -04:00
Kevin Chung
2769dc6367 Have EventManagers yield before timer code to force SSE response head… (#1400)
* EventManagers should send an initial ping event to force `text/event-steam` header to be set
2020-05-13 19:33:01 -04:00
Kevin Chung
1a57a33fe7 Merge pull request #1391 from CTFd/mark-2.4.2
2.4.2 / 2020-05-08
==================

**Admin Panel**
* Fix Challenge Reset in Admin Panel where Dynamic Challenges prevented resetting Challenges

**Plugins**
* Add the `CTFd.plugins.migrations` module to allow plugins to handle migrations. Plugins should now call `CTFd.plugins.migrations.upgrade` instead of `app.db.create_all` which will allow the plugin to have database migrations.
* Make Dynamic Challenges have a cascading deletion constraint against their respective Challenge row

**Miscellaneous**
* Add `app.plugins_dir` object to refer to the directory where plugins are installed
2.4.2
2020-05-08 17:44:12 -04:00
Kevin Chung
b9fa46e411 Set right CHANGELOG date 2020-05-08 16:30:42 -04:00
Kevin Chung
ee28d33027 Add note about upgrade vs db.create_all 2020-05-08 16:30:18 -04:00
Kevin Chung
a987160cfb Mark v2.4.2 2020-05-08 16:27:14 -04:00
Kevin Chung
0ea25476dc Merge pull request #1388 from CTFd/1386-proper-deletion-constraint-for-dynamics
* Add cascading delete constraint to `DynamicChallenge` to help with Reset functionality
* Add a system for running migrations from within plugins
* Closes #1386
2020-05-08 16:19:27 -04:00
Kevin Chung
6f0c0b1a52 Add test for dynamic challenge reset 2020-05-07 12:27:04 -04:00
Kevin Chung
52d0c2719a Update migration 2020-05-07 11:23:48 -04:00
Kevin Chung
c04235a5d1 Fix some code and lints 2020-05-07 10:53:45 -04:00
Kevin Chung
b5fe079922 Create a migrations system for plugins 2020-05-06 22:23:22 -04:00
Kevin Chung
930da02231 Run formatter 2020-05-06 16:43:56 -04:00
Kevin Chung
364273f1f1 Add cascading delete constraint to DynamicChallenge 2020-05-06 12:46:51 -04:00
Kevin Chung
818a4568a3 Merge pull request #1385 from CTFd/mark-2.4.1
2.4.1 / 2020-05-06
==================

**Admin Panel**
* Fix issue where admins couldn't update the "Account Creation" email
* Fix issue where the Submissions page in the Admin Panel could not be paginated correctly

**Miscellaneous**
* Add `SQLALCHEMY_ENGINE_OPTIONS` to `config.py` with a slightly higher default `max_overflow` setting for `SQLALCHEMY_MAX_OVERFLOW`. This can be overridden with the `SQLALCHEMY_MAX_OVERFLOW` envvar
* Add `node_modules/` to `.dockerignore`
2.4.1
2020-05-06 01:00:23 -04:00
Kevin Chung
1d28016424 Mark v2.4.1 2020-05-05 23:33:06 -04:00