fix(workflows): resolve QA blockers and protect case evidence

Fix registrar signing, reviewer re-entry, replacement evidence freshness, owner decision and rating races, multipart objections, vehicle serialization and product reporting.

Validate uploaded media with FFmpeg, serve evidence through expiring signed links, and add targeted regressions plus a dry-run repair for prematurely completed visit cases.
This commit is contained in:
SepehrYahyaee
2026-11-22 12:50:22 +03:30
parent abc40df199
commit 6b968c0952
37 changed files with 1118 additions and 211 deletions
@@ -0,0 +1,75 @@
import {
CallHandler,
Controller,
ExecutionContext,
Get,
Injectable,
Module,
NestInterceptor,
Param,
Query,
Res,
ForbiddenException,
} from "@nestjs/common";
import { APP_INTERCEPTOR } from "@nestjs/core";
import {
EvidenceAccessService,
evidenceRequestScope,
} from "./evidence-access.service";
export { EvidenceAccessService } from "./evidence-access.service";
import { realpath } from "node:fs/promises";
import { resolve, sep } from "node:path";
import { Response } from "express";
import { map, Observable } from "rxjs";
@Injectable()
class EvidenceLinksInterceptor implements NestInterceptor {
constructor(private readonly access: EvidenceAccessService) {}
intercept(context: ExecutionContext, next: CallHandler) {
const req = context.switchToHttp().getRequest();
if (!req.user?.sub) return next.handle();
return new Observable((observer) =>
evidenceRequestScope.run(true, () =>
next
.handle()
.pipe(map((value) => this.access.project(value)))
.subscribe(observer),
),
);
}
}
@Controller("files")
class EvidenceController {
constructor(private readonly access: EvidenceAccessService) {}
@Get("*path")
async read(
@Param("path") raw: string | string[],
@Query("expires") expires: string,
@Query("signature") signature: string,
@Res() res: Response,
) {
const path = Array.isArray(raw) ? raw.join("/") : raw;
this.access.verify(path, expires, signature);
const root = await realpath(resolve("files"));
let target: string;
try {
target = await realpath(resolve(root, path));
} catch {
res.status(404).end();
return;
}
if (!target.startsWith(root + sep)) throw new ForbiddenException();
res.setHeader("Cache-Control", "private, no-store");
res.setHeader("X-Content-Type-Options", "nosniff");
// sendFile retains Range/HEAD support needed by video players.
res.sendFile(target);
}
}
@Module({
controllers: [EvidenceController],
providers: [
EvidenceAccessService,
{ provide: APP_INTERCEPTOR, useClass: EvidenceLinksInterceptor },
],
})
export class EvidenceAccessModule {}