~williewillus/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH r16] Display custom-write? results in sandbox context

eutro
Details
Message ID
<20210328081032.96317-1-benedek.szilvasy@gmail.com>
DKIM signature
pass
Download raw message
Patch: +13 -7
---
 evaluator.rkt | 16 +++++++++++-----
 main.rkt      |  4 ++--
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/evaluator.rkt b/evaluator.rkt
index 3b93002..bfc8f9c 100644
--- a/evaluator.rkt
+++ b/evaluator.rkt
@@ -74,14 +74,20 @@

(define (run code definitions)
  (parameterize ([current-environment-variables (make-environment-variables)])
    (let* ((evaluator (init-evaluator definitions))
           (results (call-with-values
    (let* ([evaluator (init-evaluator definitions)]
           [results (call-with-values
                     (thunk
                      (with-handlers ([(const #t) identity])
                        (evaluator code)))
                     list))
           (stdout (get-output evaluator))
           (stderr (get-error-output evaluator)))
                     (lambda results
                       (map
                        (lambda (result)
                          (if (custom-write? result)
                              (call-in-sandbox-context evaluator (thunk (~a result)))
                              result))
                        results)))]
           [stdout (get-output evaluator)]
           [stderr (get-error-output evaluator)])
      (kill-evaluator evaluator)
      (apply values
             `(,stdout
diff --git a/main.rkt b/main.rkt
index 302c66a..e9b7186 100755
--- a/main.rkt
+++ b/main.rkt
@@ -389,7 +389,7 @@
(define (empty-string? s)
  (and (string? s) (= (string-length s) 0)))

(define (create-message-with-contents client channel message . contents)
(define ((create-message-with-contents client channel message) . contents)
  (let* ([content (apply ~a #:separator "\n"
                         (filter-not (disjoin void? http:attachment? empty-string?)
                                     contents))]
@@ -411,7 +411,7 @@
      (match-let ([(cons func content) (parse-command content)])
        (when func
          (call-with-values (thunk (func client db message content))
                            (curry create-message-with-contents client channel message)))))))
                            (create-message-with-contents client channel message)))))))

(define (init-client folder token)
  (log-r16-info "Storing tricks in ~a" folder)
-- 
2.31.0

[r16/patches/linux_buildtest.yml] build success

builds.sr.ht
Details
Message ID
<CA8TZVJ1LXJN.33K5VSTTDSLW8@cirno>
In-Reply-To
<20210328081032.96317-1-benedek.szilvasy@gmail.com> (view parent)
DKIM signature
missing
Download raw message
r16/patches/linux_buildtest.yml: SUCCESS in 1m35s

[Display custom-write? results in sandbox context][0] from [eutro][1]

[0]: https://lists.sr.ht/~williewillus/public-inbox/patches/21551
[1]: benedek.szilvasy@gmail.com

✓ #471471 SUCCESS r16/patches/linux_buildtest.yml https://builds.sr.ht/~williewillus/job/471471
Details
Message ID
<40dd03f3-9cb1-30da-3a1c-590592ce090d@gmail.com>
In-Reply-To
<20210328081032.96317-1-benedek.szilvasy@gmail.com> (view parent)
DKIM signature
pass
Download raw message
On 3/28/21 3:10 AM, eutro wrote:

> -                     list))
> -           (stdout (get-output evaluator))
> -           (stderr (get-error-output evaluator)))
> +                     (lambda results
> +                       (map
> +                        (lambda (result)
> +                          (if (custom-write? result)
> +                              (call-in-sandbox-context evaluator (thunk (~a result)))
> +                              result))
> +                        results)))]
> +           [stdout (get-output evaluator)]
> +           [stderr (get-error-output evaluator)])

 - would `(compose1 (curry map (lambda …)) list)` be too overkill? :wacko:

 - is there a need to check `custom-write?` manually? why not just ~a
everything in the sandbox?

 - on a similar note, this performs one top-level invoke of the e'tor
*per* result, each of which resets the timer, which means you can
compute for arbitrarily long by returning something like:

> (apply values
>   (build-list 8888
>     (const [malicious expr])))
Reply to thread Export thread (mbox)