From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id oJPWLMPNomAGTAEAgWs5BA (envelope-from ) for ; Mon, 17 May 2021 22:10:43 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id gCufKMPNomAXQAAA1q6Kng (envelope-from ) for ; Mon, 17 May 2021 20:10:43 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 43758265B5 for ; Mon, 17 May 2021 22:10:43 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 43D6B2AA46; Mon, 17 May 2021 16:10:38 -0400 (EDT) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by mail.notmuchmail.org (Postfix) with ESMTPS id 18DEC2AA2D for ; Mon, 17 May 2021 16:10:35 -0400 (EDT) Received: by mail-wr1-x42d.google.com with SMTP id h4so7689530wrt.12 for ; Mon, 17 May 2021 13:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Hz7jpJ7nngHvRlQseveuqPAQ0a56YBA9/9dC8zgfAo0=; b=m34YrniUBEi5x5ykYr9rt0M9lveHdicR29O60MPDx+jCc+ze3sSrcKxzoe4y97ncJb jDCAcUHLa4WZtLUX8Bjesxt1FmYgq1BBZpRuJd8sYTY7YjIkQjOIusf534SpPOrtmLoa /iS3OBo8m/Y4TyXHHnBEnriXDMP7v3iJnIWKi3X2wHAfMItUaxWe5LQVTixC5UzynDQK /DQVMmjKVgHuxlryXZ1ceodCCC3pfuytXmGUZx3DAalrnn4pV3EGAhbyck0hCRqmxUT2 O4Z19nEF46udc3Vvrina9Nphz5DL0dwa13NhrbsJZkzZMThicq9PQZSWcmoI2dLxnHeW v0mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Hz7jpJ7nngHvRlQseveuqPAQ0a56YBA9/9dC8zgfAo0=; b=bwx+YW91fi35rbyfWdNrYYxSjGX98aTCI05rLp6FyhFATlJp/dMExDS4k6qfbxoDHk 1IU4zos8t2X4OYNgdqTWBqJUdfM9QP+aayb1OZEogCyRQYXdYyYbQuHjPA/os4TmbupG YgVcZgMnpOS1Vyah9+khX8hhm/i4f0Eg6YI8vLL9RtNNjmyCsdxcEjUySh4vgXUdtfJq jRDDdPOwXo/9Nqf8/kQ3iDpPXTXcqSm141yGtHhp0TLnvKQBHtCGZMMYXk3YgVAd1VTD q8k6aFmr+u3mfOYsiWogPn9ghp2sHCUCeEXmZT0/0sGklOqrv/ZSnWI64JU9i8m+cj5P EK+Q== X-Gm-Message-State: AOAM530mTblQO9oNVXK27P44mt8X89JOYKBG+VNFacuJ+Illk1iLKyek E+NpJcuFuzt8DMGFE4OSOxOelvATkKWz12PBWSc= X-Google-Smtp-Source: ABdhPJw9FnLZhCc4ArjNsuMl8D9+WZlaosB6QO1V8QqX+ZndQlbT4/4vSGjWU+WsKGZZpietGL5qK/2jlw4bQXJexLY= X-Received: by 2002:adf:e8c3:: with SMTP id k3mr1678858wrn.255.1621282233740; Mon, 17 May 2021 13:10:33 -0700 (PDT) MIME-Version: 1.0 References: <20210517193315.11343-1-tomi.ollila@iki.fi> In-Reply-To: <20210517193315.11343-1-tomi.ollila@iki.fi> From: Felipe Contreras Date: Mon, 17 May 2021 15:10:22 -0500 Message-ID: Subject: Re: [PATCH v2] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize() To: Tomi Ollila Message-ID-Hash: VMDQVURCUAPWMDCDZICCMTKJ2DJCM3HF X-Message-ID-Hash: VMDQVURCUAPWMDCDZICCMTKJ2DJCM3HF X-MailFrom: felipe.contreras@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: "notmuch@notmuchmail.org" X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621282243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=9mY7m827bK0sti1O+HwHm5smj6+cn1zDTYlPYKgAmV0=; b=JRerCCL6mzvDpwvyfIjWp0c8I77BT9P1e5IB3UrCLVKMZmmXWvgWxmWpAyjZS743PFTMRJ mOVdPadaX5JvGWG8LyppRSXh+jdL1QmKpt0OihgRk7uJ4QgA+X3fz9h6KZaV+VIOxQ1M8S LbM+LtpwnO6ITAk9Enr8wCwYporPtncLGSidIeQeCiGVa4o0kcqvMY7AUND0+MdNGyWzRx Fx8iSXI8oryZn2Kpy8M1NULLo//yuK8pugIlwe/iRbW7rOWKSGMYQkqvyxvVlNQtguls1h Uf8FVC8lklW1w7xytQ7UMtDCaTDH25R2yltX2yh56/+di0pQEnQOzn/6UOGi0A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621282243; a=rsa-sha256; cv=none; b=RTalOcEf1ZqFKVlS1xATviVwrproVGcgJx2cuQJzRBhGFSVF8oiBj1p98Gm/MSlU1Cdvr0 CAeQ58p+GE26GIzY0Mi7T8UJuYeYZNtVcIXChYPJy4a+nQLu3MuUhuwaqPn7yZdJTL9Hx+ HeHKVlm2J18rKWftg/jEx9PDvKt93RY6tC+n5daINDtxRhVf8urhKYYvsMz+yIK2z2dROO yH7//LxkkIqhds+GNexebB75grz+vtHPlvNF7rsPoyrOQj0uoISAyMZ14a1rtQSYfXg8/k I5QEiNjFw7EM+3ejkv2Ik+K9xXsRaDV7vBISHqIh8Y/icb296adbm4H2JGFR/Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=m34YrniU; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.96 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=m34YrniU; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 43758265B5 X-Spam-Score: -0.96 X-Migadu-Scanner: scn0.migadu.com X-TUID: wEdDBVVEnZLu On Mon, May 17, 2021 at 2:33 PM Tomi Ollila 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