fix(domain,app): own-key lookups for untrusted ids in the v2 migration, attachment and PDF size caps; EVAL-011, journal, TODO

This commit is contained in:
bchanot committed 2026-10-10 12:23:03 +02:00
1 parent 17a6d9b323
commit e7f4167ada
8 files changed
+76 -5

No files matched your search

+11 -3
View File
@@ -25,6 +25,11 @@ import {
* data survives any catalog change and stays identifiable.
*/
/** Own-key lookup: ids come from untrusted documents (`__proto__` is not an entry). */
function own<T>(record: Record<string, T>, key: string): T | undefined {
return Object.hasOwn(record, key) ? record[key] : undefined
}
const SEVERITY: Record<SeverityV2, Severity> = {
légère: 'mild',
modérée: 'moderate',
@@ -43,9 +48,9 @@ function migrateZone(
zone: ObservationZoneV2,
map: ReportMigrationMap,
): ReportZone {
const entry = map.annotations[zone.boneId]
const entry = own(map.annotations, zone.boneId)
const viewId = zone.detailSourceId
? (map.views[zone.detailSourceId] ?? zone.detailSourceId)
? (own(map.views, zone.detailSourceId) ?? zone.detailSourceId)
: map.main_view_id
const out: ReportZone = { annotationId: entry?.id ?? zone.boneId, viewId }
if (zone.side) out.side = zone.side
@@ -60,7 +65,10 @@ function migrateZone(
}
function migrateFinding(finding: FindingV2, map: ReportMigrationMap): Finding {
const mapped = map.finding_paths[findingPathKey(finding.zoneId, finding.path)]
const mapped = own(
map.finding_paths,
findingPathKey(finding.zoneId, finding.path),
)
const out: Finding = {
findingZoneId: finding.zoneId,
path: [...finding.path],