Skip to content

Commit 2b801a8

Browse files
authored
1 parent da8beaf commit 2b801a8

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/code_scanning.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def list_repo_cs_alerts(api_endpoint, github_pat, repo_name):
1717
Outputs:
1818
- List of _all_ code scanning alerts on the repository
1919
"""
20-
url = f"{api_endpoint}/repos/{repo_name}/code-scanning/alerts?per_page=100&page=1"
20+
url = f"{api_endpoint}/repos/{repo_name}/code-scanning/alerts?per_page=100&after="
2121
code_scanning_alerts = api_helpers.make_api_call(url, github_pat)
2222
print(f"Found {len(code_scanning_alerts)} code scanning alerts in {repo_name}")
2323
return code_scanning_alerts
@@ -104,7 +104,7 @@ def list_org_cs_alerts(api_endpoint, github_pat, org_name):
104104
- List of _all_ code scanning alerts on the organization
105105
"""
106106

107-
url = f"{api_endpoint}/orgs/{org_name}/code-scanning/alerts?per_page=100&page=1"
107+
url = f"{api_endpoint}/orgs/{org_name}/code-scanning/alerts?per_page=100&after="
108108
code_scanning_alerts = api_helpers.make_api_call(url, github_pat)
109109
print(f"Found {len(code_scanning_alerts)} code scanning alerts in {org_name}")
110110
return code_scanning_alerts
@@ -306,7 +306,7 @@ def list_enterprise_cloud_cs_alerts(api_endpoint, github_pat, enterprise_slug):
306306
- List of _all_ code scanning alerts in enterprise that PAT user can access
307307
"""
308308

309-
url = f"{api_endpoint}/enterprises/{enterprise_slug}/code-scanning/alerts?per_page=100&page=1"
309+
url = f"{api_endpoint}/enterprises/{enterprise_slug}/code-scanning/alerts?per_page=100&after="
310310
code_scanning_alerts = api_helpers.make_api_call(url, github_pat)
311311
print(f"Found {len(code_scanning_alerts)} code scanning alerts in {enterprise_slug}")
312312
return code_scanning_alerts

src/dependabot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def list_repo_dependabot_alerts(api_endpoint, github_pat, repo_name):
1717
Outputs:
1818
- List of _all_ dependency alerts on the repository
1919
"""
20-
url = f"{api_endpoint}/repos/{repo_name}/dependabot/alerts?per_page=100&page=1"
20+
url = f"{api_endpoint}/repos/{repo_name}/dependabot/alerts?per_page=100&after="
2121
dependabot_alerts = api_helpers.make_api_call(url, github_pat)
2222
print(f"Found {len(dependabot_alerts)} dependabot alerts in {repo_name}")
2323
return dependabot_alerts
@@ -90,7 +90,7 @@ def list_org_dependabot_alerts(api_endpoint, github_pat, org_name):
9090
Outputs:
9191
- List of _all_ dependency alerts on the organization
9292
"""
93-
url = f"{api_endpoint}/orgs/{org_name}/dependabot/alerts?per_page=100&page=1"
93+
url = f"{api_endpoint}/orgs/{org_name}/dependabot/alerts?per_page=100&after="
9494
dependabot_alerts = api_helpers.make_api_call(url, github_pat)
9595
print(f"Found {len(dependabot_alerts)} dependabot alerts in {org_name}")
9696
return dependabot_alerts
@@ -109,7 +109,7 @@ def list_enterprise_dependabot_alerts(api_endpoint, github_pat, enterprise_slug)
109109
Outputs:
110110
- List of _all_ dependency alerts on the enterprise
111111
"""
112-
url = f"{api_endpoint}/enterprises/{enterprise_slug}/dependabot/alerts?per_page=100&page=1"
112+
url = f"{api_endpoint}/enterprises/{enterprise_slug}/dependabot/alerts?per_page=100&after="
113113
dependabot_alerts = api_helpers.make_api_call(url, github_pat)
114114
print(f"Found {len(dependabot_alerts)} dependabot alerts in {enterprise_slug}")
115115
return dependabot_alerts

src/secret_scanning.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ def get_repo_ss_alerts(api_endpoint, github_pat, repo_name):
1717
Outputs:
1818
- List of _all_ secret scanning alerts on the repository (both default and generic secret types)
1919
"""
20-
# First call: get default secret types (without any filters)
21-
url_default = f"{api_endpoint}/repos/{repo_name}/secret-scanning/alerts?per_page=100&page=1"
20+
# First call: get default secret types (without any filters), use after= to force object based cursor instead of page based
21+
url_default = f"{api_endpoint}/repos/{repo_name}/secret-scanning/alerts?per_page=100&after="
2222
ss_alerts_default = api_helpers.make_api_call(url_default, github_pat)
2323

24-
# Second call: get generic secret types with hardcoded list
24+
# Second call: get generic secret types with hardcoded list, use after= to force object based cursor instead of page based
2525
generic_secret_types = "password,http_basic_authentication_header,http_bearer_authentication_header,mongodb_connection_string,mysql_connection_string,openssh_private_key,pgp_private_key,postgres_connection_string,rsa_private_key"
26-
url_generic = f"{api_endpoint}/repos/{repo_name}/secret-scanning/alerts?per_page=100&page=1&secret_type={generic_secret_types}"
26+
url_generic = f"{api_endpoint}/repos/{repo_name}/secret-scanning/alerts?per_page=100&after=&secret_type={generic_secret_types}"
2727
ss_alerts_generic = api_helpers.make_api_call(url_generic, github_pat)
2828

2929
# Combine results and deduplicate
@@ -114,14 +114,14 @@ def get_org_ss_alerts(api_endpoint, github_pat, org_name):
114114
Outputs:
115115
- List of _all_ secret scanning alerts on the organization (both default and generic secret types)
116116
"""
117-
# First call: get default secret types (without any filters)
118-
url_default = f"{api_endpoint}/orgs/{org_name}/secret-scanning/alerts?per_page=100&page=1"
117+
# First call: get default secret types (without any filters), use after= to force object based cursor instead of page based
118+
url_default = f"{api_endpoint}/orgs/{org_name}/secret-scanning/alerts?per_page=100&after="
119119
ss_alerts_default = api_helpers.make_api_call(url_default, github_pat)
120120

121-
# Second call: get generic secret types with hardcoded list
121+
# Second call: get generic secret types with hardcoded list, use after= to force object based cursor instead of page based
122122
generic_secret_types = "password,http_basic_authentication_header,http_bearer_authentication_header,mongodb_connection_string,mysql_connection_string,openssh_private_key,pgp_private_key,postgres_connection_string,rsa_private_key"
123123
url_generic = (
124-
f"{api_endpoint}/orgs/{org_name}/secret-scanning/alerts?per_page=100&page=1&secret_type={generic_secret_types}"
124+
f"{api_endpoint}/orgs/{org_name}/secret-scanning/alerts?per_page=100&after=&secret_type={generic_secret_types}"
125125
)
126126
ss_alerts_generic = api_helpers.make_api_call(url_generic, github_pat)
127127

@@ -228,13 +228,13 @@ def get_enterprise_ss_alerts(api_endpoint, github_pat, enterprise_slug):
228228
Outputs:
229229
- List of _all_ secret scanning alerts on the enterprise (both default and generic secret types)
230230
"""
231-
# First call: get default secret types (without any filters)
232-
url_default = f"{api_endpoint}/enterprises/{enterprise_slug}/secret-scanning/alerts?per_page=100&page=1"
231+
# First call: get default secret types (without any filters), use after= to force object based cursor instead of page based
232+
url_default = f"{api_endpoint}/enterprises/{enterprise_slug}/secret-scanning/alerts?per_page=100&after="
233233
ss_alerts_default = api_helpers.make_api_call(url_default, github_pat)
234234

235-
# Second call: get generic secret types with hardcoded list
235+
# Second call: get generic secret types with hardcoded list, use after= to force object based cursor instead of page based
236236
generic_secret_types = "password,http_basic_authentication_header,http_bearer_authentication_header,mongodb_connection_string,mysql_connection_string,openssh_private_key,pgp_private_key,postgres_connection_string,rsa_private_key"
237-
url_generic = f"{api_endpoint}/enterprises/{enterprise_slug}/secret-scanning/alerts?per_page=100&page=1&secret_type={generic_secret_types}"
237+
url_generic = f"{api_endpoint}/enterprises/{enterprise_slug}/secret-scanning/alerts?per_page=100&after=&secret_type={generic_secret_types}"
238238
ss_alerts_generic = api_helpers.make_api_call(url_generic, github_pat)
239239

240240
# Combine results and deduplicate

0 commit comments

Comments
 (0)