This file contains hidden or 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
    
  
  
    
  | #!/usr/bin/env bash | |
| set -euo pipefail | |
| if [[ $# -lt 3 ]]; then | |
| echo "Usage: $0 <ARTIFACTORY_URL> <REPO> <OUTPUT_FILE>" | |
| echo "" | |
| echo "Environment variables required:" | |
| echo " USER=<username> - Artifactory username" | |
| echo " PASS=<password> - Artifactory password/API key" | |
| echo "" | 
  
    
      This file contains hidden or 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
    
  
  
    
  | package main | |
| # Identify all `FROM` statements that do not match the allowed pattern | |
| deny[message] { | |
| some i | |
| instruction := input[i] | |
| instruction.Cmd == "from" # Ensure this is a FROM instruction | |
| # The `Value` is an array; extract the first element | |
| image := instruction.Value[0] | 
  
    
      This file contains hidden or 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
    
  
  
    
  | curl \ | |
| --request POST \ | |
| --header "Content-Type: application/json" \ | |
| --header "Authorization: token $INSIGHTS_TOKEN" \ | |
| --data-binary "{ | |
| \"key\": \"component\", | |
| \"value\": \"$1\" | |
| }" \ | |
| https://api.snyk.io/v1/org/$2/project/$3/tags | 
  
    
      This file contains hidden or 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
    
  
  
    
  | curl \ | |
| --request POST \ | |
| --header "Content-Type: application/json" \ | |
| --header "Authorization: token INSERT_TOKEN \ | |
| --data-binary "{ | |
| \"key\": \"component\", | |
| \"value\": \"pkg:INSERT_REPO@INSERT_BRANCH\" | |
| }" \ | |
| 'https://api.snyk.io/v1/org/INSERT_ORG_ID/project/INSERT_PROJECT/tags' | 
  
    
      This file contains hidden or 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
    
  
  
    
  | docker run -d --restart=always --name broker \ | |
| -p 8000:8000 \ | |
| -e BROKER_TOKEN=secret-broker-token \ | |
| -e BROKER_CLIENT_URL=http://broker:8000 \ | |
| -e CR_AGENT_URL=https://cra:8081 \ | |
| -e CR_TYPE=quay-cr \ | |
| -e CR_BASE=your.container.registry.domain.com \ | |
| -e CR_USERNAME=secret-container-registry-username \ | |
| -e CR_PASSWORD=secret-container-registry-password \ | |
| -e PORT=8000 \ | 
  
    
      This file contains hidden or 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
    
  
  
    
  | docker run --restart=always -d \ | |
| -p 8000:8000 \ | |
| -e BROKER_TOKEN=secret-broker-token \ | |
| -e GITLAB_TOKEN=secret-gitlab-token \ | |
| -e GITLAB=your.gitlab.domain.com \ | |
| -e BROKER_CLIENT_URL=http://my.broker.client:8000 \ | |
| -e ACCEPT_CODE=true \ | |
| -e PORT=8000 \ | |
| snyk/broker:gitlab | 
  
    
      This file contains hidden or 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
    
  
  
    
  | ### GITLAB BROKER | |
| # Create Docker Network | |
| docker network create snykBroker | |
| # Deploy Broker | |
| docker run --restart=always \ | |
| -p 8000:8000 \ | |
| -e BROKER_TOKEN=secret-broker-token \ | 
  
    
      This file contains hidden or 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
    
  
  
    
  | name: "Snyk Test" | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| Pipeline-Job: | |
| # Configure Environment | 
  
    
      This file contains hidden or 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
    
  
  
    
  | - name: ACCEPT_CODE | |
| value: "true" | |
| - name: ACCEPT_IAC | |
| value: "tf,yaml,yml,json,tpl" | 
  
    
      This file contains hidden or 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
    
  
  
    
  | # First let's run everything as normal, and output in JSON so we can process our results | |
| OUTFILE="vuln.json" | |
| snyk code test --json-file-output=vuln.json || true # Never allow failure! | |
| snyk-to-html -i vuln.json -o results.html | |
| # Now we'll parse the json and check if there's any vulns of the type we select | |
| # (note this script can only detect one type of vuln to fail on right now) | |
| DISALLOW_VULNS="warning" | |
| NUMBER_DISALLOWED=$(cat $OUTFILE | jq '[.runs[].results[].level | select(.=="'$DISALLOW_VULNS'")] | length') | 
NewerOlder