forked from CTFd/CTFd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 'master'
Update to 3.5.1 from upstream See merge request hackademint/ctfd!10
- Loading branch information
Showing
69 changed files
with
1,283 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Reports | ||
reports/* | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
stages: | ||
- linting | ||
- dependencies | ||
- lint | ||
- test | ||
- sast | ||
- containerize | ||
|
||
variables: | ||
|
@@ -10,94 +12,217 @@ variables: | |
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE | ||
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY | ||
MYSQL_ROOT_PASSWORD: password | ||
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" | ||
YARN_CACHE_FOLDER: "$CI_PROJECT_DIR/.cache/yarn" | ||
SAST_EXCLUDED_PATHS: "spec, test, tests, tmp, populate.py" | ||
|
||
dockerfile: | ||
stage: linting | ||
include: | ||
- template: Security/SAST.gitlab-ci.yml | ||
|
||
python dependencies: | ||
stage: dependencies | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
script: | ||
- pip install virtualenv | ||
- virtualenv venv | ||
- source venv/bin/activate | ||
- python -m pip install --upgrade pip | ||
- python -m pip install -r development.txt | ||
artifacts: | ||
name: Python virtual environment | ||
paths: | ||
- venv | ||
expire_in: 24 hours | ||
cache: | ||
- key: pip-cache | ||
paths: | ||
- "$PIP_CACHE_DIR" | ||
- key: yarn-cache | ||
paths: | ||
- "$YARN_CACHE_FOLDER" | ||
|
||
node dependencies: | ||
stage: dependencies | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
script: | ||
- yarn install --non-interactive | ||
artifacts: | ||
name: Node modules | ||
paths: | ||
- node_modules | ||
expire_in: 24 hours | ||
|
||
lint dockerfile: | ||
stage: lint | ||
image: hadolint/hadolint:latest-debian | ||
needs: [] | ||
script: | ||
- mkdir -p reports | ||
- hadolint -f gitlab_codeclimate Dockerfile > reports/hadolint-$(md5sum Dockerfile | cut -d" " -f1).json | ||
artifacts: | ||
name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" | ||
reports: | ||
codequality: | ||
- "reports/*" | ||
paths: | ||
- "reports/*" | ||
|
||
docker-compose: | ||
stage: linting | ||
lint docker-compose: | ||
stage: lint | ||
image: python:3.9.13-bullseye | ||
needs: [] | ||
script: | ||
- python -m pip install docker-compose==1.26.0 | ||
- docker-compose -f docker-compose.yml config | ||
|
||
postgres: | ||
flake8: | ||
stage: lint | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
dependencies: | ||
- python dependencies | ||
needs: | ||
- python dependencies | ||
script: | ||
- source venv/bin/activate | ||
- flake8 --ignore=E402,E501,E712,W503,E203 --exclude=CTFd/uploads CTFd/ migrations/ tests/ | ||
|
||
black: | ||
stage: lint | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
dependencies: | ||
- python dependencies | ||
needs: | ||
- python dependencies | ||
script: | ||
- source venv/bin/activate | ||
- black --check --diff --exclude=CTFd/uploads --exclude=node_modules . | ||
|
||
yarn lint: | ||
stage: lint | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
dependencies: | ||
- node dependencies | ||
needs: | ||
- node dependencies | ||
script: | ||
- yarn lint | ||
|
||
prettier: | ||
stage: lint | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
dependencies: | ||
- node dependencies | ||
needs: | ||
- node dependencies | ||
script: | ||
- yarn global add [email protected] | ||
- prettier --check 'CTFd/themes/**/assets/**/*' | ||
- prettier --check '**/*.md' | ||
|
||
.pytest: | ||
stage: test | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
dependencies: | ||
- python dependencies | ||
needs: | ||
- python dependencies | ||
- node dependencies | ||
- flake8 | ||
- black | ||
script: | ||
- source venv/bin/activate | ||
- rm -f /etc/boto.cfg | ||
- | | ||
pytest -rf --cov=CTFd --cov-context=test --cov-report=xml:reports/coverage/${DB_DRIVER}pytest.xml \ | ||
--junitxml=reports/tests/pytest.xml \ | ||
--ignore-glob="**/node_modules/" \ | ||
--ignore=node_modules/ \ | ||
-W ignore::sqlalchemy.exc.SADeprecationWarning \ | ||
-W ignore::sqlalchemy.exc.SAWarning \ | ||
-n auto | ||
artifacts: | ||
reports: | ||
coverage_report: | ||
coverage_format: cobertura | ||
path: "reports/coverage/*.xml" | ||
junit: "reports/tests/*.xml" | ||
|
||
postgres: | ||
extends: .pytest | ||
timeout: 24 hours | ||
services: | ||
- postgres:latest | ||
- redis:latest | ||
- postgres:latest | ||
variables: | ||
TESTING_DATABASE_URL: postgres://postgres:password@postgres:5432/ctfd | ||
script: | ||
- python -m pip install --upgrade pip | ||
- python -m pip install -r development.txt | ||
- yarn install --non-interactive | ||
- rm -f /etc/boto.cfg | ||
- make test | ||
artifacts: | ||
paths: | ||
- coverage.xml | ||
DB_DRIVER: "postgres" | ||
when: manual | ||
|
||
mysql: | ||
stage: test | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
extends: .pytest | ||
timeout: 24 hours | ||
services: | ||
- mysql:5.7 | ||
- redis:latest | ||
variables: | ||
TESTING_DATABASE_URL: mysql+pymysql://root:password@mysql:3306/ctfd | ||
script: | ||
- python -m pip install --upgrade pip | ||
- python -m pip install -r development.txt | ||
- yarn install --non-interactive | ||
- rm -f /etc/boto.cfg | ||
- make test | ||
artifacts: | ||
paths: | ||
- coverage.xml | ||
DB_DRIVER: "mysql" | ||
when: manual | ||
|
||
sqlite: | ||
stage: test | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
extends: .pytest | ||
timeout: 15 minutes | ||
services: | ||
- mysql:5.7 | ||
- redis:latest | ||
variables: | ||
TESTING_DATABASE_URL: 'sqlite://' | ||
DB_DRIVER: "sqlite" | ||
|
||
bandit: | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
dependencies: | ||
- python dependencies | ||
needs: | ||
- python dependencies | ||
- flake8 | ||
- black | ||
script: | ||
- python -m pip install --upgrade pip | ||
- python -m pip install -r development.txt | ||
- yarn install --non-interactive | ||
- yarn global add [email protected] | ||
- rm -f /etc/boto.cfg | ||
- make test | ||
artifacts: | ||
paths: | ||
- coverage.xml | ||
- source venv/bin/activate | ||
- bandit -r CTFd -x CTFd/uploads --skip B105,B322 | ||
|
||
yarn verify: | ||
image: nikolaik/python-nodejs:python3.9-nodejs18 | ||
dependencies: | ||
- node dependencies | ||
needs: | ||
- node dependencies | ||
- yarn lint | ||
- prettier | ||
script: | ||
- yarn verify | ||
|
||
sast: | ||
dependencies: | ||
- python dependencies | ||
- node dependencies | ||
needs: | ||
- python dependencies | ||
- node dependencies | ||
|
||
containerize: | ||
stage: containerize | ||
image: | ||
name: gcr.io/kaniko-project/executor:debug | ||
entrypoint: [""] | ||
needs: | ||
- sqlite | ||
- lint dockerfile | ||
- bandit | ||
- yarn verify | ||
script: | ||
- | | ||
if [[ "${CI_COMMIT_BRANCH}" != "${CI_DEFAULT_BRANCH}" ]]; | ||
then | ||
SUFFIX="/${CI_COMMIT_REF_SLUG}" | ||
fi | ||
- mkdir -p /kaniko/.docker | ||
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json | ||
- >- | ||
/kaniko/executor | ||
--context "${CI_PROJECT_DIR}" | ||
--dockerfile "${CI_PROJECT_DIR}/Dockerfile" | ||
--destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" | ||
--destination "${CI_REGISTRY_IMAGE}${SUFFIX}:${CI_COMMIT_TAG}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.