--- name: Upwind Security Image Scanning description: Scan against built images inputs: upwind_client_id: description: Upwind Client ID required: true upwind_client_secret: description: Upwind Client Secret required: true docker_image: description: Already built docker image residing on same runner required: true docker_user: description: User to authenticate to the Docker registry required: false docker_password: description: Password to authenticate to the Docker registry required: false pull_image: description: Attempt to pull the image. Set to false if image is available locally default: true type: boolean upwind_uri: description: Public Upwind URI domain name default: upwind.io required: false additional_registries: description: Comma-separated list of additional registries to associate with the scanned image, passed as a string required: false debug: description: Enable debug logging default: false type: boolean runs: using: "composite" steps: - name: Download Binary id: download_binary shell: bash run: | response=$(curl -sSL -X POST \ --url "https://oauth.${{ inputs.upwind_uri }}/oauth/token" \ --data "audience=https://agent.${{ inputs.upwind_uri }}" \ --data "client_id=${{ inputs.upwind_client_id }}" \ --data "client_secret=${{ inputs.upwind_client_secret }}" \ --data "grant_type=client_credentials") if ! TOKEN=$(echo "$response" | jq -r '.access_token // empty' 2>/dev/null); then echo "Failed to parse JSON response: $response" >&2 exit 1 elif [ -z "$TOKEN" ]; then echo "No access_token found in response: $response" >&2 exit 1 fi OS=$(uname | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m | tr '[:upper:]' '[:lower:]') case "$ARCH" in x86_64) ARCH="amd64" ;; aarch64|arm64) ARCH="arm64" ;; *) echo "Unsupported architecture: $ARCH" >&2 exit 1 ;; esac UPWIND_AGENT="shiftleft" AGENT_OUTPUT="./$UPWIND_AGENT" if [[ "${{ inputs.upwind_uri }}" == "upwind.dev" ]]; then RELEASE_BUCKET="releases.upwind.dev" else RELEASE_BUCKET="releases.upwind.io" fi UPWIND_AGENT_URL="https://$RELEASE_BUCKET/$UPWIND_AGENT/stable/$OS/$ARCH/$UPWIND_AGENT-$OS-$ARCH" echo "Downloading from $UPWIND_AGENT_URL" curl -fsS -H "Authorization: Bearer $TOKEN" -L "$UPWIND_AGENT_URL" -o "$AGENT_OUTPUT" chmod +x "$AGENT_OUTPUT" - name: Execute scan against the docker image shell: bash run: | sudo ./shiftleft event \ --source=GITHUB_ACTIONS \ --initiator=${GITHUB_TRIGGERING_ACTOR} \ --event-type=IMAGE_PUBLISH \ --upwind-uri=${{ inputs.upwind_uri }} \ --upwind-client-id=${{ inputs.upwind_client_id }} \ --upwind-client-secret=${{ inputs.upwind_client_secret }} \ --docker-image ${{ inputs.docker_image }} \ --commit-sha ${GITHUB_SHA} \ --branch ${GITHUB_REF} \ --repository ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} \ --docker-user="${{ inputs.docker_user }}" \ --docker-password="${{ inputs.docker_password }}" \ --debug=${{ inputs.debug }} \ --additional-registries="${{ inputs.additional_registries}}" \ --docker-pull=${{ inputs.pull_image }} echo "Info: image publish event sent"