Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
fix(github): require https for github_api targets
SeashoreShi71a662f479a6
diff --git a/src/utils/github.test.ts b/src/utils/github.test.tsindex a2d9f2ac..98f5f064 100644--- a/src/utils/github.test.ts+++ b/src/utils/github.test.ts@@ -10,9 +10,13 @@ describe('resolveGitHubApiUrl', () => {expect(resolveGitHubApiUrl('https://api.github.com/repos/o/r')).toBe('https://api.github.com/repos/o/r');});+ it('rejects plain http even for api.github.com (token must not transit plaintext)', () => {+ expect(() => resolveGitHubApiUrl('http://api.github.com/repos/o/r')).toThrow(/requires https/);+ });+it('rejects absolute URLs to other hosts so the token cannot leak', () => {expect(() => resolveGitHubApiUrl('https://evil.example/steal')).toThrow(/restricted to api\.github\.com/);- expect(() => resolveGitHubApiUrl('http://127.0.0.1:9/x')).toThrow(/restricted to api\.github\.com/);+ expect(() => resolveGitHubApiUrl('https://127.0.0.1:9/x')).toThrow(/restricted to api\.github\.com/);// userinfo tricks must not bypass the host checkexpect(() => resolveGitHubApiUrl('https://[email protected]/')).toThrow(/restricted to api\.github\.com/);});diff --git a/src/utils/github.ts b/src/utils/github.tsindex df87b0ab..052397cd 100644--- a/src/utils/github.ts+++ b/src/utils/github.ts@@ -40,6 +40,9 @@ export function resolveGitHubApiUrl(path: string): string {} catch {throw new Error(`Invalid GitHub API URL: ${path}`);}+ if (url.protocol !== 'https:') {+ throw new Error(`github_api requires https; refusing ${url.protocol}//${url.hostname}`);+ }if (url.hostname.toLowerCase() !== GITHUB_API_HOST) {throw new Error(`github_api is restricted to ${GITHUB_API_HOST}; refusing to send the GitHub token to ${url.hostname}`,