fix: coord review remediations (path traversal, JSON parse, race condition) (#81)
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #81.
This commit is contained in:
@@ -78,7 +78,12 @@ async function readActiveSession(mission: Mission): Promise<MissionSession | und
|
||||
throw error;
|
||||
}
|
||||
|
||||
const lock = JSON.parse(lockRaw) as SessionLockState;
|
||||
let lock: SessionLockState;
|
||||
try {
|
||||
lock = JSON.parse(lockRaw) as SessionLockState;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
if (
|
||||
typeof lock.session_id !== 'string' ||
|
||||
(lock.runtime !== 'claude' && lock.runtime !== 'codex') ||
|
||||
@@ -106,10 +111,10 @@ async function readActiveSession(mission: Mission): Promise<MissionSession | und
|
||||
};
|
||||
}
|
||||
|
||||
export async function getMissionStatus(mission: Mission): Promise<MissionStatusSummary> {
|
||||
const freshMission = await loadMission(mission.projectPath);
|
||||
const tasks = await readTasks(freshMission);
|
||||
|
||||
async function buildStatusSummary(
|
||||
freshMission: Mission,
|
||||
tasks: MissionTask[],
|
||||
): Promise<MissionStatusSummary> {
|
||||
const done = tasks.filter((task) => task.status === 'done').length;
|
||||
const inProgress = tasks.filter((task) => task.status === 'in-progress').length;
|
||||
const pending = tasks.filter((task) => task.status === 'not-started').length;
|
||||
@@ -151,6 +156,12 @@ export async function getMissionStatus(mission: Mission): Promise<MissionStatusS
|
||||
};
|
||||
}
|
||||
|
||||
export async function getMissionStatus(mission: Mission): Promise<MissionStatusSummary> {
|
||||
const freshMission = await loadMission(mission.projectPath);
|
||||
const tasks = await readTasks(freshMission);
|
||||
return buildStatusSummary(freshMission, tasks);
|
||||
}
|
||||
|
||||
export async function getTaskStatus(mission: Mission, taskId: string): Promise<TaskDetail> {
|
||||
const freshMission = await loadMission(mission.projectPath);
|
||||
const tasks = await readTasks(freshMission);
|
||||
@@ -164,7 +175,7 @@ export async function getTaskStatus(mission: Mission, taskId: string): Promise<T
|
||||
throw new Error(`Duplicate task IDs found: ${taskId}`);
|
||||
}
|
||||
|
||||
const summary = await getMissionStatus(freshMission);
|
||||
const summary = await buildStatusSummary(freshMission, tasks);
|
||||
|
||||
return {
|
||||
missionId: freshMission.id,
|
||||
|
||||
Reference in New Issue
Block a user