MCPcopy Create free account
hub / github.com/GDATASoftwareAG/vaas / forRequest

Method forRequest

typescript/src/Vaas.ts:176–210  ·  view source on GitHub ↗
(sample: string | Uint8Array)

Source from the content-addressed store, hash-verified

174 }
175
176 private async forRequest(sample: string | Uint8Array): Promise<VaasVerdict> {
177 const ws = this.getAuthenticatedWebSocket();
178 return new Promise((resolve, reject) => {
179 const guid = uuidv4();
180 if (this.debug) console.debug("uuid", guid);
181 this.verdictPromises.set(guid, {
182 resolve: async (verdictResponse: VerdictResponse) => {
183 if (
184 verdictResponse.verdict === Verdict.UNKNOWN &&
185 typeof sample !== "string"
186 ) {
187 await this.upload(verdictResponse, sample, sample.length);
188 return;
189 }
190
191 this.verdictPromises.delete(guid);
192 resolve(
193 new VaasVerdict(verdictResponse.sha256, verdictResponse.verdict, verdictResponse.detection, verdictResponse.file_type, verdictResponse.mime_type),
194 );
195 },
196 reject: (reason) => reject(reason),
197 });
198
199 let hash =
200 typeof sample === "string"
201 ? sample
202 : Vaas.toHexString(sha256.hash(sample));
203 const verdictReq = JSON.stringify(
204 defaultSerializer.serialize(
205 new VerdictRequest(hash, guid, this.connection!.sessionId as string),
206 ),
207 );
208 ws.send(verdictReq);
209 });
210 }
211
212 private async forUrlRequest(url: URL): Promise<VaasVerdict> {
213 const ws = this.getAuthenticatedWebSocket();

Callers 2

forSha256Method · 0.95
forFileMethod · 0.95

Calls 3

uploadMethod · 0.95
toHexStringMethod · 0.80

Tested by

no test coverage detected