Equivalent to a WAR File in Common Lisp

I have a system written in Lisp that runs the end machines. I would like to dynamically load the definition of the state machine and any necessary assets (images, etc.) from the directory, given only the directory name. There will be several different state machines. It is similar, but not identical, to downloading Apache and running the WAR file.

My concern is that just compiling and downloading a file can start literally everything. Ideally, I would like to get only the definition of the final machine, configure it using the asset path and make it available for execution. Now I am playing with loading a class that implements a specific base class, but it is not so simple. Is there a standard technique for this?

Thank.

+4
source share
2 answers

Are you saying you are worried about the possibility of arbitrary code execution from reading in a file? Therefore, I have to revise the reading table to exclude unwanted characters.

For an example checkout this , search for "SAFE-READ-FROM-STRING".

It is not complete, but then you can use # 'read to get the data structure, perform some health checks and compile if you need to.

If this is not what you were looking for, then my apologies, could you further explain what you are looking for?

+3
source

, , :

(defmacro def-state-machine (name (&rest assets) &rest states)
  `(defparameter ,name
     (list
       :assets ',(remove-if-not #'legal-asset? assets)
       :states ',(remove-if-not #'legal-state? states))))

( , , - , e , ).

, :

(defmacro def-transition (name args &body body)
  `(defun ,name (,@args)
     ,@body))

. , :

(defun load-toy-state-machine (directory)
  (let ((path (cl-fad:merge-pathnames-as-file directory #P"machine.lisp"))
        ;(*readtable* (copy-readtable nil))
       )
    ; (make-dispatch-macro-character #\#)
    (with-open-file (stream path :direction :input)
      (do ((form (read stream nil 'done)
                 (read stream nil 'done)))
          ((eql form 'done) T)
        (if (member (car form) '(def-state-machine def-transition))
            (eval form)
            (error "malformed state machine definition file"))))))

(def-state-machine def-transition), . .

+1

All Articles