For the complete documentation index, see llms.txt. This page is also available as Markdown.

CircleCI code scan workflow template

Configure Cortex CLI code scanning in a CircleCI workflow.

This CircleCI workflow automates code scanning with the Cortex CLI. Replace placeholder values with values for your environment.

version: 2.1

executors:
  docker-executor:
    docker:
      - image: cimg/base:stable  # Replace with a suitable image or executor
    environment:
      CORTEX_API_URL: "https://{CORTEX_URL}"
      CORTEX_CLI_VERSION: "0.8.11"

jobs:
  setup-environment:
    executor: docker-executor
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Get Temporary Token and Pull Docker Image
          command: |
            export TOKEN_RESPONSE=$(curl --location "${CORTEX_API_URL}/public_api/cas/v1/cortex-cli/create-token" \
                                        --header "Authorization: ${CORTEX_API_KEY}" \
                                        --header "x-xdr-auth-id: ${CORTEX_API_KEY_ID}" \
                                        --header "Content-Type: application/json" \
                                        --data "{}" -s)
            export TEMP_TOKEN=$(echo "$TOKEN_RESPONSE" | jq -r '.token')
            docker pull distributions-dev.traps.paloaltonetworks.com/cli-docker/${TEMP_TOKEN}/method:amd64-${CORTEX_CLI_VERSION}-dev
            docker tag distributions-dev.traps.paloaltonetworks.com/cli-docker/${TEMP_TOKEN}/method:amd64-${CORTEX_CLI_VERSION}-dev cortexcli:${CORTEX_CLI_VERSION}
      - run:
          name: Run Cortex CLI Container
          # Replace owner/repo with your actual repository information
          command: |
            docker run --rm cortexcli:${CORTEX_CLI_VERSION} \
                        --api-base-url ${CORTEX_API_URL} \
                        --api-key ${CORTEX_API_KEY} \
                        --api-key-id ${CORTEX_API_KEY_ID} \
                        code scan \
                        --directory . \
                        --repo-id <REPLACE WITH REPO_OWNER/REPO_NAME> \
                        --branch "${CIRCLE_BRANCH}"

workflows:
  version: 2
  build:
    jobs:
      - setup-environment:
          context: cortex-secrets

Last updated

Was this helpful?