例:GitLabにスキャンを組み込む
GitLabにContrast Scanを組み込む前にスキャンのインテグレーション手順について確認してください。
ここでは、GitLabパイプラインを設定して以下の処理を行う例をご紹介します。
リポジトリからコードをプル(pull)
GitLabをコードリポジトリとして使用している場合は、この処理は必要がない場合があります。
コードをビルド
生成されたJARファイルをスキャン
パイプラインの設定例
以下は、GitLabパイプラインを設定するためのサンプルのYAMLファイルです。
stages: # List of stages for jobs, and their order of execution
- pull
- build
- scan
# - deploy
pull:
stage: pull
artifacts:
paths:
- WebGoat
script:
- git clone -b main https://github.com/WebGoat/WebGoat.git
build:
stage: build
image: maven:3.8.1-openjdk-17-slim
artifacts:
paths:
- $CI_PROJECT_DIR
dependencies:
- pull
script:
- ls -l /tmp
- cd WebGoat
- mvn -DskipTests clean install
scan: # This is the step for Contrast Scan
stage: scan
image: node:18.19-slim
dependencies:
- build
script:
- ls -la
- npm install -g @contrast/contrast@latest
- contrast version
- contrast auth --api-key $API_KEY --authorization $AUTH --organization-id $ORG_ID --host $URL
- contrast scan -f $CI_PROJECT_DIR/WebGoat/target/webgoat-2023.7.jar --fail --severity high
deploy: #TODO