MCPcopy
hub / github.com/lissy93/web-check / shodanHandler

Function shodanHandler

api/shodan.js:7–19  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

5
6// Server-side Shodan lookup so the API key never touches the client
7const shodanHandler = async (url) => {
8 const auth = requireEnv('SHODAN_API_KEY', 'Shodan');
9 if (auth.skipped) return auth;
10 const { hostname } = parseTarget(url);
11 try {
12 const res = await httpGet(`https://api.shodan.io/shodan/host/${hostname}?key=${auth.value}`, {
13 timeout: 8000,
14 });
15 return res.data;
16 } catch (error) {
17 return upstreamError(error, 'Shodan lookup');
18 }
19};
20
21export const handler = middleware(shodanHandler);
22export default handler;

Callers

nothing calls this directly

Calls 4

requireEnvFunction · 0.90
parseTargetFunction · 0.90
httpGetFunction · 0.90
upstreamErrorFunction · 0.90

Tested by

no test coverage detected