Skip to content

Instantly share code, notes, and snippets.

@skwashd
Created August 26, 2019 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skwashd/b07b4e531b3d1fd305912fd2985c37ec to your computer and use it in GitHub Desktop.
Save skwashd/b07b4e531b3d1fd305912fd2985c37ec to your computer and use it in GitHub Desktop.
Bulk enable dependabot and security alerts on github repos
#!/usr/bin/env python3
import json
import os
import requests
token = os.environ.get("GITHUB_TOKEN")
org = os.environ.get("GITHUB_ORG")
repos = [
# Add list of repos here
]
for repo in repos:
headers = {
"Authorization": f"token {token}",
"Accept": "application/vnd.github.dorian-preview+json",
}
url = f"https://api.github.com/repos/{org}/{repo}/vulnerability-alerts"
r = requests.put(url, headers=headers)
r.raise_for_status()
headers = {
"Authorization": f"token {token}",
"Accept": "application/vnd.github.london-preview+json",
}
url = f"https://api.github.com/repos/{org}/{repo}/automated-security-fixes"
r = requests.put(url, headers=headers)
r.raise_for_status()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment