all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: Stefan Kangas <stefan@marxist.se>
Subject: Re: scratch/package-security bcde5f8 2/2: Support expiration of metadata by package archives
Date: Wed, 25 Nov 2020 20:01:12 -0500	[thread overview]
Message-ID: <jwvmtz5c58i.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20201121234315.1991F209DE@vcs0.savannah.gnu.org> (Stefan Kangas's message of "Sat, 21 Nov 2020 18:43:14 -0500 (EST)")

> @@ -449,6 +458,7 @@ synchronously."
>  (define-error 'bad-size "Package size mismatch" 'package-error)
>  (define-error 'bad-signature "Failed to verify signature" 'package-error)
>  (define-error 'bad-checksum "Failed to verify checksum" 'package-error)
> +(define-error 'bad-timestamp "Failed to verify timestamp" 'package-error)

Hmm, these errors should all have a `package-` prefix.

>  \f
>  ;;; `package-desc' object definition
> @@ -1812,6 +1822,100 @@ Once it's empty, run `package--post-download-archives-hook'."
>      (message "Package refresh done")
>      (run-hooks 'package--post-download-archives-hook)))
>  
> +(defun package--parse-header-from-buffer (header name)
> +  "Find and return \"archive-contents\" HEADER for archive NAME.
> +This function assumes that the current buffer contains the
> +\"archive-contents\" file.
> +
> +A valid header looks like: \";; HEADER: <TIMESTAMP>\"
> +
> +Where <TIMESTAMP> is a valid ISO-8601 (RFC 3339) date.  If there
> +is such a line but <TIMESTAMP> is invalid, show a warning and
> +return nil.  If there is no valid header, return nil."
> +  (save-excursion
> +    (goto-char (point-min))
> +    (when (re-search-forward (concat "^;; " header ": *\\(.+?\\) *$") nil t)
> +      (condition-case-unless-debug nil
> +          (encode-time (iso8601-parse (match-string 1)))
> +        (lwarn '(package timestamp)
> +               (list (format "Malformed timestamp for archive `%s': `%s'"
> +                             name (match-string 1))))))))

Hmm... I think you forgot the `error` in this
`condition-case-unless-debug` (i.e. the way you wrote it, it will catch
all `lwarn` errors).

> +(defun package--parse-valid-until-from-buffer (name)
> +  "Find and return \"Valid-Until\" header for archive NAME."
> +  (package--parse-header-from-buffer "Valid-Until" name))

It would be easier for the ELPA archives is to use a "validity duration"
header, since it could then be constant.

Other that that, LGTM,

[ BTW, to mitigate against replay attacks in the absence of timestamps,
  we could compare the last `archive-content` with the new one and make
  sure that none of the packages's version got smaller.  ]


        Stefan




       reply	other threads:[~2020-11-26  1:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201121234313.32698.75403@vcs0.savannah.gnu.org>
     [not found] ` <20201121234315.1991F209DE@vcs0.savannah.gnu.org>
2020-11-26  1:01   ` Stefan Monnier [this message]
2020-11-26  2:24     ` scratch/package-security bcde5f8 2/2: Support expiration of metadata by package archives Stefan Kangas
2020-11-26  2:44       ` 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=jwvmtz5c58i.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=stefan@marxist.se \
    /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.