Skip to content

Snyk Demo using GithubActions - no Terraform #7

Snyk Demo using GithubActions - no Terraform

Snyk Demo using GithubActions - no Terraform #7

name: Snyk Demo using GithubActions - no Terraform
#on:
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
on:
workflow_dispatch:
inputs:
name:
description: 'name of the Snyk team'
required: true
default: 'Snyk TSM APJ'
country:
description: 'Country'
required: false
jobs:
test_appcode:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: build appcode
run: mvn install
- name: execute automated tests
run: echo "running automated tests of appcode"
scan_vulnerability:
needs: test_appcode
runs-on: ubuntu-latest
container: snyk/snyk:maven-3-jdk-8
environment: snyk_aws_demo
env:
INTEGRATION_ID: 1c3d4b02-6bdd-4533-87e5-88e85f07e68f
ORG_ID: 96094dfc-3551-4561-ac13-11022e08aefb
SNYK_TOKEN: "${{ secrets.SNYK_TOKEN }}"
steps:
- uses: actions/checkout@v1
- name: build appcode
run: mvn install
- name: scan vulnerability with Snyk
run: |
# Snyk OpenSource
snyk test --org=${ORG_ID} --all-projects --detection-depth=8 --print-deps --remote-repo-url=aws_snyk_mvn_goof --severity-threshold=low || true # *1 replace with snyk-filter or snyk-delta
# Snyk IaC
snyk iac test --org=${ORG_ID} --scan=planned-values || true # *1
# Snyk Code
snyk code test --org=${ORG_ID} || true # *1
- name: monitor/report with Snyk App UI
run: |
# Snyk IaC
snyk iac test --org=${ORG_ID} --scan=planned-values --report || true # *1
# Snyk OpenSource
snyk monitor --org=${ORG_ID} --all-projects --detection-depth=8 --print-deps --remote-repo-url=aws_snyk_mvn_goof # *1
# Snyk import from Git integration through API
curl --request POST --header "Content-Type: application/json; charset=utf-8" --header "Authorization: token ${SNYK_TOKEN}" --data-binary "{
\"target\": {
\"owner\": \"lmaeda\",
\"name\": \"aws-snyk-mvn-goof\",
\"branch\": \"${{ github.sha }}\"
}
}" "https://api.snyk.io/v1/org/${ORG_ID}/integrations/${INTEGRATION_ID}/import"
refresh_container:
needs: scan_vulnerability
environment: snyk_aws_demo
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: "1"
DOCKER_LOGIN: "${{ secrets.DOCKER_LOGIN }}"
ORG_ID: 96094dfc-3551-4561-ac13-11022e08aefb
SNYK_TOKEN: "${{ secrets.SNYK_TOKEN }}"
steps:
- uses: actions/checkout@v1
- name: build container image
run: docker image build . --file Dockerfile --tag ${{env.DOCKER_LOGIN}}/my-snyk-demo-mvn-goof:latest
- name: scan vulnerability
run: docker run --env SNYK_TOKEN -v /var/run/docker.sock:/var/run/docker.sock snyk/snyk:docker snyk container test --print-deps --org=${ORG_ID} --project-name=${{github.repository}} --app-vulns --nested-jars-depth=8 ${{env.DOCKER_LOGIN}}/my-snyk-demo-mvn-goof:latest|| true # *1
- name: monitor container image for vulnerability
run: docker run --env SNYK_TOKEN -v /var/run/docker.sock:/var/run/docker.sock snyk/snyk:docker snyk container monitor --print-deps --org=${ORG_ID} --project-name=${{github.repository}} --app-vulns --nested-jars-depth=8 ${{env.DOCKER_LOGIN}}/my-snyk-demo-mvn-goof:latest || true # *1
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: push container image
run: docker push ${{env.DOCKER_LOGIN}}/my-snyk-demo-mvn-goof:latest