fix: Update fetchLinkedPRs to prevent shell injection vulnerabilities

- Modified the fetchLinkedPRs function to use JSON.stringify for the request body, ensuring safe input handling when spawning the GitHub CLI command.
- Changed the command to read the query from stdin using the --input flag, enhancing security against shell injection risks.
This commit is contained in:
Kacper
2025-12-24 01:41:05 +01:00
parent 7b61a274e5
commit 1ff617703c

View File

@@ -111,8 +111,10 @@ async function fetchLinkedPRs(
try {
// Use spawn with stdin to avoid shell injection vulnerabilities
// --input - reads the JSON request body from stdin
const requestBody = JSON.stringify({ query });
const response = await new Promise<Record<string, unknown>>((resolve, reject) => {
const gh = spawn('gh', ['api', 'graphql', '-f', 'query=-'], {
const gh = spawn('gh', ['api', 'graphql', '--input', '-'], {
cwd: projectPath,
env: execEnv,
});
@@ -133,7 +135,7 @@ async function fetchLinkedPRs(
}
});
gh.stdin.write(query);
gh.stdin.write(requestBody);
gh.stdin.end();
});