Commit Graph

956 Commits

Author SHA1 Message Date
Kevin Chung
aa225f8e15 Lint markdown and require markdown changes to pass prettier (#1510)
* Require that markdown files are linted by prettier
2020-06-24 14:04:10 -04:00
Kevin Chung
a61ff68458 API Documentation structure (#1480)
Implement a basic working idea for how to start adding better documentation on the REST API
* Works on #821
2020-06-24 10:59:17 -04:00
Kevin Chung
412692d49a Add current attempts and max attempts to challenge view (#1507)
* Display current attempts in challenge view when max attempts is enabled
* Closes #1477
2020-06-23 12:21:18 -04:00
Kevin Chung
84c02b11af Remove the persistent green outline in the admin panel and make it smaller in general (#1497)
* Closes #1495
2020-06-18 21:59:19 -04:00
Kevin Chung
0bd3130fc2 Switch from raw textareas to easymde for challenge/hint content (#1496)
* Convert textareas for hint content and challenge content into EasyMDE editors. 
* Works on #1493
2020-06-18 18:31:20 -04:00
Kevin Chung
74ff3b57a2 Remove lint step from test workflows 2020-06-18 18:06:46 -04:00
Kevin Chung
7a09aee0fa Bump travis dist to bionic 2020-06-18 17:56:43 -04:00
Kevin Chung
0c43e2dd0a Seperate out postgres tests and clarify postgres support (#1494)
* Clarifies the position on supporting Postgres and removes Postgres from the main test suite
* Closes #973
2020-06-17 03:14:47 -04:00
Kevin Chung
717da5cecb Reorganize challenge plugins (#1492)
* Convert Challenge plugin static methods into class methods
* Copy the create, read, update, attempt, solve, fail methods into the BaseChallenge class so that they can be re-used between challenge plugins
2020-06-15 00:02:55 -04:00
Kevin Chung
94bd8baca1 Update challenge plugins and flag plugins to have exception messages (#1491)
* Update challenge plugins and flag plugins to raise and catch exceptions for flag error messages
* Closes #1425
2020-06-14 17:01:23 -04:00
Kevin Chung
1143d751c8 929 better visibility constants (#1490)
* Adds Enums for visibility configs for better reusability. Old tests will continue to use the static values but new ones should use the enum values. 
* Closes #929
2020-06-14 04:15:55 -04:00
Kevin Chung
bacb8977a4 Switch main theme graphing library to echarts (#1487)
* Switches from Plotly to echarts. Saves file space and allows for more flexibility in graphing types. 
* Changes colorHash slightly to change color output for demo data. 
* Closes #1433
2020-06-13 12:18:41 -04:00
Kevin Chung
c3897f9527 1245 eslint linting (#1486)
* Adds `yarn lint` to `make lint`
* Closes #1245
2020-06-12 03:11:45 -04:00
Kevin Chung
a30437c1fa Get basic implementation of HTML sanitization working for pages (#1462)
* Closes #1332
* Pages by default now strip script tags and other potential XSS vectors
* lxml and html5lib are now pinned dependencies
* Challenge plugins rewritten to allow for better re-useability of template content and allow more control from the theme side
2020-06-12 01:10:27 -04:00
Kevin Chung
bd5e6d4552 1329 theme settings (#1485)
* Adds `window.init.theme_settings` which is a JSON blob that's passed by CTFd and configurable from the Admin Panel
* Adds `config.html` which should be a form which can be loaded into the Admin Panel and able to emit a JSON blob which can be used as `window.init.theme_settings`.
* Closes #1329
2020-06-12 00:09:56 -04:00
Kevin Chung
3095032536 Make get_standings more flexible by allowing to specify what other attributes to add into query. Closes #1020 (#1484)
* Make `get_standings` code more flexible by allowing to specify what other attributes to add into query. 
* Closes #1020
2020-06-11 15:24:38 -04:00
Kevin Chung
051dcb9263 Merge remote-tracking branch 'origin/master' into 3.0.0-dev 2020-06-11 14:24:57 -04:00
Kevin Chung
a47cdb7ce1 WIP: Add form globals (#1469)
* Work on #1467 
* Creates the Form global which will contain all forms.
2020-06-11 02:32:20 -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
62b5d4fc4e Remove adding email to user session 2020-06-06 23:52:04 -04:00
Kevin Chung
b2bf4eb542 Change expired session token error to be 401 2020-06-06 23:50:55 -04:00
Kevin Chung
9e39d18e52 Run yarn build 2020-06-06 22:09:50 -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
126f4a91e4 Fix broken tests 2020-06-03 13:25:30 -04:00
Kevin Chung
454845a234 Fix some tests 2020-06-03 12:41:28 -04:00
Kevin Chung
a162f295d1 Fix circular import 2020-06-03 11:06:31 -04:00
Kevin Chung
04b6fc070b Remove direct usage of Markup function 2020-06-03 10:52:52 -04:00
Kevin Chung
463fa97a61 Remove deprecated function usage 2020-06-03 10:49:05 -04:00
Kevin Chung
255b97498f Remove more legacy functions 2020-06-03 10:42:40 -04:00
Kevin Chung
52c65ced55 Remove keys from session and inject Session class into Jinja (#1456)
* Closes #1362
* Reduces the session object to just an id, nonce, and security hash
2020-06-03 02:09:48 -04:00
Kevin Chung
2a8d7ed349 Remove some attrs 2020-06-03 01:42:08 -04:00
Kevin Chung
e5ab35c8b0 Clean up login.html 2020-06-03 01:41:09 -04:00
Kevin Chung
69b24f75e8 Clean up register.html 2020-06-03 01:39:14 -04:00
Kevin Chung
423cbf8dc0 Remove usage of get_config in core theme 2020-06-03 01:15:45 -04:00
Kevin Chung
8313ccb443 1234 error components (#1465)
Start cleaning up a lot of the core theme. 
Extract pieces into components that can be included into overarching templates. 
Work on #1234
2020-06-03 00:17:18 -04:00
Kevin Chung
97f0beb9ca User pagination pages (#1464)
* Replace user facing pagination with Flask SQLAlchemy Pagination objects
* Closes #1353

I think this is a big improvement but I feel like this is harder to create a theme construct around.
2020-06-02 21:12:24 -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
Kevin Chung
d04ef66365 Closes #1307 2020-05-30 22:40:18 -04:00
Kevin Chung
0afd25ed39 1215 dockerfile improvements (#1461)
* Switch Dockerfile from alpine to debian. Switch entrypoint from sh to bash
* Closes #1215
2020-05-30 17:24:03 -04:00
Kevin Chung
712e43aea4 Closes #1027 (#1457)
* Closes #1027 
* Default to using the non-root user in `docker-compose`
2020-05-30 13:32:25 -04:00
Kevin Chung
76e5ad08a8 820 python 3 only (#1454)
* Remove Python 2 specific code
* Require imports to have a proper isort-supported order
* Only test/lint on Python 3
* Bump most dependencies to latest supported version
2020-05-30 02:43:49 -04:00
Kevin Chung
72be918e06 Remove yarn lint for now 2020-05-29 17:58:00 -04:00
Kevin Chung
3c151b9ebc Add yarn lint to make lint. Closes #1245 2020-05-29 17:14:16 -04:00
Kevin Chung
d88c529367 GFM without the tagfilter extension 2020-05-29 17:11:18 -04:00
Kevin Chung
48d6890cf7 Switch to only commonmark for now 2020-05-29 17:04:04 -04:00
Kevin Chung
ebcb35a395 Refer to right DispatcherMiddleware 2020-05-29 16:48:13 -04:00
Kevin Chung
256fd9725f Refer to correct DispatcherMiddleware 2020-05-29 16:45:06 -04:00