mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Better header check + remove last-modified header
This commit is contained in:
parent
40523f29dd
commit
290a630526
2 changed files with 47 additions and 20 deletions
|
|
@ -231,23 +231,6 @@ describe("npmInterceptor minimum package age", async () => {
|
|||
assert.equal(modifiedJson["dist-tags"]["alpha"], undefined);
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {import("../interceptorBuilder.js").Interceptor} interceptor
|
||||
* @param {string} body
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async function runModifyNpmInfoRequest(url, body) {
|
||||
const interceptor = npmInterceptorForUrl(url);
|
||||
const requestHandler = await interceptor.handleRequest(url);
|
||||
|
||||
if (requestHandler.modifiesResponse()) {
|
||||
const modifiedBuffer = requestHandler.modifyBody(Buffer.from(body));
|
||||
return modifiedBuffer.toString("utf8");
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
it("Should not filter packages when skipMinimumPackageAge is enabled", async () => {
|
||||
minimumPackageAgeSettings = 5;
|
||||
skipMinimumPackageAgeSetting = true;
|
||||
|
|
@ -296,4 +279,23 @@ describe("npmInterceptor minimum package age", async () => {
|
|||
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../interceptorBuilder.js").Interceptor} interceptor
|
||||
* @param {string} body
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async function runModifyNpmInfoRequest(url, body) {
|
||||
const interceptor = npmInterceptorForUrl(url);
|
||||
const requestHandler = await interceptor.handleRequest(url);
|
||||
|
||||
if (requestHandler.modifiesResponse()) {
|
||||
const modifiedBuffer = requestHandler.modifyBody(Buffer.from(body), {
|
||||
["content-type"]: "application/json",
|
||||
});
|
||||
return modifiedBuffer.toString("utf8");
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue