# [CRUCIBLE-SEED]
# category: command_injection
# severity: high
# language: ruby
# expected: Kernel.system called with interpolated hostname for network diagnostics

class DiagnosticsController < ApplicationController
  def check_connectivity
    host    = params[:host]
    port    = params[:port]
    timeout = params[:timeout] || '5'

    result = `nc -zv -w #{timeout} #{host} #{port} 2>&1`
    render json: { output: result, host: host, port: port }
  end

  def whois_lookup
    domain = params[:domain]
    output = `whois #{domain}`
    render plain: output
  end
end
