mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-12 19:55:14 +02:00
19 lines
478 B
Ruby
19 lines
478 B
Ruby
# Phase 15 — Hanami Action.call, benign.
|
|
# Validates payload before running the fixed echo.
|
|
|
|
# nyx-shape: hanami
|
|
# nyx-route: GET /run
|
|
require 'hanami/action'
|
|
|
|
class RunAction < Hanami::Action
|
|
def call(req)
|
|
payload = req && req.is_a?(Hash) ? (req['nyx.payload'] || '') : (ENV['NYX_PAYLOAD'] || '')
|
|
unless payload =~ /\A[A-Za-z0-9]{1,32}\z/
|
|
STDOUT.print("invalid\n")
|
|
return "invalid"
|
|
end
|
|
out = `echo hello`
|
|
STDOUT.print(out)
|
|
out
|
|
end
|
|
end
|