T-4: M0.4b — Close sb-research.* holdout leak: 403 on dataset /export and ungranted project GETs
This commit is contained in:
parent
13eb8352f3
commit
420e77f837
17 changed files with 788 additions and 1123 deletions
|
|
@ -142,13 +142,21 @@ export class BacktestRuns {
|
|||
return mapRun(at(result.rows, 0));
|
||||
}
|
||||
|
||||
async listRuns(backtestId: string): Promise<Run[]> {
|
||||
const result = await this.container.postgres.query(
|
||||
`SELECT * FROM runs
|
||||
WHERE backtest_id = $1
|
||||
ORDER BY run_number DESC`,
|
||||
[backtestId]
|
||||
);
|
||||
async listRuns(backtestId: string, agentId?: string): Promise<Run[]> {
|
||||
const result =
|
||||
agentId !== undefined
|
||||
? await this.container.postgres.query(
|
||||
`SELECT * FROM runs
|
||||
WHERE backtest_id = $1 AND research_agent_id = $2
|
||||
ORDER BY run_number DESC`,
|
||||
[backtestId, agentId]
|
||||
)
|
||||
: await this.container.postgres.query(
|
||||
`SELECT * FROM runs
|
||||
WHERE backtest_id = $1
|
||||
ORDER BY run_number DESC`,
|
||||
[backtestId]
|
||||
);
|
||||
|
||||
return result.rows.map(row => mapRun(row));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,23 @@ export class BacktestTemplates {
|
|||
limit: number;
|
||||
offset: number;
|
||||
includeArchived?: boolean;
|
||||
agentId?: string;
|
||||
}): Promise<Backtest[]> {
|
||||
if (params.agentId !== undefined) {
|
||||
const result = await this.container.postgres.query(
|
||||
`SELECT b.* FROM backtests b
|
||||
JOIN research_agents a ON a.id = $4
|
||||
WHERE ($3::boolean OR b.archived_at IS NULL)
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM jsonb_array_elements(a.policy->'grants') g
|
||||
WHERE g->>'backtestId' = b.id::text
|
||||
)
|
||||
ORDER BY b.created_at DESC
|
||||
LIMIT $1 OFFSET $2`,
|
||||
[params.limit, params.offset, params.includeArchived === true, params.agentId]
|
||||
);
|
||||
return result.rows.map(row => mapBacktest(row));
|
||||
}
|
||||
const result = await this.container.postgres.query(
|
||||
`SELECT * FROM backtests
|
||||
WHERE ($3::boolean OR archived_at IS NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue