Sha256: da89d373f54ad55bb5fc1d1d79980d962670a755ceb3949376155cd0f2fc38f5

Contents?: true

Size: 560 Bytes

Versions: 20

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true

require "safe_shell"

module Mihari
  module Controllers
    class CommandController < BaseController
      post "/api/command" do
        param :command, String, required: true

        command = params["command"]
        if command.nil?
          status 400
          return json({ message: "command is required" })
        end

        command = command.split

        output = SafeShell.execute("mihari", *command)
        success = $?.success?

        json({ output: output, success: success })
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mihari-3.9.0 lib/mihari/web/controllers/command_controller.rb
mihari-3.8.1 lib/mihari/web/controllers/command_controller.rb
mihari-3.8.0 lib/mihari/web/controllers/command_controller.rb
mihari-3.7.2 lib/mihari/web/controllers/command_controller.rb
mihari-3.7.1 lib/mihari/web/controllers/command_controller.rb
mihari-3.7.0 lib/mihari/web/controllers/command_controller.rb
mihari-3.6.1 lib/mihari/web/controllers/command_controller.rb
mihari-3.6.0 lib/mihari/web/controllers/command_controller.rb
mihari-3.5.0 lib/mihari/web/controllers/command_controller.rb
mihari-3.4.1 lib/mihari/web/controllers/command_controller.rb
mihari-3.4.0 lib/mihari/web/controllers/command_controller.rb
mihari-3.3.0 lib/mihari/web/controllers/command_controller.rb
mihari-3.2.0 lib/mihari/web/controllers/command_controller.rb
mihari-3.1.0 lib/mihari/web/controllers/command_controller.rb
mihari-3.0.1 lib/mihari/web/controllers/command_controller.rb
mihari-3.0.0 lib/mihari/web/controllers/command_controller.rb
mihari-2.4.0 lib/mihari/web/controllers/command_controller.rb
mihari-2.3.1 lib/mihari/web/controllers/command_controller.rb
mihari-2.3.0 lib/mihari/web/controllers/command_controller.rb
mihari-2.2.1 lib/mihari/web/controllers/command_controller.rb