You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+144-5Lines changed: 144 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,11 +20,9 @@ This is a set of scripts that use these APIs to access and manage alerts. The sc
20
20
- requires read access to the repository, organization or Enterprise you are querying
21
21
- Note that Secret Scanning alerts are only available to admins of the repository, organization or Enterprise, a security manager, or where otherwise granted access
22
22
23
-
## 🚀 Usage
23
+
## 🚀 Scripts usage
24
24
25
-
Generally, the date in `--since` can be specified as `YYYY-MM-DD` or as `Nd` where `N` is the number of days ago. Full ISO formats are also supported. If a timezone is not specified, the date is assumed to be in UTC (`Z` timezone).
26
-
27
-
Run each specific script according to the help for each script.
25
+
A note on common arguments: generally, the date in `--since` can be specified as `YYYY-MM-DD` or as `Nd` where `N` is the number of days ago. Full ISO formats are also supported. If a timezone is not specified, the date is assumed to be in UTC (`Z` timezone).
28
26
29
27
### List secret scanning alerts
30
28
@@ -327,7 +325,148 @@ options:
327
325
ISO date string to filter secrets detected after this date (e.g., 2023-01-01)
328
326
```
329
327
330
-
## 🛠️ Alternatives
328
+
## 🔧 The `githubapi.py` Module
329
+
330
+
The `githubapi.py` module is a lightweight GitHub API client that provides a wrapper around the GitHub REST API. It handles authentication, pagination, rate limiting, and provides convenient methods for accessing GitHub Advanced Security alerts. All scripts in this repository use this module as their foundation.
331
+
332
+
### Key Features
333
+
334
+
-**Authentication**: Automatically handles GitHub token authentication via the `GITHUB_TOKEN` environment variable or passed token
335
+
-**Automatic Pagination**: Supports cursor-based pagination to retrieve all results across multiple pages
336
+
-**Rate Limiting**: Automatically detects and handles GitHub API rate limits by waiting and retrying
337
+
-**Flexible Scoping**: Query at repository, organization, or Enterprise level
338
+
-**Date Filtering**: Filter results by date with support for ISO 8601 formats or relative dates (e.g., `7d` for 7 days ago)
339
+
-**TLS Support**: Configurable TLS certificate verification, including support for custom CA bundles and self-signed certificates
340
+
-**Error Handling**: Robust error handling with detailed logging
341
+
342
+
### The `GitHub` Class
343
+
344
+
The main class in the module is `GitHub`, which provides methods to interact with the GitHub API.
345
+
346
+
#### Initialization
347
+
348
+
```python
349
+
from githubapi import GitHub
350
+
351
+
# Initialize with token from environment variable
352
+
gh = GitHub()
353
+
354
+
# Or provide token explicitly
355
+
gh = GitHub(token=some_variable)
356
+
357
+
# For GitHub Enterprise Server with custom hostname
Make a GET request to the specified URL with optional headers and parameters, respecting rate limits automatically by raising a `RateLimited` exception when necessary.
0 commit comments