T-29: lint:check fails on existing issues, so bun run check (M0 exit criterion 1) can't go green
This commit is contained in:
parent
88023ba643
commit
1720e45f70
5 changed files with 43 additions and 31 deletions
|
|
@ -167,8 +167,8 @@ const VALID_IPV6_ZONE_ID = /^[a-z0-9._~-]+$/i;
|
|||
// Any URL authority/path/query/fragment delimiter, whitespace, or control char inside a
|
||||
// decoded MongoDB seed host would be re-interpreted by ServerDescription.hostAddress's
|
||||
// WHATWG URL re-parse (e.g., "localhost%2f:27018" -> "localhost/:27018" -> localhost:27017).
|
||||
const FORBIDDEN_MONGO_HOST_CHARS = /[/?#@:\\[\],\s\x00-\x1f\x7f]/;
|
||||
const FORBIDDEN_MONGO_IPV6_HOST_CHARS = /[/?#@\\[\],\s\x00-\x1f\x7f]/;
|
||||
const FORBIDDEN_MONGO_HOST_CHARS = /[/?#@:\\[\],\s]/;
|
||||
const FORBIDDEN_MONGO_IPV6_HOST_CHARS = /[/?#@\\[\],\s]/;
|
||||
|
||||
function isValidIpv6WithZoneId(host: string): boolean {
|
||||
const zoneIdx = host.indexOf('%');
|
||||
|
|
@ -216,7 +216,7 @@ function decodeMongoHost(rawHost: string, isBracketedIpv6 = false): string {
|
|||
const forbiddenChars = isBracketedIpv6
|
||||
? FORBIDDEN_MONGO_IPV6_HOST_CHARS
|
||||
: FORBIDDEN_MONGO_HOST_CHARS;
|
||||
if (forbiddenChars.test(current)) {
|
||||
if (hasAsciiControlChar(current) || forbiddenChars.test(current)) {
|
||||
throw new Error(`Safety guard: invalid characters in MongoDB host "${rawHost}".`);
|
||||
}
|
||||
return current.toLowerCase();
|
||||
|
|
|
|||
|
|
@ -328,14 +328,17 @@ export class ResearchAgentsService {
|
|||
const url = new URL(request.url);
|
||||
const path = url.pathname;
|
||||
const project = /^\/api\/v2\/research-projects\/([^/]+)(?:\/|$)/.exec(path);
|
||||
if (project && !allowedProjectIds.includes(project[1]!.toLowerCase())) {
|
||||
return deny();
|
||||
if (project) {
|
||||
const projectId = project[1];
|
||||
if (!projectId || !allowedProjectIds.includes(projectId.toLowerCase())) {
|
||||
return deny();
|
||||
}
|
||||
}
|
||||
if (request.method === 'GET' || request.method === 'HEAD') {
|
||||
const narrative = /^\/api\/v2\/(hypotheses|analysis-artifacts)\/([^/]+)(?:\/|$)/.exec(path);
|
||||
if (narrative) {
|
||||
const narrativeId = narrative[2]!;
|
||||
if (!strictUuid.test(narrativeId)) {
|
||||
const narrativeId = narrative[2];
|
||||
if (!narrativeId || !strictUuid.test(narrativeId)) {
|
||||
return deny();
|
||||
}
|
||||
const table = narrative[1] === 'hypotheses' ? 'research_hypotheses' : 'analysis_artifacts';
|
||||
|
|
@ -347,21 +350,28 @@ export class ResearchAgentsService {
|
|||
}
|
||||
}
|
||||
const backtest = /^\/api\/v2\/backtests\/([^/]+)(?:\/|$)/.exec(path);
|
||||
if (backtest && !grantedBacktestIds.includes(backtest[1]!.toLowerCase())) {
|
||||
return deny();
|
||||
if (backtest) {
|
||||
const backtestId = backtest[1];
|
||||
if (!backtestId || !grantedBacktestIds.includes(backtestId.toLowerCase())) {
|
||||
return deny();
|
||||
}
|
||||
}
|
||||
if (path === '/api/v2/experiments/compare') {
|
||||
const leftIds = url.searchParams.getAll('leftId');
|
||||
const rightIds = url.searchParams.getAll('rightId');
|
||||
const leftId = leftIds[0];
|
||||
const rightId = rightIds[0];
|
||||
if (
|
||||
leftIds.length !== 1 ||
|
||||
rightIds.length !== 1 ||
|
||||
!strictUuid.test(leftIds[0]!) ||
|
||||
!strictUuid.test(rightIds[0]!)
|
||||
!leftId ||
|
||||
!rightId ||
|
||||
!strictUuid.test(leftId) ||
|
||||
!strictUuid.test(rightId)
|
||||
) {
|
||||
return deny();
|
||||
}
|
||||
const uniqueIds = [...new Set([leftIds[0]!.toLowerCase(), rightIds[0]!.toLowerCase()])];
|
||||
const uniqueIds = [...new Set([leftId.toLowerCase(), rightId.toLowerCase()])];
|
||||
const rows = (
|
||||
await this.database.query(
|
||||
'SELECT id,submission_principal FROM research_experiments WHERE id=ANY($1::uuid[])',
|
||||
|
|
@ -387,8 +397,8 @@ export class ResearchAgentsService {
|
|||
const experiment =
|
||||
/^\/api\/v2\/experiments\/(walk-forward\/|validation\/)?([^/]+)(?:\/|$)/.exec(path);
|
||||
if (experiment) {
|
||||
const experimentId = experiment[2]!;
|
||||
if (!strictUuid.test(experimentId)) {
|
||||
const experimentId = experiment[2];
|
||||
if (!experimentId || !strictUuid.test(experimentId)) {
|
||||
return deny();
|
||||
}
|
||||
const table =
|
||||
|
|
@ -405,8 +415,8 @@ export class ResearchAgentsService {
|
|||
}
|
||||
const run = /^\/api\/v2\/runs\/([^/]+)(?:\/|$)/.exec(path);
|
||||
if (run) {
|
||||
const runId = run[1]!;
|
||||
if (!strictUuid.test(runId)) {
|
||||
const runId = run[1];
|
||||
if (!runId || !strictUuid.test(runId)) {
|
||||
return deny();
|
||||
}
|
||||
const owned = (
|
||||
|
|
@ -418,8 +428,8 @@ export class ResearchAgentsService {
|
|||
}
|
||||
const strategy = /^\/api\/v2\/strategies\/([^/]+)(?:\/|$)/.exec(path);
|
||||
if (strategy) {
|
||||
const strategyId = strategy[1]!;
|
||||
if (!strictUuid.test(strategyId)) {
|
||||
const strategyId = strategy[1];
|
||||
if (!strategyId || !strictUuid.test(strategyId)) {
|
||||
return deny();
|
||||
}
|
||||
const permittedStrategy = (
|
||||
|
|
@ -439,8 +449,8 @@ export class ResearchAgentsService {
|
|||
}
|
||||
const strategyVersion = /^\/api\/v2\/strategy-versions\/([^/]+)(?:\/|$)/.exec(path);
|
||||
if (strategyVersion) {
|
||||
const versionId = strategyVersion[1]!;
|
||||
if (!strictUuid.test(versionId)) {
|
||||
const versionId = strategyVersion[1];
|
||||
if (!versionId || !strictUuid.test(versionId)) {
|
||||
return deny();
|
||||
}
|
||||
const permittedVersion = (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue