Skip to content

Commit

Permalink
fix: security patch (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored Nov 12, 2024
1 parent 265388e commit ded72a9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/backend/src/api/v1/runs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sql from "@/src/utils/db";
import { Context } from "koa";
import Router from "koa-router";

import { checkAccess } from "@/src/utils/authorization";
import { checkAccess, checkProjectAccess } from "@/src/utils/authorization";
import { convertChecksToSQL } from "@/src/utils/checks";
import { jsonrepair } from "jsonrepair";
import { Feedback, Score, deserializeLogic } from "shared";
Expand Down Expand Up @@ -1016,8 +1016,14 @@ runs.patch(
checkAccess("logs", "update"),
async (ctx: Context) => {
const { id: runId } = ctx.params;
const { projectId, userId } = ctx.state;
const { label, value, comment } = Score.parse(ctx.request.body);

const hasProjectAccess = await checkProjectAccess(projectId, userId);
if (!hasProjectAccess) {
ctx.throw(401, "Unauthorized");
}

let [existingScore] =
await sql`select * from run_score where run_id = ${runId} and label = ${label}`;

Expand Down

0 comments on commit ded72a9

Please sign in to comment.