Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed revision selection so the 64-revision cap prefers the newest matching branches and tags instead of pruning by ref-name order. [#1122](https://github.com/sourcebot-dev/sourcebot/pull/1122)
- Fixed infinite pagination loop in Gitea/Forgejo when an API token can only see a subset of org repos (the `x-total-count` header reports org total while token returns fewer items). [#1130](https://github.com/sourcebot-dev/sourcebot/pull/1130)
- Fixed CodeQL path injection vulnerability in review agent log file writing by validating paths stay within the expected log directory. [#1133](https://github.com/sourcebot-dev/sourcebot/pull/1133)

## [4.16.11] - 2026-04-17

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@ import OpenAI from "openai";
import { sourcebot_file_diff_review, sourcebot_file_diff_review_schema } from "@/features/agents/review-agent/types";
import { env } from "@sourcebot/shared";
import fs from "fs";
import path from "path";
import { createLogger } from "@sourcebot/shared";

const logger = createLogger('invoke-diff-review-llm');

const REVIEW_AGENT_LOG_BASE = path.join(env.DATA_CACHE_DIR, 'review-agent');

const validateReviewAgentLogPath = (logPath: string): void => {
const resolved = path.resolve(logPath);
if (!resolved.startsWith(REVIEW_AGENT_LOG_BASE + path.sep)) {
throw new Error('reviewAgentLogPath escapes log directory');
}
};

export const invokeDiffReviewLlm = async (reviewAgentLogPath: string | undefined, prompt: string): Promise<sourcebot_file_diff_review> => {
logger.debug("Executing invoke_diff_review_llm");

if (!env.OPENAI_API_KEY) {
logger.error("OPENAI_API_KEY is not set, skipping review agent");
throw new Error("OPENAI_API_KEY is not set, skipping review agent");
}

if (reviewAgentLogPath) {
validateReviewAgentLogPath(reviewAgentLogPath);
}

const openai = new OpenAI({
apiKey: env.OPENAI_API_KEY,
Expand Down
Loading