Some checks failed
Deploy (Gitea) / deploy (push) Failing after 2s
- BOUNCER-PRIVACY-TAGS → *DISPATCHER-PRIVACY-TAGS* - BOUNCER-SHELL-TIMEOUT → *DISPATCHER-SHELL-TIMEOUT* - BOUNCER-SHELL-MAX-OUTPUT → *DISPATCHER-SHELL-MAX-OUTPUT* - bouncer-privacy-tags docstrings → Dispatcher privacy tags - 'Bouncer' in log messages, docstrings, test descriptions - 'Bouncer Security Dispatcher' → 'Security Dispatcher'
27 lines
1.3 KiB
Common Lisp
27 lines
1.3 KiB
Common Lisp
(defun actuator-shell-execute (action context)
|
|
"Executes a shell command via the OS timeout binary with output limit."
|
|
(declare (ignore context))
|
|
(let* ((payload (getf action :payload))
|
|
(cmd (getf payload :cmd))
|
|
(timeout-sym (find-symbol "*DISPATCHER-SHELL-TIMEOUT*" :passepartout))
|
|
(timeout (or (getf payload :timeout) (if timeout-sym (symbol-value timeout-sym) 30)))
|
|
(max-sym (find-symbol "*DISPATCHER-SHELL-MAX-OUTPUT*" :passepartout))
|
|
(max-output (or (getf payload :max-output) (if max-sym (symbol-value max-sym) 100000))))
|
|
(log-message "ACT [Shell]: ~a (timeout: ~as)" cmd timeout)
|
|
(multiple-value-bind (out err code)
|
|
(uiop:run-program (list "timeout" (format nil "~a" timeout) "bash" "-c" cmd)
|
|
:output :string :error-output :string
|
|
:ignore-error-status t)
|
|
(cond
|
|
((= code 124) (format nil "ERROR: Command timed out after ~a seconds" timeout))
|
|
((> (length out) max-output)
|
|
(format nil "~a~%... (output truncated to ~a chars)" (subseq out 0 max-output) max-output))
|
|
((= code 0) out)
|
|
(t (format nil "ERROR [~a]: ~a" code err))))))
|
|
|
|
(register-actuator :shell #'actuator-shell-execute)
|
|
|
|
(defskill :passepartout-system-actuator-shell
|
|
:priority 50
|
|
:trigger (lambda (ctx) (declare (ignore ctx)) nil))
|