emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tom Gillespie <tgbugs@gmail.com>
To: Max Nikulin <manikulin@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] ob-core: add org-confirm-babel-evaluate-cell custom variable
Date: Sun, 11 Dec 2022 12:27:32 -0800	[thread overview]
Message-ID: <CA+G3_PNHe3J+PHzv_L+X1DR66TGc3sW5FxiJC5HqDd57N75P0w@mail.gmail.com> (raw)
In-Reply-To: <tn3h08$1099$1@ciao.gmane.io>

Hi Max,
   Thank you for the feedback. More replies in lines. Best!
Tom

> I am not sure concerning "exactly".
>
> lisp/ob-core.el:248
> `org-confirm-babel-evaluate' is called with 2 arguments. In your patch
> `org-confirm-babel-evaluate-cell' has a single argument.

You're right, and in point of fact I should have retained the structure
exactly because in other contexts I have thought about ways to use
other languages in contexts like that. At the moment everything is
elisp so I dropped the argument, but that is clearly a mistake.

> It seems, you do not change defaults. Could you, please, provide an
> example of configuration that is less annoying, but still safe?

#+begin_src elisp :results none
(setq-local
 org-confirm-babel-evaluate-cell
 (lambda (lang body)
   (ignore lang)
   (let ((rb (read body)))
     (not ; aka (unless condition t)
      (or
       (member rb
               '((or)
                 (and)
                 ;; add more forms that are known safe here
                 ))
       (and
        (eq (car rb) 'identity)
        (let ((v (cadr rb)))
          (or
           (symbolp v)
           (stringp v)
           (numberp v)
           ))))))))
#+end_src

#+header: :var v1=(or) v2=(and) v3=(identity nil)
#+header: :var v4=(identity default-directory) v5=(identity #o0755)
#+header: :var v6=(identity "not sure why you would want to do this")
#+header: :var v7=(identity (concat "this" "will" "fail"))
#+header: :var v8="reminder that strings are ok"
#+begin_src elisp
(mapcar
 #'list
 (list v1 v2 v3 v4 v5 v6 v7 v8))
#+end_src

> I was thinking if it is possible to collect requests to confirm and to
> allow the user to decide for the whole bunch of expressions and code
> blocks. Besides implementation issues, there is a question concerning UI
> that will allow to inspect code to be evaluated.

Yes, in the example above I thought about including something
with a yes-or-no-p where users could quickly add forms to a
safe list some (defcustom org-known-safe-cells '()) or something
like that. A user could do that with the new machinery, and we
could do the same for the default implementation. I think that
is the next step once we get the basics in place.

> Calling convention for the case of function value is not described. If
> it is really the same as for `org-confirm-babel-evaluate' then this user
> option should be mentioned in the docstring.

When I correct the function signature to actually match
I will make a note in the docstring.

> :package-version instead of :version?

I think because org is part of emacs core we use the emacs version?
I see "24.1" included with other org defcustoms.

> Is there any reason to not use the :safe property of `defcustom'? I see
> that you take definition of `org-confirm-babel-evaluate' as a template
> so I wonder if there is some particular reason or the original code was
> just written before introducing of :safe.

I'm guessing that it was written before :safe, but don't
know for sure. A systematic cleanup of stuff like that
could come after this maybe?


  reply	other threads:[~2022-12-11 20:28 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-10 20:28 [PATCH] ob-core: add org-confirm-babel-evaluate-cell custom variable Tom Gillespie
2022-12-11  2:58 ` Max Nikulin
2022-12-11 20:27   ` Tom Gillespie [this message]
2022-12-11 20:37     ` Tom Gillespie
2022-12-11 20:46     ` Kyle Meyer
2022-12-11 21:08       ` Tom Gillespie
2022-12-12 10:20         ` Ihor Radchenko
2022-12-13  1:53           ` Tom Gillespie
2022-12-13  9:03             ` Ihor Radchenko
2022-12-13 16:31             ` Max Nikulin
2022-12-13 21:16               ` Tom Gillespie
2022-12-14 16:40                 ` Max Nikulin
2022-12-14 18:24                   ` Tom Gillespie
2022-12-15  9:18                     ` Ihor Radchenko
2022-12-15  9:25                       ` Tom Gillespie
2022-12-15  9:57                       ` tomas
2022-12-15  9:10                   ` Ihor Radchenko
2022-12-15 12:10                     ` Max Nikulin
2022-12-15 12:25                       ` Ihor Radchenko
2022-12-15 14:46                         ` Max Nikulin
2022-12-15 21:08                           ` Tim Cross
2022-12-16  6:07                             ` Ihor Radchenko
2022-12-16  7:22                               ` Tim Cross
2022-12-18 14:19                                 ` Ihor Radchenko
2022-12-18 21:37                                   ` Tim Cross
2022-12-20  0:00                                     ` Tom Gillespie
2022-12-20  0:06                                       ` Tom Gillespie
2022-12-25 11:00                                         ` Ihor Radchenko
2022-12-18 14:12                           ` Ihor Radchenko
2022-12-25 11:06             ` Ihor Radchenko
2022-12-29 15:58               ` Bastien Guerry
2022-12-29 16:33                 ` Max Nikulin
2022-12-29 16:35                 ` Ihor Radchenko
2022-12-30  8:52                   ` Bastien
2022-12-30 11:10                     ` Max Nikulin
2022-12-30 17:43                     ` Tom Gillespie
2022-12-31 13:48                       ` Ihor Radchenko
2022-12-31 16:15                         ` Tom Gillespie
2023-01-02  8:34                         ` [SECURITY] Arbitrary code evaluation security in Org (was: [PATCH] ob-core: add org-confirm-babel-evaluate-cell custom variable) Ihor Radchenko
2023-01-02 10:59                           ` [SECURITY] Arbitrary code evaluation security in Org Greg Minshall
2023-01-03  9:52                             ` [SECURITY] Tangling can overwrite arbitrary tangling targets, including important user files (was: [SECURITY] Arbitrary code evaluation security in Org) Ihor Radchenko
2023-01-02 19:00                           ` [SECURITY] Arbitrary code evaluation security in Org (was: [PATCH] ob-core: add org-confirm-babel-evaluate-cell custom variable) Tim Cross
2023-01-03 11:00                             ` Ihor Radchenko
2023-01-07 13:12                               ` Ihor Radchenko
2023-01-02 15:13                         ` [PATCH] ob-core: add org-confirm-babel-evaluate-cell custom variable Bastien Guerry
2023-01-02 15:17                           ` Ihor Radchenko
2023-01-02 15:15                       ` Bastien
2022-12-13  4:16           ` Kyle Meyer
2022-12-13 16:15     ` Max Nikulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+G3_PNHe3J+PHzv_L+X1DR66TGc3sW5FxiJC5HqDd57N75P0w@mail.gmail.com \
    --to=tgbugs@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).