Skip to content
Snippets Groups Projects
Commit 1bc791d6 authored by Torma Kristóf's avatar Torma Kristóf :alien:
Browse files

Configure SAST in `.gitlab-ci.yml`, creating this file if it does not already exist

parent 46904968
No related branches found
No related tags found
1 merge request!13Configure SAST in `.gitlab-ci.yml`, creating this file if it does not already exist
Pipeline #43309 passed
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
image: python:3.11 image: python:3.11
#services:
# - postgres:13
variables: variables:
POSTGRES_DB: kszkepzes POSTGRES_DB: kszkepzes
CONTAINER_IMAGE: 'harbor.sch.bme.hu/kszk/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME' CONTAINER_IMAGE: harbor.sch.bme.hu/kszk/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME
cache: cache:
key: '$CI_JOB_NAME-$CI_COMMIT_REF_SLUG' key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths: paths:
- .cache/pip - ".cache/pip"
- env/ - env/
stages: stages:
- Test and Flake8 - Test and Flake8
- Docker Build - Docker Build
- deploy - deploy
- test
Flake8: Flake8:
stage: Test and Flake8 stage: Test and Flake8
only: only:
- dev - dev
- master - master
- tags - tags
tags: [kszk] tags:
- kszk
script: script:
- python -V - python -V
- python3 -m venv env - python3 -m venv env
- source env/bin/activate - source env/bin/activate
- pip install -r requirements/production.txt - pip install -r requirements/production.txt
- flake8 --max-line-length=125 --exclude=src/kszkepzes,migrations,env - flake8 --max-line-length=125 --exclude=src/kszkepzes,migrations,env
# TODO write tests
# Test:
# stage: Test and Flake8
# only:
# - dev
# - master
# tags: [kszk]
# variables:
# DATABASE_URL: 'postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB'
# SECRET_KEY: 'secret'
# AUTHSCH_KEY: 'secret'
# AUTHSCH_SECRET: 'secret'
# script:
# - python -V
# - python3 -m venv env
# - source env/bin/activate
# - pip install -r requirements/production.txt
# - python src/manage.py test
Docker build to KSZK registry: Docker build to KSZK registry:
stage: Docker Build stage: Docker Build
tags: [kszk] tags:
- kszk
only: only:
- tags - tags
image: image:
name: gcr.io/kaniko-project/executor:debug name: gcr.io/kaniko-project/executor:debug
entrypoint: [''] entrypoint:
- ''
script: script:
- echo "{\"auths\":{\"harbor.sch.bme.hu\":{\"username\":\"$REGISTRY_USER\",\"password\":\"$REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - echo "{\"auths\":{\"harbor.sch.bme.hu\":{\"username\":\"$REGISTRY_USER\",\"password\":\"$REGISTRY_PASSWORD\"}}}"
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CONTAINER_IMAGE > /kaniko/.docker/config.json
- "/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile
--destination $CONTAINER_IMAGE"
Deploy to Kubernetes: Deploy to Kubernetes:
stage: deploy stage: deploy
image: alpine image: alpine
tags: [kszk] tags:
- kszk
environment: environment:
name: master name: master
before_script: before_script:
...@@ -79,9 +65,14 @@ Deploy to Kubernetes: ...@@ -79,9 +65,14 @@ Deploy to Kubernetes:
script: script:
- cd k8s - cd k8s
- sed -i "s|##IMAGETAG##|${CI_COMMIT_REF_NAME}|" deployment.yml - sed -i "s|##IMAGETAG##|${CI_COMMIT_REF_NAME}|" deployment.yml
# A kovetkezo ket sor egy undorito workaround a mindig valtozo init kontenerek miatt letrejovo es beakado replicasetek miatt. Pls replace, ha van jobb otlet. - kubectl delete deployment --namespace=devteam-kszk-bme-hu apache-kszkepzes ||
- kubectl delete deployment --namespace=devteam-kszk-bme-hu apache-kszkepzes || true true
- kubectl delete deployment --namespace=devteam-kszk-bme-hu kszkepzes-backend || true - kubectl delete deployment --namespace=devteam-kszk-bme-hu kszkepzes-backend ||
true
- kubectl apply -f deployment.yml - kubectl apply -f deployment.yml
only: only:
- tags - tags
sast:
stage: test
include:
- template: Security/SAST.gitlab-ci.yml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment