|
27 | 27 |
|
28 | 28 | mcp = FastMCP("GitHubCodeScanning") |
29 | 29 |
|
30 | | -GITHUB_PERSONAL_ACCESS_TOKEN = os.getenv('GITHUB_PERSONAL_ACCESS_TOKEN', default='') |
| 30 | +GH_TOKEN = os.getenv('GH_TOKEN', default='') |
31 | 31 |
|
32 | 32 | CODEQL_DBS_BASE_PATH = mcp_data_dir('seclab-taskflows', 'codeql', 'CODEQL_DBS_BASE_PATH') |
33 | 33 | ALERT_RESULTS_DIR = mcp_data_dir('seclab-taskflows', 'gh_code_scanning', 'ALERT_RESULTS_DIR') |
@@ -72,7 +72,7 @@ def _get_repo_from_html_url(html_url: str) -> str: |
72 | 72 | async def call_api(url: str, params: dict) -> str | httpx.Response: |
73 | 73 | """Call the GitHub code scanning API to fetch alert.""" |
74 | 74 | headers = {"Accept": "application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28", |
75 | | - "Authorization": f"Bearer {GITHUB_PERSONAL_ACCESS_TOKEN}"} |
| 75 | + "Authorization": f"Bearer {GH_TOKEN}"} |
76 | 76 | async def _fetch_alerts(url, headers, params): |
77 | 77 | try: |
78 | 78 | async with httpx.AsyncClient(headers = headers) as client: |
@@ -182,7 +182,7 @@ async def _fetch_codeql_databases(owner: str, repo: str, language: str): |
182 | 182 | """Fetch the CodeQL databases for a given repo and language.""" |
183 | 183 | url = f"https://api.github.com/repos/{owner}/{repo}/code-scanning/codeql/databases/{language}" |
184 | 184 | headers = {"Accept": "application/zip,application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28", |
185 | | - "Authorization": f"Bearer {os.getenv('GITHUB_PERSONAL_ACCESS_TOKEN')}"} |
| 185 | + "Authorization": f"Bearer {os.getenv('GH_TOKEN')}"} |
186 | 186 | try: |
187 | 187 | async with httpx.AsyncClient() as client: |
188 | 188 | async with client.stream('GET', url, headers =headers, follow_redirects=True) as response: |
@@ -238,7 +238,7 @@ async def dismiss_alert( |
238 | 238 | headers = { |
239 | 239 | "Accept": "application/vnd.github+json", |
240 | 240 | "X-GitHub-Api-Version": "2022-11-28", |
241 | | - "Authorization": f"Bearer {GITHUB_PERSONAL_ACCESS_TOKEN}" |
| 241 | + "Authorization": f"Bearer {GH_TOKEN}" |
242 | 242 | } |
243 | 243 |
|
244 | 244 | async with httpx.AsyncClient(headers=headers) as client: |
|
0 commit comments