function handleProxyReq()

in cloudrun-malware-scanner/gcs-proxy-server.ts [85:100]


function handleProxyReq(
  proxyReq: ClientRequest,
  req: IncomingMessage,
  res: ServerResponse,
): void {
  if (proxyReq.path?.startsWith(`/${clamCvdMirrorBucket}/`)) {
    logger.info(`Proxying request for ${proxyReq.path} to GCS`);
    proxyReq.setHeader('Authorization', 'Bearer ' + accessToken);
  } else {
    logger.error(`Denying Proxy request for ${proxyReq.path} to GCS - 403`);
    res.writeHead(403, {
      'Content-Type': 'text/plain',
    });
    res.end('Failed to proxy to GCS - unauthorzied path: status 403\n');
  }
}