Skip to content

Commit 7bac0ae

Browse files
committed
private repo
1 parent 36b5b3d commit 7bac0ae

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

private-sec-reporting.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import os
2+
import requests
3+
import os
4+
import json
5+
org = "jupyter"
6+
7+
token = os.getenv("GH_TOKEN")
8+
9+
def check_private_vulnerability_reporting(repo_name):
10+
headers = {
11+
'Authorization': f'token {token}',
12+
'Accept': 'application/vnd.github.v3+json'
13+
}
14+
url = f'https://api.github.com/repos/{org}/{repo_name}/private-vulnerability-reporting'
15+
16+
response = requests.get(url, headers=headers)
17+
18+
if response.status_code == 200:
19+
return response.json().get('enabled', False)
20+
return False
21+
22+
def get_org_repos():
23+
headers = {
24+
'Authorization': f'token {token}',
25+
'Accept': 'application/vnd.github.v3+json'
26+
}
27+
28+
repos = []
29+
page = 1
30+
while True:
31+
url = f'https://api.github.com/orgs/{org}/repos?page={page}&per_page=100'
32+
response = requests.get(url, headers=headers)
33+
34+
if response.status_code != 200:
35+
print(f"Error fetching repos: {response.status_code}")
36+
break
37+
38+
page_repos = response.json()
39+
if not page_repos:
40+
break
41+
42+
repos.extend(page_repos)
43+
page += 1
44+
45+
return repos
46+
47+
# Get all repos and check their vulnerability reporting status
48+
repos = get_org_repos()
49+
results = {}
50+
from rich import print
51+
for repo in repos:
52+
repo_name = repo['name']
53+
repo_is_private = repo['private']
54+
if repo_is_private:
55+
print(f"{repo_name:>25}: [yellow]Private[/yellow]")
56+
continue
57+
has_vuln_reporting = check_private_vulnerability_reporting(repo_name)
58+
results[repo_name] = has_vuln_reporting
59+
print(f"{repo_name:>25}: {'[green]Enabled[/green]' if has_vuln_reporting else '[red]Disabled[/red]'}")

0 commit comments

Comments
 (0)