@codefresh-io/ssrf-safe
v0.1.0
Published
Ssrf check for requests
Downloads
275
Maintainers
Keywords
Readme
ssrf-safe
nodejs lib for SSRF safe request and filter
Example for GET
Modify code:
try {
return await request({
method: 'GET',
uri,
});
} catch (cause) {
throw new NotFoundError({ cause });
}
By adding options
const { requestSsrfOptions } = require('@codefresh-io/ssrf-safe');
const options = requestSsrfOptions({ url: uri });
try {
return await request({
method: 'GET',
...options
});
} catch (cause) {
throw new NotFoundError({ cause });
}
Example generic
add filter agent to the options
const options = { uri };
try {
return await request(
requestSsrfOptions({ options })
);
} catch (cause) {
throw new NotFoundError({ cause });
}
Using logs
const options = { uri };
try {
return await request(
requestSsrfOptions({ options })
);
} catch (cause) {
logSsrfError(err, logger.warning);
throw new NotFoundError({ cause });
}