unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Tomi Ollila <tomi.ollila@iki.fi>
Cc: "notmuch@notmuchmail.org" <notmuch@notmuchmail.org>
Subject: Re: [PATCH v2] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()
Date: Mon, 17 May 2021 15:10:22 -0500	[thread overview]
Message-ID: <CAMP44s1upWVUT8j3MeibP=Ov5AaWA1s3W58zdnYiWLxPQ_dC-Q@mail.gmail.com> (raw)
In-Reply-To: <20210517193315.11343-1-tomi.ollila@iki.fi>

On Mon, May 17, 2021 at 2:33 PM Tomi Ollila <tomi.ollila@iki.fi> wrote:
>
> notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot
> work in many cases...
>
> The more specific version _libconfig_sanitize() replaces it in
> T590-libconfig.sh and the code that uses it is modified to output
> the keys (ascending numbers printed in hex) so the sanitizer knows
> what to sanitize in which lines...
>
> In addition to ".(none)" now also ".localdomain" if filtered from
> USERNAME@FQDN.
> ---
>
> Rebase of id:20210502181535.31292-1-tomi.ollila@iki.fi
>
> * 'fn () {' style change
> * added @ to fqdn replace, as it could be subset of user
>
>  test/T590-libconfig.sh | 97 +++++++++++++++++++++++++-----------------
>  test/test-lib.sh       | 20 ---------
>  2 files changed, 59 insertions(+), 58 deletions(-)
>
> diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
> index 745e1bb4..8e70b7b2 100755
> --- a/test/T590-libconfig.sh
> +++ b/test/T590-libconfig.sh
> @@ -5,6 +5,26 @@ test_description="library config API"
>
>  add_email_corpus
>
> +_libconfig_sanitize() {
> +    ${NOTMUCH_PYTHON} -c '
> +import os, sys, pwd, socket
> +
> +pw = pwd.getpwuid(os.getuid())
> +user = pw.pw_name
> +name = pw.pw_gecos.partition(",")[0]
> +fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
> +                          socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
> +for l in sys.stdin:
> +    if l[:3] == "8: ":
> +        # fqdn could be subset of user; therefore @
> +        l = l.replace(user, "USERNAME").replace("@" + fqdn, "@FQDN")
> +        l = l.replace(".(none)", "").replace(".localdomain", "")
> +    elif l[:3] == "a: ":
> +        l = l.replace(name, "USER_FULL_NAME")

This generates garbage when name is null. See ff5f141b (test: fix
passwd_sanitize(), 2021-05-01).

At the very least we need to check for that, even better if we
generate the proper output:

        if name:
            l = l.replace(name, "USER_FULL_NAME")
        else:
            l = "a: \'USER_FULL_NAME\'\\n"

This makes the test pass with no geckos name, but we need to use bash
strings: $'string'. Otherwise we would need to do something much more
weird.

Cheers.

-- 
Felipe Contreras

  reply	other threads:[~2021-05-17 20:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17 19:33 [PATCH v2] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize() Tomi Ollila
2021-05-17 20:10 ` Felipe Contreras [this message]
2021-05-18  5:10   ` Tomi Ollila

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://notmuchmail.org/

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

  git send-email \
    --in-reply-to='CAMP44s1upWVUT8j3MeibP=Ov5AaWA1s3W58zdnYiWLxPQ_dC-Q@mail.gmail.com' \
    --to=felipe.contreras@gmail.com \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /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://yhetil.org/notmuch.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).