A helper was generated to send webhooks after validating the target URL.
Node.js microservice sending outbound webhooks to user-supplied URLs.
Select suspicious lines in the terminal to flag them before submitting your verdict.
const axios = require('axios');
const { URL } = require('url');
async function sendWebhook(targetUrl, payload) {
const parsed = new URL(targetUrl);
const blocked = ['localhost', '127.0.0.1', '0.0.0.0', '[::1]'];
if (blocked.includes(parsed.hostname)) {
throw new Error('Internal addresses not allowed');
}
const response = await axios.post(targetUrl, payload, {
timeout: 5000,
maxRedirects: 5
});
return response.status;
}