1. Overview

Prisma Cloud can scan GitHub repositories and identify vulnerabilities in your software’s dependencies. Modern apps are increasingly composed of external, open source dependencies, so it’s important to give developers tools to assess those components early in the development lifecycle. Repository scanning gives you early insight into the software as it’s being developed, and long before apps are packaged (e.g. as a container) and deployed by CI/CD pipelines.

Currently, Prisma Cloud supports Python, Java, and JavaScript (Node.js).

2. Prerequisites

Prisma Cloud authenticates with the GitHub API using user-generated API tokens. The following scopes are required for scanning private repos. Prisma Cloud doesn’t modify or write to your repos.

  • repo — Full control of private repositories

    • repo:status — Access commit status

    • repo_deployment — Access deployment status

    • public_repo — Access public repositories

    • repo:invite — Access repository invitations

    • security_events — Read and write security events

If you’re scanning public repos only, select just the public_repo scope. The benefit of creating an access token for scanning public repos is that GitHub grants you a higher rate limit to their API, which Prisma Cloud utilizes for scanning.

3. Deployment

Prisma Cloud selects the repositories to scan according to a user-defined scope. For example, you might want to scan all repositories in your organization or just a subset of them. For each repo in scope, Prisma Cloud searches for well-known package manifest files, and enumerates the dependencies listed in them. Those dependencies are assessed against the latest threat data in the Intelligence Stream.

Code repository scans is handled by Console.

The following table lists the manifest files known to the scanner.

Package manager File name

Java (Gradle)

build.gradle, build.gradle.kts, gradle.properties

Java (Maven)

pom.xml

Python (pip)

req*.txt

JavaScript (NPM)

package.json, package-lock.json, npm-shrinkwrap.json, bower.json

Finally, Prisma Cloud can continuously monitor your code repositories for vulnerabilities by rescanning on every push event. Prisma Cloud integrates with GitHub using webooks, which notify the scanner when there are changes in the repository.

Prisma Cloud uses the GitHub API. The GitHub API is rate-limited. For unauthenticated requests, which can be used to scan public repositories, the cap is very low (60 requests/hour). Here the rate limit is guaged by IP address. For authenticated requests, which can scan either public or private repositories, the cap is 5000 requests/hour. Here the rate limit is guaged per account.

4. Set up your credentials

Generate a personal access token in GitHub, and then save it in the Prisma Cloud Credentials Store so that the scanner can access your repositories for scanning.

  1. Generate a GitHub access token.

    1. Log into your GitHub account.

    2. Go to Settings > Developer Settings > Personal access tokens.

    3. Click Generate new token.

    4. Set the scope to repo.

      code repo scanning creds

      If you’re scanning public repos only, select just the public_repo scope.

    5. Click Generate token. If your account requires SSO, enable it.

    6. Copy the generated token.

      code repo scanning token
  2. Save the token in Prisma Cloud’s credentials store.

    1. Log into Prisma Cloud Console.

    2. Go to Manage > Authentication > Credentials Store.

    3. Click Add Credential.

    4. Enter a Name for the credential.

    5. In Type, select GitHub access token.

    6. In Access Token, paste the access token you generated in GitHub.

    7. Click Save.

5. Configure the repos to scan

Specify the repositorires to scan. If your repository specifies dependencies in non-standard package manifest files, specify them here so the scanner can parse them. If there are manifests the scanner should ignore, specify them here as well.

  1. Open Console.

  2. Go to Defend > Vulnerabilities > Code Repositories.

  3. Click Add Scope. If this is your first repository, click Add the first item.

    Each scope spec has the following parameters:

    Field Description

    Provider

    GitHub is currently the only supported provider.

    Type

    To scan all repos in an organization, including both public and private repos, set the type to Private. You’ll need to set up an access token, so that Prisma Cloud can access your repos.

    To scan public repositories not related to your account or organziation, set the type to Public. When type is Public, credentials are not required, although API accesss to GitHub is capped to a very low value. Even if you’re only scanning public repos, we recommend that you set up an access token for authenticated access.

    Credential

    Specify credentials for the repository owner. If the credentials have already been created in the Prisma Cloud credentials store, select it. If not, click Add New.

    Repositories

    Specify the repositories to scan in the format: owner/name When you’ve selected a credential, the drop-down lists all repositories in the owner’s account.

    Wildcards are supported when the repo type is Private. They aren’t supported when the type is Public.

    Excluded manifest paths

    Specify paths to be excluded for analysis. Wildcards are supported.

    Advanced settings > Explicit manifest names

    Supported for Python only. Specify any additional file names that should be included for analysis. If you have a custom naming scheme for your manifest files, specify them here so that the scanner can find and parse them.

    Advanced settings > Python version

    For a more accurate analysis of your app’s dependencies, specify the version of Python you deploy in production. Otherwise, the scanner assumes the latest available version of Python.

  4. Click Add.

  5. Click Save.

6. Scan repos on push events

Configure GitHub webhooks to rescan your repositories on push events.

  1. Open Console.

  2. Go to Defend > Vulnerabilities > Code Repositories.

  3. In Webhook settings, select the publicly accessible name or IP address GitHub will use to notify Prisma Cloud that a push event occurred.

  4. Copy the URL.

  5. Configure GitHub.

    1. Log into GitHub, select a repo, and go to Settings > Webhooks.

    2. Click Add webhook.

    3. In Payload URL, paste the URL you copied from Prisma Cloud Console.

    4. In Content type, select application/json.

    5. Select Disable SSL verification.

      For Compute Edition, you can enable SSL verification if your Console runs under a domain with a valid certificate signed by a known authority.

      For Prisma Cloud Enterprise Edition, select Enable SSL verification.

    6. Leave all other settings in their default state.

    7. Click Add webhook.

    8. Verify that the ping webhook was delivered successfully.

7. Policy

Prisma Cloud ships with a default rule that alerts on vulnerabilities. In Defend > Vulnerabilities > Code Repositories, create vulnerability rules to tailor what’s reported.

Additional scan settings can be found under Manage > System > Scan, where you can set the scan interval. By default, it’s 24 hours.