From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74879: 30.0.92; trusted-content-p and trusted-files cannot be used for non-file buffers Date: Sun, 15 Dec 2024 12:47:59 +0200 Message-ID: <86cyhtrzmo.fsf@gnu.org> References: <87ed29ixu8.fsf@daniel-mendler.de> <875xnlfdzi.fsf@daniel-mendler.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21469"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74879@debbugs.gnu.org, monnier@iro.umontreal.ca, stefankangas@gmail.com To: Daniel Mendler Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 15 11:49:11 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tMmBS-0005Rp-Sr for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Dec 2024 11:49:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tMmBM-0008K0-Dr; Sun, 15 Dec 2024 05:49:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMmBK-0008Jo-Rf for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 05:49:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tMmBK-0004VO-Jl for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 05:49:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=MMWY+VTMMCSa/qsIXnMHAoE4lSbKBgUZKTOzgWwhYwM=; b=R4hWbp4jCZbrMNp4dD+HbNrQFvLQuwsRyl0KZCFqcD4jFIO+HphHxiPnS37H77gzkZ8Y1RJH/gmZQ96pbSKFAxTbMC0iB+7RfsXLenXiN4slqGAV71vUq18DTURk3uchkzOQazTrJon6Y+ZlJVmyPJqUcM05eGlaeDzEsbNbD4QiyWCYQ9Buj02P5uk4hK6iEYxdrFfd784J4nQIJIijfpi0yPHKCXTCLgl1+diC+cvr87RCWKweGyvWJQ9b+RRfrIKtguXdn1vyU1xG1CNV1kG/EAqvJHYhrXRAf8fjVonOzMh0FvPuRUh8ee/EScGKFTQuY2bSJALEfJ7IVfurAw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tMmBK-0006VP-60 for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 05:49:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Dec 2024 10:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74879 X-GNU-PR-Package: emacs Original-Received: via spool by 74879-submit@debbugs.gnu.org id=B74879.173425971124960 (code B ref 74879); Sun, 15 Dec 2024 10:49:02 +0000 Original-Received: (at 74879) by debbugs.gnu.org; 15 Dec 2024 10:48:31 +0000 Original-Received: from localhost ([127.0.0.1]:49661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMmAp-0006UW-4g for submit@debbugs.gnu.org; Sun, 15 Dec 2024 05:48:31 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57182) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMmAk-0006UA-8h for 74879@debbugs.gnu.org; Sun, 15 Dec 2024 05:48:28 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMmAd-0004Ou-Hu; Sun, 15 Dec 2024 05:48:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=MMWY+VTMMCSa/qsIXnMHAoE4lSbKBgUZKTOzgWwhYwM=; b=YpPamtppnSsT JT+0kALLcgcag0EAiN+j/Spwv+kUsX+PoNMhFun5LEYXvQY2jBgVe7ULNPMw3KT8zLqIxYus/0wi1 7GKp1DZocI/D18024BhIHvMCkYz6s9IUroDAsqDqlJFcfhRP6QxaQoIuh2V1uM54veTmvhuJAQlhO RESGt8+k8umgJ+a9I1JtBe3ZyxN4PUDtxqElw0oMld7WR+QTBIjPyMW+cVa//L55Yj3jPXyVigAJc J9fm0/ldXQ/Ie1C7u590ncPxIxDDHPqZC55xFHM0CXLQEs/1QsyUAhP1zoMiSRKkjVTdwXyxgUuBP F+bTrekhfPv1HknmikM9/Q==; In-Reply-To: <875xnlfdzi.fsf@daniel-mendler.de> (bug-gnu-emacs@gnu.org) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:297093 Archived-At: > Cc: Stefan Monnier , > Stefan Kangas > Date: Sun, 15 Dec 2024 11:16:17 +0100 > From: Daniel Mendler via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Daniel Mendler writes: > > > Thank you for the recent addition of `trusted-content-p'. Is there a > > possibility to use `trusted-content-p' in buffers which are not backed > > by a file? I use Flymake in *scratch* or similar buffers and it seems > > that this won't continue to work given that `trusted-content-p' needs a > > `buffer-file-truename'. > > > > My suggestion would be to replace `trusted-files' by a > > `trusted-buffer-function' which is a predicate function or a list of > > functions. The functions could then check a custom list of trusted files > > or a custom list of trusted buffers. > > > > Alternatively offer `trusted-files', `trusted-buffers' and > > `trusted-buffer-function`? `trusted-buffers' could for example rely on > > `buffer-match-p`. > > I have also ported back `trusted-content-p' via Compat. I had the plan > to use `trusted-content-p' in external packages which could potentially > perform dangerous operations. This way the new feature can be used to > retroactively improve the safety even of older Emacs installations. > > For example in my GNU ELPA Corfu package the plan was to check > `(trusted-content-p)' when starting auto completion. To be clear - Corfu > is safe by default, since auto completion is disabled by default. > However many people enable auto completion unconditionally in all > buffers. > > Now with the limitation of `trusted-content-p' to file-backed buffers, I > cannot do this, since otherwise auto completion would be lost for > example in *scratch* buffers. Each package could invent its own trust > mechanism or alternatively one could limit the `trusted-content-p' check > to only file-backed buffers. Both alternatives would be worse than going > through the `trusted-content-p' standard mechanism. > > Therefore by making the `trusted-content-p' mechanism too limited, we > get less safety than with a more flexible mechanism. Nevertheless I > would avoid creating a complex mechanism given that the mechanism is > supposed to be part of Emacs 30. The simplest approach I can think of > this this `trusted-buffer-function', a hook called by > `run-hook-with-args-until-success'. Later on trust functions can be > provided and added to the hook list. The trust functions could check > file lists, buffer lists, regexps etc. Users can also write their own > predicate functions. What do you envision trusted-buffer-function should do in a buffer that doesn't visit a file?