GitHub Integration

How to integrate GitHub to test and watch your repositories

You can add your Node.js, Ruby and Java GitHub repos and quickly test them, or decide which ones you’d like to continously watch with Snyk.

Adding your GH repos

  1. Go to the integrations page and click “Connect to GitHub”.
  2. You need to grant Snyk additional GitHub permissions. Choose to give access to public and private repositories, or grant access to public repositories only.
  3. Next, you’ll see a list of all GitHub repos across your GitHub organisations. Select the repos you would like to test with Snyk.
  4. Click on the button at the bottom of the page “Add selected repositories to Snyk”. The selected repos appear in your projects, and will be continuously checked for vulnerabilities.
  5. Clicking “View report” on any project lets you view & fix vulnerabilities right away. You’ll be able to review the suggested remediations, and create a PR with the required upgrades or patches.

To view your organisation's projects in Snyk, you'll need to have sufficient access to your organisation's repositories on GitHub.

Integration features

Watch a Node.js, Ruby or Java GitHub repo to add it as a project to Snyk. This will allow you to:

  • see Snyk tests in your pull requests that check for vulnerabilities.
  • get email alerts and a Snyk pull request with fixes when new vulnerabilities that affect your repo are disclosed.
  • get email alerts and a Snyk pull request if a new upgrade or patch is available for a vulnerability that affects you.
  • trigger a Snyk pull request with fixes yourself from the test report page or the project page for your repo on snyk.io.

Snyk Test on your pull requests

Snyk Test on pull requests

Snyk tests will be visible in pull requests on repos that you are watching with Snyk. You can review and adjust the settings for this by going to the ‘Settings’ for the watched project:

Snyk Test on pull request settings

  • By default, Snyk runs a test when the dependencies in the package.json or Gemfile.lock/Gemfile change, and fails the test if the new dependencies have vulnerabilities.
  • You can change this to fail if the repository has any existing vulnerabilities (so tests will fail even if the current PR is not adding new vulnerable dependencies).
  • You can choose to fail tests only for high severity vulnerabilities.
  • You can disable Snyk tests in pull requests.

Fix vulnerabilities with Snyk pull requests

When viewing a Snyk test report for a repo that you own, or when looking at a project that you are watching with Snyk, you’ll see two options for fixing a vulnerability:

1) ‘Open a fix PR’ link: generate a Snyk pull request with the minimal changes needed to fix the vulnerabilities affecting the repo.

2) ‘Fix this vulnerability’ link: generate a Snyk pull request that fixes only this vulnerability.

Fix button

You can review the vulnerabilities that will be fixed, change your selection, and choose to ignore any vulnerabilties that can’t be fixed right now before opening the pull request on the ‘Open a fix PR’ page.

Note that patching is only supported for Node.js repos; Ruby vulnerabilities can be fixed with upgrades only.

Open a fix PR page

Snyk fixes your Ruby projects by updating vulnerable dependencies in your Gemfile.lock file. When a fix requires a change to your Gemfile, our fix pull requests will propose these changes.

When you open a PR via snyk.io, we will give you a heads-up when this is the case:

Gemfile changes flag

Here’s an example for the pull request:

Snyk remediation PR

Get a Snyk pull request when newly disclosed vulnerabilities affect you

Whenever a vulnerability is disclosed that affects a repo you’re watching, Snyk will not only email you about it, but also generate a Snyk pull request that addresses the vulnerabilities. You’ll receive a pull request similar to the example above.

Get a Snyk pull request when new upgrades or patches are available

When no upgrade is available, you can ignore or patch the vulnerability (patching is only available for Node.js projects). When a better remediation option has become available, for example an upgrade for a vulnerability you previously ignored, Snyk notifies you about this via email, and also generates a pull request with the new fix.

Disable automatic pull requests

You can disable Snyk’s auto-generated pull requests with fixes in your organisation settings. This will affect all projects in the organisation.

Disable automatic fix PRs

Disabling the GitHub integration

If you don’t want to watch a GitHub repo anymore, you can stop watching this project via the project settings. The project will be set to inactive, and you’ll no longer get alerts, pull requests, or Snyk test on your pull requests. The web hook that enables the GitHub integration for this repo will be removed.

You can re-start watching at any time.

Authorizing GitHub

Repository access

When granting Snyk access to GitHub, you can choose to:

  • grant access to public and private repositories
  • grant access to public repositories only

This is for all GitHub organisations you have sufficient permissions for.

Repo access permissions

If you want to change your permissions at another point in time, you can do so by going to Settings, Integrations and selecting GitHub from the list.

GitHub organisations

To test your GitHub organisation’s repositories with Snyk, you will need to have sufficient user permissions. When you authenticate Snyk, GitHub will show you which organisations you can integrate.

If you do not have the correct permissions, you will see “Access request pending” next to your ogranisation’s name, and you will be unable to see this organisation’s projects in Snyk.

Adding your GH repos

If you’d like to integrate this organisation, you will need to request organisational approval in GitHub.