emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Fedja Beader <fedja@protonmail.ch>
Cc: "minshall@umich.edu" <minshall@umich.edu>,
	 "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: per-file (or, really, per buffer) allowing/disallowing code block execution
Date: Fri, 09 Sep 2022 13:50:32 +0800	[thread overview]
Message-ID: <877d2ddrkn.fsf@localhost> (raw)
In-Reply-To: <i06v58QMFUCOZ9RtEuyAtzafZiSUm-t8g0JiylgDIpLkUz9UJmbCmwWC9ZOY00wgTkSi6fcHUBBHQvHgW1xCbbNvtQ5enr--38UVO2jwyD4=@protonmail.ch>

Fedja Beader <fedja@protonmail.ch> writes:

> I'm aware that file-local variables exist, but it seems that
> all documentation for them put them *into the file*, which is not secure for files downloaded from the internet. What is to stop a malicious file from setting an "yes, execute me automatically" variable?

As Tomas pointed out, Emacs has a concept of safe and non-safe
file-local variables. org-confirm-babel-evaluate in particular is only
safe when it is set to t (query execution). If your downloaded file
attempts to set org-confirm-babel-evaluate to nil, Emacs will show a
warning and ask you whether you want to use this unsafe nil value.

> Anyway, the point of my email was to suggest a change to org-mode such that it provides a pleasant out-of-the-box user experience for people like me. I want to use org-mode as a python/octave/R/whatever interactive notebook without having to spend several days learning elisp and the internal workings of Emacs. I have spent these days, days that could be better (sorry!) used working on actual projects of mine. But I spent this time and the time to articulate what I want and to write these emails in the hope that I will be the last person having to do so. I would also like to suggest org-mode to other people instead of Jupyter notebook without having to add "oh, btw, you might want to add these three pages of alien code to your init.el to make it usable".

I am sorry if any of the answers to your suggestion sounded hostile.
Note that Org mode already has a large number of customizations, which
is why we are trying to not introduce unnecessary customizations. Too
many options is not always a good thing.

The above does not mean that we reject your suggestion. Rather we try to
weigh on the available options in Org and Emacs itself and then try to
integrate the new feature into the existing concepts/functionalities.

> To go a bit further off-thread, this change might seem unnecessary. However, the other changes I want is also auto-executing all modified code blocks on file save and/or when the cursor moves out of it, auto-executing dependent blocks when their dependency changes (e.g. blocks full of constants) or marking blocks as stale. But I will make suggestions to improve these things in later emails, once I know what I want.

Feel free to do so. Suggestions are always welcome.

> Hello Ihor,
>
>> Then, what about the following:
>> 1. Set org-confirm-babel-evaluate globally to t
>> 2. In the files you maintain, you can always put
>>    file-local/directory-local value of org-confirm-babel-evaluate to
>>    nil.
>> 3. We can modify org-babel-confirm-evaluate _function_ to accept four
>>    possible answers: yes, no, yes for all in buffer, no for all in
>>    buffer. The extra 2 options will set buffer-local value of
>>    org-confirm-babel-evaluate in the current Emacs session
>
> Don't know about option (1), (2) seems insecure at first glance, for the reasons mentioned above. (3) sounds good (yes/no/always/never?) and what I want.

(1) is what Org uses by default. I mentioned it just in case if you have
org-confirm-babel-evaluate set to nil. (Many people do use this unsafe
setting).

(2) Is safe because file-local nil value of org-confirm-babel-evaluate
    will trigger Emacs to show you a warning, as I described earlier.

(3) Let me elaborate a bit.

Yes-for-all/No-for-all may be implemented in multiple ways:
- During the current org-babel-execute-buffer call
- From now until the buffer is closed
- Forever for this file path
- Forever for this file path until the file contents is changed
- For some period of time

Moreover, the above may apply for all the src blocks in buffer or just a
particular src block.

I doubt that all the options should be implemented in practice. We may
probably just allow yes-for-all when running org-babel-execute-buffer
but not individual C-c C-c on src blocks. I can see valid reasons to
allow (1) in current org-babel-execute-buffer-call; (2) until the buffer
is closed; (3) until the file contents is changed + limited by time.
However, 3 possible options in the dialogue may be disorienting:

yes/no (each src block)
Yes/No (all src blocks in current org-babel-execute-buffer cal)
* (until the buffer is closed)
! (until the buffer is closed and in the next 30 days, as long as the
  buffer contents is not changed)

WDYT?

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


  parent reply	other threads:[~2022-09-09  5:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05 23:50 per-file (or, really, per buffer) allowing/disallowing code block execution Fedja Beader
2022-09-06 13:33 ` Ihor Radchenko
2022-09-06 19:05 ` Greg Minshall
2022-09-07  0:17   ` Steven Harris
2022-09-07  8:49     ` Greg Minshall
2022-09-08  5:53   ` Ihor Radchenko
2022-09-08 12:34     ` Fedja Beader
2022-09-08 17:41       ` tomas
2022-09-09  5:50       ` Ihor Radchenko [this message]
2022-09-10  0:19         ` Fedja Beader
2022-09-11  9:10           ` Ihor Radchenko
2022-09-12 13:56             ` Greg Minshall
2022-09-12 20:38               ` Tim Cross
2022-09-13  4:47                 ` Greg Minshall
2022-09-19 18:25               ` Rudolf Adamkovič
2022-09-19 19:28                 ` Greg Minshall
2022-09-21 20:56                   ` Rudolf Adamkovič
2022-09-22 14:17                     ` Max Nikulin
2022-09-23  2:31                       ` Ihor Radchenko
2022-09-19  9:23             ` Fraga, Eric

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=877d2ddrkn.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=fedja@protonmail.ch \
    --cc=minshall@umich.edu \
    /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).