From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id OJAYAboJqWAvMAEAgWs5BA (envelope-from ) for ; Sat, 22 May 2021 15:40:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id kMhVOLkJqWDsZAAAbx9fmQ (envelope-from ) for ; Sat, 22 May 2021 13:40:09 +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 2C7B723A6F for ; Sat, 22 May 2021 15:40:09 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id CEB822AA0E; Sat, 22 May 2021 09:40:04 -0400 (EDT) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by mail.notmuchmail.org (Postfix) with ESMTPS id 4EB0D2AA0C for ; Sat, 22 May 2021 09:40:02 -0400 (EDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 0D7C91B00162; Sat, 22 May 2021 16:40:01 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1621690801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ipgGFjWDMKgpACmoo/NVPYmzD574GNtxb3eIMJ7krJo=; b=PiU7gb9JEK6TtzJtUhV5LzumRrTQVxiaYnTXkm7lmEVwVPCgykkURjRg5TFvM7u8tXGOlQ 2mqjcC1LbHp6D4+dqf9bQH6icZV6SPInglEDO8yhBuVdvodxtWGRIEKKc6O8uQkvnXquEi ZhxRTd1tK5X7c1XNDn1IiAgyFmOsSqKT2WJ12rCiq3GT1VSflqrL0l+0gn/sA2JJiLp6xb m0JtbUTu/kFVKpFF4fMr0hFrJMMLguhRYQy2fa13ubhIUZIo5j4KcqLGveOOM3AzYhwRxb VHFK5hkIw93deGzzOA2fv+v14hrl6RRe5u+N5ScPy91cbMKFm6t/ClvX/y67vA== From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH v5] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize() Date: Sat, 22 May 2021 16:39:57 +0300 Message-Id: <20210522133957.24755-1-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1621690801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ipgGFjWDMKgpACmoo/NVPYmzD574GNtxb3eIMJ7krJo=; b=PQNG4MQqjDHaTQSxe8vwOxYgsiM25RaHjwNdYp5rlRk7A5xvc9hrISfYoPT0UHwavWMSoR 2XgGzTg7/ASqs4puDP6ZcPT0sHoSoW7yb/6pBoPJi+7vhkssoXPj3T7GJMvh9dVfBJj6QB Sa5dbXoqJxbZuttI/FiWSZgSNLNYLdwBYvfr92YCewDxrOcCmGz2a1ztOoMmykts9vF5b9 Rbd/yaO1iCcia/80Ljkefc0bMjjs2AvpznXgvFt733+gCjTwcCWKfS+O+jOUjysGnt/R8b HogQF9gDjaWS7VcbJBdLxiTS0KVV5sqZ6qfd/Pwl8e6kxfdaxU6Yg9n9wAMwDA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1621690801; a=rsa-sha256; cv=none; b=GF4s8gCaIn2WTVGtofvJtHaBgaFrJF7ewTzc8R9/fa9gvdg4L9U28RgXDXkBpYhthZFG0Z Osf9eMtwG8s7/LMp7Wvcz4kq3jwNvV+l7xMZuOjb6YrK5tYn9tlHuYxhg14tfL3aw+huCb W7R3WHLl5HgHqMjm0Fmde1iOvtK2njZErrtO5jNE3IhSqpatIqNNeCRO6E00gECwxsrPXX siYONaViHcBz5oMIVrMC2oy3n5lRil9ocmJbgw8NyusUlnc+/b8W+2wsXaLYc+Y24eYWFB LZ6vSzbrxqcDaP0I2SB0khrgsqZWxge+Vy83BPduqqIPbb4vZqXWBiTkcW0JyQ== Message-ID-Hash: 6DEZ7BOAOQYMBMABI6V2KOOIBD5S2XIU X-Message-ID-Hash: 6DEZ7BOAOQYMBMABI6V2KOOIBD5S2XIU X-MailFrom: tomi.ollila@iki.fi 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: tomi.ollila@iki.fi 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=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621690809; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=333xudOAe2IlwiJJhm2cqYhFYeqvUM0iFJifxOMtFhM=; b=BGRusXTD6n7W5EHaCBvU2MrqGAthtyE01ssYoKosSi9hnJaYpfQEMy2vCV8dNGM/wz7hh9 m4Hl9vyu7AxbGkU0oxoknM/9AYRuCE93gevcsHRZKPsGvLVPgAAVqr3LWCJOz9b8a4upp8 X7Q8CavpIHGS8lEIDJdGdNVFgLX8ym23jWJLLIPVA565NctR8WYpAojPOo863MXyF1WhrX t5LeqRyliS5lst1ifXO79e7JmMzK/yA63p++WI4HMSjPgYp0W+Rd8DkZMTtVblrdmVgmwb OqmCa/+C9/ykTuyIOozpE6WL3BLS4jG7aGgtamoT68ewt57hArgeNyg5/iXReA== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1621690809; a=rsa-sha256; cv=fail; b=ZPPYhlg5QRMGlAmobsKjsIfPLaMjAt8in+zuX7GH/KDFa9mVQ1hmwvXCE8n4ZtVt7QIqAZ XlOlKs2clSGH36p2H1TCCvwhlMQBcRphmEDmspqXQ5B2cbjegag/43OjMFud2g02dUhTDg JCuc8q8U//PN/R54TZ+8iisz9b8a1/TzsOm9njqnc5wzXJ04Vn+G2bNENJ0vhC3J24HTE3 teyOK+e7gwPJj8CIifGZ7sfFNfjEyiT3L+uiNTyioo2nFrElI5Rxi1lMZgoE4Drzf2ElzK 0/Gx2Da7qpk1FSwsKCZ/LnDNHouTt0hJFYaQhSF04B7pjZVLDuk/2MnPrVyFZA== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=PiU7gb9J; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=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: 1.92 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=PiU7gb9J; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=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: 2C7B723A6F X-Spam-Score: 1.92 X-Migadu-Scanner: scn1.migadu.com X-TUID: Xh65+h8AeQ9E 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... "@" + fqdn -> "@FQDN" replacement is used as fqdn could -- in theory -- be substring of 'USERNAME'. 'user -> 'USER_FULL_NAME replacement to work in cases where user is empty -- as only first ' is replaced that works as expected. In addition to ".(none)" now also ".localdomain" is filtered from USERNAME@FQDN. /dev/fd/{n} is not defined in posix, but it is portable enough (if it weren't it is easy to fix -- now code looks clearer). --- Implemented David's suggestion in id:87sg2ft21p.fsf@tethera.net I did have exactly the same thought, 2 decimal digits, but as suggested and so easy to implement, did it now instead of someone(tm) updating when need arises... v4 in id:20210520134628.11653-1-tomi.ollila@iki.fi test/T590-libconfig.sh | 96 +++++++++++++++++++++++++----------------- test/test-lib.sh | 20 --------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh index 745e1bb4..bc7298f8 100755 --- a/test/T590-libconfig.sh +++ b/test/T590-libconfig.sh @@ -5,6 +5,25 @@ test_description="library config API" add_email_corpus +_libconfig_sanitize() { + ${NOTMUCH_PYTHON} /dev/fd/3 3<<'EOF' +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[:4] == "08: ": + l = l.replace(user, "USERNAME", 1).replace("@" + fqdn, "@FQDN", 1) + l = l.replace(".(none)", "", 1).replace(".localdomain", "", 1) + elif l[:4] == "10: ": + l = l.replace("'" + name, "'USER_FULL_NAME", 1) + sys.stdout.write(l) +EOF +} + cat < c_head #include #include @@ -380,26 +399,26 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} '' %NULL% key < NOTMUCH_CONFIG_LAST; key = (notmuch_config_key_t)(key + 1)) { const char *val = notmuch_config_get (db, key); - printf("%s\n", val ? val : "NULL" ); + printf("%02d: '%s'\n", key, val ? val : "NULL" ); } } EOF -notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean +_libconfig_sanitize < OUTPUT > OUTPUT.clean cat <<'EOF' >EXPECTED == stdout == -MAIL_DIR -MAIL_DIR -MAIL_DIR/.notmuch/hooks -MAIL_DIR/.notmuch/backups - -unread;inbox - -true -USERNAME@FQDN -NULL -USER_FULL_NAME +00: 'MAIL_DIR' +01: 'MAIL_DIR' +02: 'MAIL_DIR/.notmuch/hooks' +03: 'MAIL_DIR/.notmuch/backups' +04: '' +05: 'unread;inbox' +06: '' +07: 'true' +08: 'USERNAME@FQDN' +09: 'NULL' +10: 'USER_FULL_NAME' == stderr == EOF unset MAILDIR @@ -694,23 +713,23 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% %NULL% key < NOTMUCH_CONFIG_LAST; key = (notmuch_config_key_t)(key + 1)) { const char *val = notmuch_config_get (db, key); - printf("%s\n", val ? val : "NULL" ); + printf("%x: '%s'\n", key, val ? val : "NULL" ); } } EOF cat <<'EOF' >EXPECTED == stdout == -MAIL_DIR -MAIL_DIR -MAIL_DIR/.notmuch/hooks -MAIL_DIR/.notmuch/backups -foo;bar;fub -unread;inbox -sekrit_junk -true -test_suite@notmuchmail.org -test_suite_other@notmuchmail.org;test_suite@otherdomain.org -Notmuch Test Suite +0: 'MAIL_DIR' +1: 'MAIL_DIR' +2: 'MAIL_DIR/.notmuch/hooks' +3: 'MAIL_DIR/.notmuch/backups' +4: 'foo;bar;fub' +5: 'unread;inbox' +6: 'sekrit_junk' +7: 'true' +8: 'test_suite@notmuchmail.org' +9: 'test_suite_other@notmuchmail.org;test_suite@otherdomain.org' +a: 'Notmuch Test Suite' == stderr == EOF test_expect_equal_file EXPECTED OUTPUT @@ -723,25 +742,26 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} /nonexistent %NULL% key < NOTMUCH_CONFIG_LAST; key = (notmuch_config_key_t)(key + 1)) { const char *val = notmuch_config_get (db, key); - printf("%s\n", val ? val : "NULL" ); + printf("%02d: '%s'\n", key, val ? val : "NULL" ); } } EOF -notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean +_libconfig_sanitize < OUTPUT > OUTPUT.clean + cat <<'EOF' >EXPECTED == stdout == -MAIL_DIR -MAIL_DIR -MAIL_DIR/.notmuch/hooks -MAIL_DIR/.notmuch/backups - -unread;inbox - -true -USERNAME@FQDN -NULL -USER_FULL_NAME +00: 'MAIL_DIR' +01: 'MAIL_DIR' +02: 'MAIL_DIR/.notmuch/hooks' +03: 'MAIL_DIR/.notmuch/backups' +04: '' +05: 'unread;inbox' +06: '' +07: 'true' +08: 'USERNAME@FQDN' +09: 'NULL' +10: 'USER_FULL_NAME' == stderr == EOF test_expect_equal_file EXPECTED OUTPUT.clean diff --git a/test/test-lib.sh b/test/test-lib.sh index 6be5d11f..35bea097 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -561,26 +561,6 @@ notmuch_built_with_sanitize () { sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/' } -notmuch_passwd_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 user: - l = l.replace(user, "USERNAME") - if fqdn: - l = l.replace(fqdn, "FQDN").replace(".(none)","") - if name: - l = l.replace(name, "USER_FULL_NAME") - sys.stdout.write(l) -' -} - notmuch_config_sanitize () { notmuch_dir_sanitize | notmuch_built_with_sanitize } -- 2.25.1