unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Philip Kaludercic <philipk@posteo.net>
Cc: ELPA Maintainers <emacs-devel@gnu.org>
Subject: Re: Patches for elpa-admin
Date: Fri, 15 Apr 2022 00:01:22 -0400	[thread overview]
Message-ID: <jwvfsmf6mrm.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <874k2x8jhb.fsf@posteo.net> (Philip Kaludercic's message of "Wed,  13 Apr 2022 08:40:00 +0000")

> The somewhat recent addition to render markdown caused an error when
> building a package locally on my system, as the executable "markdown"
> was not installed.  So I gathered a number of implementations and
> had had `elpaa--section-to-html' use whatever is installed:

I wouldn't work that hard at it: I think the only important part of the
behavior is either "reproduces faithfully what will happen on
elpa.gnu.org" or "doesn't fail stupidly", so rather than try out all the
possible alternatives the most important part is to fail gracefully.

> +(defvar elpaa--markdown-candidates
> +  '("pandoc" "cmark" "marked" "discount"      ;ideally
> +    "lowdown" "hoedown" "sundown" "kramdown"  ;backup
> +    "markdown.pl" "markdown_py" "md2html.awk" ;fallback
> +    "markdown"                                ;despair
> +    ))

I think this list is "a bit over the top", but feel free to keep it.
OTOH, I think "markdown" should come first since that's what's used on
`elpa.gnu.org`.

> -            (elpaa--call-sandboxed t "markdown" input-filename))
> +            (elpaa--call-sandboxed t (elpa--markdown-executable) input-filename))

I think this is more than 80 columns, please wrap.

> +(cl-defmethod elpaa--sandbox-args ((_mechaism (eql bwrap)) args)
> +  (let ((dd (expand-file-name default-directory))) ;No `~' allowed!
> +    (setq args (cl-list* "--bind" dd dd args)))
> +  ;; Add read-only dirs in reverse order.
> +  (dolist (b (append elpaa--sandbox-ro-binds elpaa--sandbox-extra-ro-dirs))
> +    (when (file-exists-p b)         ;`brwap' burps on binds that don't exist!
> +      (setq b (expand-file-name b))
> +      (setq args (cl-list* "--ro-bind" b b args))))
> +  (append (list "bwrap") elpaa--bwrap-args args))
> +
> +(cl-defmethod elpaa--sandbox-args ((_mechaism (eql guix)) args)
> +  ;; Indicate the remaining arguments are the command to be executed.
> +  (append (list "guix") elpaa--guix-args (cons "--" args)))

There's a typo "mechaism".

More importantly, I understand that `elpaa--sandbox-ro-binds` doesn't
need to be passed to `guix shell`, but I don't understand why
`elpaa--sandbox-extra-ro-dirs` would not be needed either.

>  (defun elpa--markdown-executable ()
>    (catch 'exists
> +    (when (eq elpaa--sandbox-mechanism 'guix)
> +      ;; When using Guix, we can ensure what markdown implementation
> +      ;; we want to use, so we just return a fixed one here.
> +      (throw 'exists "cmark"))
>      (dolist (cmd elpaa--markdown-candidates)
>        (when (executable-find cmd)
>          (throw 'exists cmd)))

I think this optimization is not worth its cost.

> This approach could also be extended to Nix/nix-shell, but I have no
> experience with that tool.

To be honest, I'm not thrilled about adding support for more container
systems to `elpa-admin.el` because it's not its focus.  The containers
are important on `elpa.gnu.org` because I'm a bit paranoid about running
arbitrary software on a central server that could conceivably be
a target for an attack.  But for most other uses it seems that setting
`elpaa--sandbox` to nil will do the job just fine if you don't want to
install `bwrap`.

More interesting would be to add support for this kind of sandboxing in
Emacs itself (so ELisp's Flymake support can use it); and some years
from now `elpa-admin.el` will then be able to ditch its own sandboxing.

> (On a related note, is it necessary to sandbox markdown rendering?

It's necessary if (like me) you don't want to try and convince yourself
that it's currently unnecessary nor want to depend on that fact
remaining true in the future.

> I understand why org can be dangerous, but markdown shouldn't be able
> to have any side effects?)

Yes, and 640kB should be enough for everyone.

> If these changes are fine, I can push them myself.

Feel free,


        Stefan




  reply	other threads:[~2022-04-15  4:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13  8:40 Patches for elpa-admin Philip Kaludercic
2022-04-15  4:01 ` Stefan Monnier [this message]
2022-04-15  7:18   ` Philip Kaludercic
2022-04-15 14:40     ` Stefan Monnier
2022-04-15 15:05       ` Brian Cully
2022-04-15 15:44         ` Philip Kaludercic
2022-04-15 15:37       ` Philip Kaludercic
2022-05-21 11:38       ` Philip Kaludercic
2022-05-31  8:37         ` Philip Kaludercic

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.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwvfsmf6mrm.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=philipk@posteo.net \
    /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.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).