Commit Graph

209 Commits

Author SHA1 Message Date
Kevin Chung
e4b91dfe58 Add test for num_user limit via MLC 2023-06-13 20:53:07 -04:00
Kevin Chung
5d055f60f6 Add test for user limit registration behavior 2023-06-13 20:02:15 -04:00
Alper Berber
23c7b2f90f use ruff instead of flake8 (#2278)
* add: use ruff instead of flake8

* Update ruff switches and remove flake8 plugins

* fix: ignore linting rules

* fix: ignore I001

* fix: spaces before noqa

---------

Co-authored-by: Kevin Chung <kchung@ctfd.io>
2023-04-11 11:20:48 -04:00
Kevin Chung
b17adaf7aa Add support for robots.txt (#2269)
* Adds support for admins to control `robots.txt`
* Closes #2141
2023-03-12 17:03:35 -04:00
Kevin Chung
d89ac579f2 Cache challenge data for faster loading of /api/v1/challenges (#2232)
* Improve response time of `/api/v1/challenges` and `/api/v1/challenges/[challenge_id]/solves`
* Rewrite and remove _build_solves_query to make it cacheable
* Closes #2209
2022-12-05 00:10:30 -05:00
Kevin Chung
a085d0922a Fix issue with scoreboard ordering when an award results in a tie (#2212)
* Fix issue with scoreboard ordering when an award results in a tie
* Closes #833
2022-11-02 16:56:23 -04:00
Smyler
eb66034aae Add S3 region support (#2188)
Co-authored-by: Smyler <smyler@hackademint.org>
2022-09-30 03:46:47 -04:00
Janos Bonic
02c08f50cc Redirect users to team creation before event start (#2185)
* Redirect users to the team creation page if they access a during_ctf_time_only page before the CTF starts
2022-09-23 00:35:43 -04:00
Kevin Chung
e0290cc67b Notifications improvements (#2166)
* Improve event `ping`s to actually include data so that they show up in devtools
* Improve Event publishers to take an `id` parameter that is sent to the browser
* Add a `since_id` parameter to `GET /api/v1/notifications` to get Notifications that have happened since a specific ID
* Add `HEAD /api/v1/notifications` to get a count of notifications that have happened. This also includes a `since_id` parameter to allow for a notification cursor.
2022-08-15 17:35:01 -04:00
Aides2593
3b39a9e679 Hidden admin team by default (#2150)
* When admins create teams in the normal creation flow, the team will be hidden by default
* Closes #2144
2022-06-29 14:03:05 -04:00
Kevin Chung
1bdd30606f Improve reliability of test_previewing_page_with_format_works test (#2110) 2022-05-03 19:22:06 -04:00
Kevin Chung
d2b2d7d880 Add teamId and teamName to base.html (#2106)
- Add `teamId` and `teamName` to the CTFd init object in `base.html` for easier integration with other JavaScript code
2022-05-03 05:00:28 -04:00
Kevin Chung
90e81d7298 Fix page preview so that it accounts for the provided format (#2091)
* Fix page preview so that it accounts for the provided format
* Closes #2089
2022-04-15 15:17:33 -04:00
Kevin Chung
0c6e28315c Add userName and userEmail to init objects in base.html (#2082)
* Add `userName` and `userEmail` to the CTFd init object in `base.html`
* Closes #2066
2022-04-08 15:14:57 -04:00
Kevin Chung
00bb891457 Add code to check for the potential of session ID duplication during ID generation (#2075)
* Add code to check for the potential of session ID duplication during ID generation
2022-03-29 17:17:59 -04:00
Kevin Chung
fc7516c91f Show admins the email server error message when email sending fails (#2073)
* Show admins the email server error message when email sending fails
2022-03-24 14:14:55 -04:00
Kevin Chung
262d896a0e Mark 3.4.3 (#2063)
# 3.4.3 / 2022-03-07

**Security**

- Bump cmarkgfm to 0.8.0 to resolve CVE-2022-24724. Copied entry from 3.4.2 since 3.4.2 introduced a bug that prevented writing raw HTML.

**General**

- Fix issue where raw HTML would not be rendered in markdown
2022-03-07 19:00:52 -05:00
Allen Guan
a868faffb5 Fix download with auth token fail after ctf (458ce2e) (#2011)
* Fix issue where unauthed users couldn't download challenge files after CTF end but viewing after CTF was enabled
2022-03-06 21:25:46 -05:00
Connor Tumbleson
3e6f635b7b #2003 - All numeric registration codes (#2004)
* fix: cast registration_code to string during register

* test: add test to confirm numeric registration codes
2021-10-11 00:33:06 -04:00
Kevin Chung
94c4441aae Set THEME_FALLBACK to default to true (#1971)
* CTFd now has the `THEME_FALLBACK` option enabled by default. This allows users to provide incomplete themes. Missing theme files will be provided from the built-in core theme
* Closes #1967
2021-08-05 01:04:05 -04:00
Kevin Chung
27d862ab29 Challenge Topics (#1966)
* Closes #1897 
* Adds Topics to Challenges where Topics are admin-only visible tags about challenges
* Adds `/api/v1/topics` and `/api/v1/challenges/[challenge_id]/topics` to API 
* Challenge comments have been moved into a modal
2021-07-30 00:03:16 -04:00
Kevin Chung
22a0c0b007 Add a decorator for redirecting users if their profile isn't complete (#1933)
* Redirect users and teams whose profiles are incomplete to complete their profile
* Closes #1926
2021-07-29 02:11:54 -04:00
Kevin Chung
f8f32042f8 WIP: Add registration password (#1946)
* Closes #1895 
* Add a registration password to account creation (ignoring SSO or API based account creation)
2021-07-18 05:21:14 -04:00
Kevin Chung
58dfe15fe6 Validate that a user can't patch their team id (#1947)
* Prevent users from PATCH'ing their team id
2021-07-15 12:11:30 -04:00
Kevin Chung
8c564681bb Add a fix for receiving non-string Config values (#1931)
* Properly receive non-string config values (None, bool, integers, etc) in /api/v1/config
* Closes #1928 
* Fix the response schema for `PATCH /api/v1/configs/<config_key>` in error situations

Overall we weren't particularly strict before and we should try to stay a little lax so we don't break anything.
2021-07-01 22:00:57 -04:00
Kevin Chung
61507bb12a Add CSV importing feature (#1922)
* Closes #1888 
* Adds code to import CSVs for challenges, users, and teams
2021-06-26 18:04:14 -04:00
Kevin Chung
31e8261bad Add a way to access the challenge plugin class from the Challenges model (#1925)
* Add a way to access the challenge plugin class from the Challenges model
   * Allows templates to access the plugin class more easily
   * Allows plugins to access the plugin class without having to load the class explicitly
* Closes #1879
2021-06-26 15:03:18 -04:00
Ife Lawal
08ff0f2ed6 Show length error when Configs provided are too long (#1920)
* Show an error when a config is too long
2021-06-26 00:04:36 -04:00
Chris Frohoff
dd05f57b6a Limit total number of teams (#1867)
* Adds support for a total teams limit
2021-06-25 23:00:40 -04:00
Kevin Chung
df27d0e7a9 Flip value and initial for dynamic challenges to better support ctfcli (#1921)
* Makes the initial value for a dynamic challenge provided by the `initial` argument instead of the `value` argument. This makes it easier to support ctfcli. Refer to https://github.com/CTFd/ctfcli/issues/13. 
* Closes #1875
2021-06-18 19:13:55 -04:00
Ife Lawal
f00e69d619 Ctftime test context #928 (#1866)
Works on #928
2021-04-26 14:31:19 -04:00
Frank
5976830957 use different directories for different tests (#1864) 2021-04-12 17:33:46 -04:00
Kevin Chung
d23f59dbd5 Fix issue where admins couldn't see some challenges in the add requirements interface (#1853)
- Fix an issue where admins couldn't see challenges which had requirements in the add requirements interface
2021-03-27 19:59:10 -04:00
Kevin Chung
7fa9f2f56e fix: Ensure hidden users see their own solves (#1840) (#1846)
* Closes #1839

Co-authored-by: maybe-sybr <58414429+maybe-sybr@users.noreply.github.com>
2021-03-24 13:24:28 -04:00
Kevin Chung
8de9819bd4 3.3.0 (#1833)
# 3.3.0 / UNRELEASED

**General**

- Don't require a team for viewing challenges if Challenge visibility is set to public
- Add a `THEME_FALLBACK` config to help develop themes. See **Themes** section for details.

**API**

- Implement a faster `/api/v1/scoreboard` endpoint in Teams Mode
- Add the `solves` item to both `/api/v1/challenges` and `/api/v1/challenges/[challenge_id]` to more easily determine how many solves a challenge has
- Add the `solved_by_me` item to both `/api/v1/challenges` and `/api/v1/challenges/[challenge_id]` to more easily determine if the current account has solved the challenge
- Prevent admins from deleting themselves through `DELETE /api/v1/users/[user_id]`
- Add length checking to some sensitive fields in the Pages and Challenges schemas
- Fix issue where `PATCH /api/v1/users[user_id]` returned a list instead of a dict
- Fix exception that occured on demoting admins through `PATCH /api/v1/users[user_id]`
- Add `team_id` to `GET /api/v1/users` to determine if a user is already in a team

**Themes**

- Add a `THEME_FALLBACK` config to help develop themes.
  - `THEME_FALLBACK` will configure CTFd to try to find missing theme files in the default built-in `core` theme.
  - This makes it easier to develop themes or use incomplete themes.
- Allow for one theme to reference and inherit from another theme through approaches like `{% extends "core/page.html" %}`
- Allow for the automatic date rendering format to be overridden by specifying a `data-time-format` attribute.
- Add styling for the `<blockquote>` element.
- Fix scoreboard table identifier to switch between User/Team depending on configured user mode
- Switch to using Bootstrap's scss in `core/main.scss` to allow using Bootstrap variables
- Consolidate Jinja error handlers into a single function and better handle issues where error templates can't be found

**Plugins**

- Set plugin migration version after successful migrations
- Fix issue where Page URLs injected into the navbar were relative instead of absolute

**Admin Panel**

- Add User standings as well as Teams standings to the admin scoreboard when in Teams Mode
- Add a UI for adding members to a team from the team's admin page
- Add ability for admins to disable public team creation
- Link directly to users who submitted something in the submissions page if the CTF is in Teams Mode
- Fix Challenge Requirements interface in Admin Panel to not allow empty/null requirements to be added
- Fixed an issue where config times (start, end, freeze times) could not be removed
- Fix an exception that occurred when demoting an Admin user
- Adds a temporary hack for re-enabling Javascript snippets in Flag editor templates. (See #1779)

**Deployment**

- Install `python3-dev` instead of `python-dev` in apt
- Bump lxml to 4.6.2
- Bump pip-compile to 5.4.0

**Miscellaneous**

- Cache Docker builds more by copying and installing Python dependencies before copying CTFd
- Change the default emails slightly and rework confirmation email page to make some recommendations clearer
- Use `examplectf.com` as testing/development domain instead of `ctfd.io`
- Fixes issue where user's name and email would not appear in logs properly
- Add more linting by also linting with `flake8-comprehensions` and `flake8-bugbear`
2021-03-18 18:08:46 -04:00
Kevin Chung
8a70d9527f Relax team requirement when challenges are publicly visible (#1832)
* Don't require a team for viewing challenges if Challenge visibility is set to public
* Closes #1831
2021-03-18 02:35:03 -04:00
Kevin Chung
e5dbd62a66 Fix frontend UI where empty/null requirements could be added (#1824)
* Fix Challenge Requirements interface in Admin Panel to not allow empty/null requirements to be added
* Closes #1809
2021-03-16 19:03:55 -04:00
Kevin Chung
843546bfa8 Switch default testing/development domain name to examplectf.com (#1807)
* Use `examplectf.com` as testing/development domain instead of `ctfd.io`
2021-02-20 15:11:22 -05:00
Kevin Chung
5611c47487 1002 improve email content (#1804)
* Change the default emails slightly and rework confirmation email page to make some recommendations clearer
* Works a little more on #1002
2021-02-18 16:09:10 -05:00
Kevin Chung
5c9b3e7070 Add team creation disable configuration (#1802)
* Add ability for admins to disable public team creation
* Closes #1364
2021-02-12 18:26:03 -05:00
Kevin Chung
fa7316722e Fix exception occuring on Admin demotion (#1799)
* Fix an exception that occurred when demoting an Admin user
* Fix the response from the above request from returning a list instead of a dict
* Closes #1794
2021-02-09 04:03:04 -05:00
Kevin Chung
0a5a886ac6 Fix issue where page URLs were relative (#1798)
* Fix issue where Page URLs were relative in the navbar
* Closes #1797
2021-02-09 03:03:17 -05:00
Kevin Chung
9374c2a0a8 Mark 3.2.1 (#1757)
# 3.2.1 / 2020-12-09

- Fixed an issue where Users could not unlock hints
2020-12-09 14:53:19 -05:00
Kevin Chung
cb5ba26bdb Miscellaneous Fixes (#1752)
* Update CHANGELOG 
* Add `registered_only` decorator
* Make team invites redirect to `/register` if you're unauthed
2020-12-04 14:10:36 -05:00
Kevin Chung
d9975f307c Mark 3.2.0 (#1748)
# 3.2.0 / unreleased

**General**

- Add Team invites.
  - Team invites are links containing a token that allow a user to join a team without knowing the team password
  - Captains can generate invite tokens for their teams
  - Admins can generate Team invite links as well
- Improved Team handling
  - Prevent team joining while already on a team
  - Return 403 instead of 200 for team join/create errors
  - Allow team captains whose teams haven't done anything to disband their team
- Allow for uploading navbar logo, favicon, and index page banner during initial setup
- Fixed issue in teams mode where a user couldn't unlock a hint despite their team having enough points
  - The fix for this is essentially to allow the user's points to go negative
- Imports have been made more stable
  - This is primarily done by killing MySQL processes that are locking metadta
  - This is a subpar approach but it seems to be the only solution to avoid a metadata lock in MySQL. This approach did not appear to be needed under Postgres or SQLite
- Update some migrations to first check if a table already exists.

**API**

- Addition of `POST /api/v1/teams/me/members` to generate invite tokens for teams
- Fixed an issue in `POST /api/v1/awards` where CTFd would 500 when a user could not be found by the provided `user_id`
- `POST /api/v1/unlocks` in teams mode now uses the team's score to determine if a user can purchase a hint
  - Properly check for existing unlocks in teams mode in `POST /api/v1/unlocks`
- `/api/v1/notifications` and `/api/v1/notifications/[notification_id]` now have an html parameter which specifies the rendered content of the notification content

**Themes**

- Added syntax highlighting to challenge descriptions, pages, hints, notifications, comments, and markdown editors
  - This is done with `highlight.js` which has been added to `package.json`
- Fix notifications to properly fix/support Markdown and HTML notifications
  - Notifications SQL Model now has an html propery
  - Notifications API schemas now has an html field
- Removed MomentJS (see https://momentjs.com/docs/#/-project-status/) in favor of dayjs
  - dayjs is mostly API compatible with MomentJS. The only major changes were:
    - dayjs always uses browser local time so you don't need to call `.local()`
    - dayjs segments out some MomentJS functionality into plugins which need to be imported in before using those features
- Fixed issue in `challenge.html` where the current attempt count would have a typo
- Fixed issue in `challenge.html` where the max attempts for a challenge would not show if it was set to 1
- Edit donut charts to have easier to read legends and labels
- Make data zoom bars thinner and more transparent

**Plugins**

- Don't run `db.create_all()` as much during plugin upgrade or during imports
  - By avoiding this we can let alembic and migrations do more of the table creation work but this means that plugins specifically opt into `app.db.create_all()` and will not implicitly get it through `upgrade()`.
  - This means plugins that run `upgrade()` without a migrations folder (no idea who would do this really) will need to upgrade their code.

**Admin Panel**

- Add Favicon uploading to the Admin Panel
- Move Logo uploading to the Theme tab in the Admin Panel
- The challenge left side bar tabs have been rewritten into VueJS components.
  - This fixes a number of issues with the consistency of what data is deleted/edited in the challenge editor
  - This also prevents having to refresh the page in most challenge editing situations
- Fixed a possible bug where the update available alert wouldn't go away on server restart
- Examples for regex flags are now provided
- Wrong submissions has been renamed to Incorrect Submissions
- Graphs in the Admin Statistics page will now scroll with mouse wheel to improve browsing large datasets

**Deployment**

- A restart policy set to `always` has been added to nginx in docker-compose
- Rename `requirements.txt` to `requirements.in` and generate `requirements.txt` using `pip-tools` under Python 3.6
- `UPLOAD_PROVIDER` no longer has a default `filesystem` set in config.ini. Instead it is defaulted through `config.py`

**Miscellaneous**

- The `psycopg2` dependency in development.txt has been removed in favor of `psycopg2-binary` which was updated to 2.8.6
- The `moto` dependency in development.txt has been updated to 1.3.16
- Add `pip-tools` to `development.txt`
- Add `import_ctf` and `export_ctf` commands to `manage.py` and deprecate `import.py` and `export.py`
- Override the `MAIL_SERVER` config with the `TESTING_MAIL_SERVER` envvar during tests
- `ping` events in the notification event handler have been fixed to not send duplicates
2020-12-01 16:09:31 -05:00
Kevin Chung
af1c325371 Improved Team Handling (#1713)
* Prevent team joining while already on a team
* Return 403 instead of 200 for team join/create errors
* Allow team captains whose teams haven't done anything to disband their team
* Closes #1588
2020-11-23 02:35:46 -05:00
Kevin Chung
9264e96428 Mark 3.1.0 (#1634)
# 3.1.0 / 2020-09-08

**General**

- Loosen team password confirmation in team settings to also accept the team captain's password to make it easier to change the team password
- Adds the ability to add custom user and team fields for registration/profile settings.
- Improve Notifications pubsub events system to use a subscriber per server instead of a subscriber per browser. This should improve the reliability of CTFd at higher load and make it easier to deploy the Notifications system

**Admin Panel**

- Add a comments functionality for admins to discuss challenges, users, teams, pages
- Adds a legal section in Configs where users can add a terms of service and privacy policy
- Add a Custom Fields section in Configs where admins can add/edit custom user/team fields
- Move user graphs into a modal for Admin Panel

**API**

- Add `/api/v1/comments` to manipulate and create comments

**Themes**

- Make scoreboard caching only cache the score table instead of the entire page. This is done by caching the specific template section. Refer to #1586, specifically the changes in `scoreboard.html`.
- Add rel=noopener to external links to prevent tab napping attacks
- Change the registration page to reference links to Terms of Service and Privacy Policy if specified in configuration

**Miscellaneous**

- Make team settings modal larger in the core theme
- Update tests in Github Actions to properly test under MySQL and Postgres
- Make gevent default in serve.py and add a `--disable-gevent` switch in serve.py
- Add `tenacity` library for retrying logic
- Add `pytest-sugar` for slightly prettier pytest output
- Add a `listen()` method to `CTFd.utils.events.EventManager` and `CTFd.utils.events.RedisEventManager`.
  - This method should implement subscription for a CTFd worker to whatever underlying notification system there is. This should be implemented with gevent or a background thread.
  - The `subscribe()` method (which used to implement the functionality of the new `listen()` function) now only handles passing notifications from CTFd to the browser. This should also be implemented with gevent or a background thread.
2020-09-08 00:08:35 -04:00
Kevin Chung
976b191b53 Fix submission search (#1605)
* Fix submission searching in Admin Panel
2020-08-14 12:20:41 -04:00
Kevin Chung
5d7e0e39c7 1580 fix hidden admin scores (#1581)
* Fix issue where admins could not see user graphs/api data if score visibility was set to hidden
* Closes #1580
2020-08-04 13:23:46 -04:00
Kevin Chung
dc3a4d275b Fix issue with previewing certain pages (#1571)
* Fix previewing pages when page attributes are set
2020-07-24 14:52:35 -04:00