Code Room
Code reviewMediumcr-g030
Subject Command injectionLevel Mid–Senior~20 minCommon in Security interviewsIndustries Software development

Question

Review this Node.js diagnostics endpoint on a network appliance.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewjs
const { exec } = require('child_process'); app.post('/api/ping', (req, res) => {  const host = req.body.host;  exec(`ping -c 3 ${host}`, (err, stdout) => {    if (err) return res.status(500).json({ error: 'ping failed' });    res.json({ output: stdout });  });});
Run or narrate your approach, then ask the coach.