all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: "Vincent Belaïche" <vincent.b.1@hotmail.fr>
Cc: emacs-devel@gnu.org
Subject: Re: SES local variables to define printers
Date: Thu, 23 May 2013 21:06:45 -0400	[thread overview]
Message-ID: <lvd2sh4256.fsf@fencepost.gnu.org> (raw)
In-Reply-To: 80li75ifm0.fsf@gmail.com


I haven't quite followed what you are trying to do (I don't know what a
SES "printer" is), but as a general comment: please, please don't
(re)invent your own version of local variable handling unless you are
really, really sure you need special handling that is not provided by
normal file or directory local variables (or local eval). (And be really
careful if you do implement it, since it can be a security hole.)


Vincent Belaïche wrote:

> That sort of trick was to define a file local variable foo to a lambda
> expression defining a printer function, and then use the foo symbol as a
> printer when setting the printer for a cell.
[...]
> By the way, that kind of things was a security breach because you allow
> to call a function defined in the file without any control.

!!!

> Now, I would like to have again the same sort of feature in SES,

!!!

> so I did a quick hack herein attached 

!!!

"Security breach" + "quick hack" = fun times

> - is that possible to check that when a function is executing, that
>   takes a reasonable time, and if not to interact with the use and ask
>   whether he/she would like to double that time

   Your printer function `(lambda (arg) (shell-command "rm -rf /"))'
   has been running for 30 seconds.  Run for another 60?

Doesn't help much...

> +(defcustom ses-enable-local-variables nil
> +  "Non-nil if SES should process local-variables lists in ses buffers.

Why is this needed - what's wrong with the normal enable-local-variables?
Why should there be a special variable that controls local variables
only in SES files?

> +\(You can explicitly request processing the local-variables by
> +executing `(hack-local-variables)'). Local variables are useful
> +to define file local printers or values but raise a security
> +issue if the printer function is used to do border effects. If
> +you select `Filename test', then you should configure a function
> +symbol or lambda expression which takes one argument, then the
> +local variables are processed iff the buffer file name passed to

Don't use "iff" in doc strings.

> +this function returns a non nil. For instance you could configure:

"returns non-nil".

> +  (lambda (x)
> +    (string-match \"^/dir/where/local/var/are/allowed\" 
> +		  (expand-file-name x)))

Sounds like dir-locals.  Why not just use a dir-locals file?

> +"
> +  :type '(choice
> +	  (const :tag "No" nil)
> +	  (const :tag "Yes" t)
> +	  (function :tag "Filename test"))
> +  :group 'ses)

You would need to add

   :risky t

>        (functionp printer)
> +      (and (symbolp printer) (boundp printer) (functionp (symbol-value printer)))

What is this for?

> +	(and (symbolp printer)
> +	     (boundp printer)
> +	     (functionp (symbol-value printer))
> +	     (setq printer (symbol-value printer)))

? Likewise.

>  	(setq value (funcall printer (or value "")))
>  	(if (stringp value)
>  	    value
> @@ -1899,9 +1925,17 @@
>    (unless (and (boundp 'ses--deferred-narrow)
>  	       (eq ses--deferred-narrow 'ses-mode))
>      (kill-all-local-variables)
> +    (setq major-mode 'ses-mode)
> +    (and
> +     enable-local-variables
> +     ses-enable-local-variables
> +     (or (eq ses-enable-local-variables t)
> +	 (let ((bfn (buffer-file-name)))
> +	   (and (stringp bfn)
> +		(funcall ses-enable-local-variables bfn))))

Ironically, ses-enable-local-variables is itself a potential security hole...



  parent reply	other threads:[~2013-05-24  1:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 20:52 SES local variables to define printers Vincent Belaïche
2013-05-23 21:35 ` Davis Herring
2013-05-24  1:06 ` Glenn Morris [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-05-24  5:45 Vincent Belaïche
2013-05-24 13:28 ` Stefan Monnier
2013-05-24  5:46 Vincent Belaïche
2013-05-24  5:53 Vincent Belaïche
2013-05-25 20:43 Vincent Belaïche
2013-05-26  1:17 ` Stefan Monnier
2013-05-26  7:16 Vincent Belaïche
2013-05-26 18:02 ` Stefan Monnier
2013-05-26 20:25 Vincent Belaïche
2013-05-27  1:35 ` Stefan Monnier
2013-05-28  4:38 Vincent Belaïche
2013-05-28  4:57 ` Stefan Monnier
2013-05-30  5:50 Vincent Belaïche
2013-05-30 13:20 ` Stefan Monnier
2013-05-30  7:24 Vincent Belaïche
2013-05-30 15:36 Vincent Belaïche
2013-05-30 17:15 ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=lvd2sh4256.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=vincent.b.1@hotmail.fr \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.