T09 · Insecure Skill Coding Practices
- Location
scripts/process.js:122- Finding
Destination Image Redaction Fails Open
- Content
View full analysis
{ const t = l.text.replace(/\s+/g, ''); return (t.match(/终[点炭]/)) && l.bbox.y0 > cardTop && l.bbox.y0 < timeLine.bbox.y0; }); let mosaicRegions = []; if (destLine) { const destWords = ocrData.words.filter(w => w.bbox.y0 >= destLine.bbox.y0 - 5 && w.bbox.y1 <= destLine.bbox.y1 + 5 && !['终', '点', '炭', ':', ':'].includes(w.text) ); if (destWords.length >= 2) { const first = destWords[0]; const last = destWords[destWords.length - 1]; mosaicRegions.push({ left: first.bbox.x1 + 3, top: destLine.bbox.y0 - 2, width: Math.max(0, last.bbox.x0 - first.bbox.x1 - 6), height: destLine.bbox.y1 - destLine.bbox.y0 + 4, }); } } const imgMeta = await sharp(srcImg).metadata(); const cropTop = Math.max(0, cardTop); const cropHeight = Math.min(imgMeta.height - cropTop, cardBottom - cardTop); // Build composite overlay list for single pipeline let overlays = []; for (const reg of mosaicRegions) { const relTop = reg.top - cropTop; if (reg.width > 0 && reg.height > 0) { try { const block = await sharp({ create: { width: reg.width, height: reg.height, channels: 3, background: { r: 255, g: 255, b: 255 } } }).png().toBuffer(); overlays.push({ input: block, left: reg.left, top: relTop }); console.log(` [mosaic] block: ${reg.left},${relTop} ${reg.width}x${reg.height}`); } catch (e) { console.warn(' Mosaic failed for', order.date, e.message); } } } // Single pipeline: crop + composite + save let pipeline = sharp(srcImg).extract({ left: 0, top: cropTop, width: imgMeta.width, height: cropHeight }); if (overlays.length > 0) { pipeline = pipeline.composite(overlays); } ...[truncated 3223 chars]- Remediation
View remediation
