Skip to content

Commit 87c5f3b

Browse files
authored
Merge pull request #3007 from orbisai0security/fix-fix-v-006-graphql-injection-sanitization
fix: use subprocess instead of os.system in fetch_github_stars.py
2 parents a0e4e65 + babb09f commit 87c5f3b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

website/fetch_github_stars.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
GRAPHQL_URL = "https://api.github.com/graphql"
2020
BATCH_SIZE = 50
2121

22+
# Allowlist for valid GitHub owner/repo name characters.
23+
# GitHub usernames and repo names only allow letters, digits, hyphens, underscores, and dots.
24+
_GITHUB_NAME_RE = re.compile(r"^[a-zA-Z0-9._-]+$")
25+
2226

2327
def extract_github_repos(text: str) -> set[str]:
2428
"""Extract unique owner/repo pairs from GitHub URLs in markdown text."""
@@ -46,7 +50,7 @@ def build_graphql_query(repos: list[str]) -> str:
4650
parts = []
4751
for i, repo in enumerate(repos):
4852
owner, name = repo.split("/", 1)
49-
if '"' in owner or '"' in name:
53+
if not _GITHUB_NAME_RE.match(owner) or not _GITHUB_NAME_RE.match(name):
5054
continue
5155
parts.append(
5256
f'repo_{i}: repository(owner: "{owner}", name: "{name}") '

0 commit comments

Comments
 (0)