From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 2P0eLlrsjmB8TAEAgWs5BA (envelope-from ) for ; Sun, 02 May 2021 20:15:54 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id mPGhKVrsjmDBbgAAbx9fmQ (envelope-from ) for ; Sun, 02 May 2021 18:15:54 +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 EB0A013EB4 for ; Sun, 2 May 2021 20:15:51 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id A2655271D4; Sun, 2 May 2021 14:15:47 -0400 (EDT) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) by mail.notmuchmail.org (Postfix) with ESMTPS id EB9CD1FAC2 for ; Sun, 2 May 2021 14:15:44 -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 501921B00EE3; Sun, 2 May 2021 21:15:41 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1619979341; 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=baJ3kDZIfn0oUFA/eH6VMWHrAYshThKhtPwfIYGdKSM=; b=DHjGx5NG5vna+Gr5kXc8Y9S8m29RS/XD8Y/nR2nEVy8kBuaVr0RAHcjzdaxG+5MBwPq2Ac lsr/6giFRBefOVlsTgcpw2Ly4swn/aC+b1Uho0y7V5rNsxbFvudIyWafN8oyzyxBN2iG9k /CdVoxoBz0vU/Fzq/qlkEexEjHFkL8EQpL3VCy/QeylyHThIrkvwk5kgiqRBhrTFUHHn1T GxphYjVb+F5LnDK+vjqwnjDupAOGo0Yz92G3kuh8JKOZqtip55vTVZM6pRoPgGm5BsZXCo tLe+x57PHa9QE2fcpiwxIR1/uADLFeHi8IihuxMz8QhuEAIkHuLzza8oCtmPVg== From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize() Date: Sun, 2 May 2021 21:15:35 +0300 Message-Id: <20210502181535.31292-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=1619979341; 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=baJ3kDZIfn0oUFA/eH6VMWHrAYshThKhtPwfIYGdKSM=; b=dk3JdAwUa2rrwhOD8VYFqXLcd4M+OLcgwM7h2SP8ttzo79zlWuwWPdKcp08tyX7+uDQThy eIu/5PL2XhoHa21F1JAWdJBEPfGdb5xgnW9FAkF4CNmQBymqLUh0ukK59VM1HOjaKHMNLe PmxxEznqjwnq3QzX4irqtBvsdkHPOyxF0kQiGuVe/FK/T6puVytJpKrwe/xDWB3sjuUOUk TvuPNF8zHiWHer0kgjiG0DCo7n1b8LrD4YlZfonGmqHxehiwuWW8kdaWxrOElXKUe3brYS WbRGXQqPRm/RWIf1uth8vweh1griiXlZOzDyaBr/isazhZduSdg/g7Pq7ZQqwg== 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=1619979341; a=rsa-sha256; cv=none; b=F3gPprtD5Ox8G208mnFeCmMLeuMA7ZPbsGg78VvBYZ5MwQ566cD0y9fH8R3hBc8GcWBkZY /ymcDoPYb3wwl86767zp4p3SasFBYGmCP+qceJvCQ8Gh/NJfWNbJIuSj34gJXAv7aNLrYn LPSt5HbCod8/aGLsJ/wMoh+9qgqP+rVxuNUpJ7krFBEIjtltt6rv2UceqD0zCn+P2ueSMm nXsgPkd8YaJGnZGywBqshJ3Z7FAfvMYIPuaeZ9uK7AIMOghLlEGA+oVTdVikYvupbiPG+F V17ZN3sQ7eJZAaQ65h01kLLVecBAamWhqR4wwwA7W0vU80AMOiaq8AcE2ym8Fw== Message-ID-Hash: TFIMUSQ44FB7DOCLUEPIJRGVXJW6L3D2 X-Message-ID-Hash: TFIMUSQ44FB7DOCLUEPIJRGVXJW6L3D2 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=1619979352; 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=P2CDIIwhYzm1If0WsDvXLwBysarympBGuo4kHK6eXUg=; b=j1ZysrCqNmlpcrchoxgNU0qGJSEj3hezckfErpaQ8gB+iBBDZlUtuCypZW+NU7Yy1OWISZ vruFKEWWsR6oaPIyE3xm65NTo+JIy3c+kL9PXcHXCTN3WnRLVOH0ADGaQ9y5lFlLGq9Ehh PWPpnJ3YBuGoidViHMLjOuSEhcujLe+E+gteJRhvEsy+RrD3+F6U9ikRJmkOgPtOBPyIzG DrihaF6UEGljcfTfsER7UaVEfrtWWlvG+evvW1Jv0UlAOHLkbQ8WOF65Gd0jdxm9FYIphT T6Bs8/4Q7BQowO1QLOj9MRamx5+knw8ib49hLvtlOT8rNOSuugU0fpEQEXjr6g== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1619979352; a=rsa-sha256; cv=fail; b=UK/wAwRynppDDJf2sK0GYawcgtbsOnJUurUVfbcLJvi6jnE1WwKF/GZmDFzvPPxB7tfC++ qlETR3yxFV+AQLIDchJh//4wrtn8RSpXzPoqZFPHVJCtlrcW+ey4mNGhQo+cpXjwXHBBtJ gdCbftw0JyTDOBKstcriLbTGXlATRPaUl9afvG132vMTgZ2W14WIzvUO7XPhfRMW7ZAJSu oJzcyZs3YEjp35vAfeJP8Is2W/KkNYHSmZELt9M+hDyUSfw1Ajg5qOy/YaGBUSUy59CXo6 rACxDzayrAUQh6z3Pv20MqK324jUkx9EJe5IpJ2LOFh7Yrqb4iJnmPQe3laRjw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=DHjGx5NG; 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.93 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=DHjGx5NG; 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: EB0A013EB4 X-Spam-Score: 1.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: 0+U0BkiNwdtu 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. --- On fedora 34 I got that ".localdomain" suffix. test/T590-libconfig.sh | 97 +++++++++++++++++++++++++----------------- test/test-lib.sh | 21 --------- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh index 51dd29c8..3587e607 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: ": + 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") + sys.stdout.write(l) +' +} + cat < c_head #include #include @@ -380,26 +400,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("%x: '%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 +0: 'MAIL_DIR' +1: 'MAIL_DIR' +2: 'MAIL_DIR/.notmuch/hooks' +3: 'MAIL_DIR/.notmuch/backups' +4: '' +5: 'unread;inbox' +6: '' +7: 'true' +8: 'USERNAME@FQDN' +9: 'NULL' +a: 'USER_FULL_NAME' == stderr == EOF unset MAILDIR @@ -694,23 +714,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 +743,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("%x: '%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 +0: 'MAIL_DIR' +1: 'MAIL_DIR' +2: 'MAIL_DIR/.notmuch/hooks' +3: 'MAIL_DIR/.notmuch/backups' +4: '' +5: 'unread;inbox' +6: '' +7: 'true' +8: 'USERNAME@FQDN' +9: 'NULL' +a: '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 d46bb4c3..777b5dd9 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -710,27 +710,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.31.1