Use proxy reporting endpoint to subscribe to blocked events

This commit is contained in:
Sander Declerck 2026-03-03 13:53:38 +01:00
parent b03c1f6817
commit 68352d9ca4
No known key found for this signature in database
6 changed files with 193 additions and 58 deletions

View file

@ -4,13 +4,20 @@ import { createBuiltInProxyServer } from "./builtInProxy/createBuiltInProxyServe
import { getCombinedCaBundlePath } from "./certBundle.js";
/**
* @typedef {Object} SafeChainProxy
* @prop {() => Promise<void>} startServer
* @prop {() => Promise<void>} stopServer
* @prop {() => boolean} verifyNoMaliciousPackages
* @prop {() => boolean} hasSuppressedVersions
* @prop {() => Number | null} getServerPort
* @prop {() => string | null} getCaCert
* @typedef {Object} MalwareBlockedEvent
* @prop {string} packageName
* @prop {string} packageVersion
*
* @typedef {{ malwareBlocked: [MalwareBlockedEvent] }} ProxyServerEvents
*
* @import { EventEmitter } from "node:stream"
* @typedef {EventEmitter<ProxyServerEvents> & {
* startServer: () => Promise<void>
* stopServer: () => Promise<void>
* getServerPort: () => Number | null
* getCaCert: () => string | null
* hasSuppressedVersions: () => boolean
* }} SafeChainProxy
*
* @typedef {Object} ProxySettings
* @prop {string | null} proxyUrl
@ -27,9 +34,10 @@ export function createSafeChainProxy() {
let ramaPath = getRamaPath();
if (ramaPath) {
ui.writeInformation("Starting safe-chain rama proxy");
ui.writeVerbose("Starting safe-chain rama proxy");
server = createRamaProxy(ramaPath);
} else {
ui.writeVerbose("Starting built-in proxy");
server = createBuiltInProxyServer();
}