From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id QOpiLAzFomBkOgEAgWs5BA (envelope-from ) for ; Mon, 17 May 2021 21:33:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id oLYDKAzFomD3FwAAB5/wlQ (envelope-from ) for ; Mon, 17 May 2021 19:33:32 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (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 61BEA25DF0 for ; Mon, 17 May 2021 21:33:32 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 92C7A2AA2B; Mon, 17 May 2021 15:33:26 -0400 (EDT) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by mail.notmuchmail.org (Postfix) with ESMTPS id 52C082AA0E for ; Mon, 17 May 2021 15:33:23 -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 2855B1B00162; Mon, 17 May 2021 22:33:19 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1621279999; 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=75kp5Q88Iw9eWilD2D6eHmEEAjITsUy/6qtmPOxxK1c=; b=f1QOk2Etly5ymjkUBi1aBP/8DVhgQXG/NLd+qV8x2mNQQr6g93QMYpi+EdFXl4n+xX1ExA qe3k0egdOVnIqC5Ov5OleJXEs+xAZ3VsJmV+R/JNYy/yMMp/5XLPDutmezozV18UR/uQlO WJVOPwiTyqmoMPEXrGfYCE1g9SzD+uIGeVF5bcTg0HqauuvwV1d4pXtMzvn8mV26m0z9I4 aJaCs4Nv+LHdH7XPAKFIBJzH8PfxaFdIaFN/x2Hty02M0O6PYlM2yx9bZ0zqNz75KeKiyZ It4NzzyOLDDHG/gT+n7iZ1WmqntUVjHNpRMv53FX3k5TfKeu5Nu4lZ6S+8xFEA== From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH v2] test: replace notmuch_passwd_sanitize() with _libconfig_sanitize() Date: Mon, 17 May 2021 22:33:15 +0300 Message-Id: <20210517193315.11343-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=1621279999; 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=75kp5Q88Iw9eWilD2D6eHmEEAjITsUy/6qtmPOxxK1c=; b=XDqHeW1XflzyKSU02aEjNn4RKTaHN3eRw1PTX0KgbAgLxIqIhgDQb8Y8/wxBaILs7uPvRZ zh0qtzMoEFF11j/PJ7rWheSz0q/bOE0oDDsS8GdCG+xerUGg5NWXwqVI4bU5gAvgCb7BTg V55AOLBPu+OBQlJEZn/V9rc395RYtKbyzxNohIaAMcZbjaWUG8mfBfQxJ4GSONz0Rwzpdp uPai8+Kah3BdR/53aM5T5jOOTKAIpc/I0briyyQZ7REuSYLJcKvBQdfxz4WbUDOx3G61Tp x6YOBDcXZkmyhhgZPm8Cde7GkN8b3F+0oUHK9d4ksJO6sCLWkqpeVQ+0oQ+/cQ== 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=1621279999; a=rsa-sha256; cv=none; b=PLtMbMgWUyzEZQPE8DUEieTuhA8d+9ZR9MpteEKOKBIfkzkqw815Q/K1NvXZoBRM27MiTd Nd6VjPyX+HJsXs4Lunh4DjqELN6rSJcmMNcrGCGVExUECO2xOzOXNp1/iF5FMKrSQ8nANx LJgBrll9k2QZGTELqIGhqxtlJ3IUpqn+rmNXFrcvJ7rc/u9Zpcqeeq5nFh6ZhUu51RGbRF m3aPejOMXvSJq4nKlJRH0xFPU4vdrNKc3IyV+dpDBDKNfjJKUq/3nWG3Px8xLXTS3sXdhX qXXVWML+fpzq1WBfZ9BcDB4kF2EEBLzXqGSlOrOwGLit0z7TbrQNnAwbMFm6bQ== Message-ID-Hash: YD7CLVB276ZP4NIMONPZ35HC7AHOLG6E X-Message-ID-Hash: YD7CLVB276ZP4NIMONPZ35HC7AHOLG6E 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=1621280012; 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=kMOG1SSjyXW9ZG8mhntjXo/p/hj5VBup3n9kMgJfHss=; b=tJnzk70nzxAY5Hlcb4yKw49406KxN5ofq4oU/x1a8DP/OnUqcqkDnO5WeD3TXBzDn+tyRD B2naH00G9thPCb2Btqo15OotNM6ToWS/t8waLpaK2s3D0s0FGCvmhrLjLfwJbMMO40ABw6 4rMSnVjORKFqNyS7CjQto3/dI/Z3mFrMHQkoJv/9vsU4p2oK6hPq12ap6ZSGO7oMLYcO1H Ed8n06oH4pSMxT1hh4ktyFMyf0CHGzpz00xm/DZYoPrw5vOkt6TJcSEhIC4STudSUVQrgD q0wJtpYYjHjUbnX5sYyjOhfDI/WtIpiMtYYGm54Ub2hkV1xmDkAVT3tTBUTtxw== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1621280012; a=rsa-sha256; cv=fail; b=DNvzqJOBb6P3rwae/AfXiEbWcz6pWEVd6GhrKXJndQlZCx5NAfH7ovbtC/I0DKdZPi6OHZ vKNYnqGpbac9YQ4A3V2oEatZoD5LoGWXMNrP+Ldk+It34ZoGUHituamZHUU8Al0sCt5qlK R8A0f5j+HqEy4sF6CMKQdznZ40pIgWjmCc1QqtwSH/j4CtWHybccdBNjSvlSd4nt+XC2v/ NwoNmyBwpUHCmXy/KucY4IUPN5+PUlcXvp1ftLk9VpzXgrSy8pnUOyUCwxjVc4BDArqsiF vsoC3548y16tnYYM0VbnK/qlbigUeJ8eNTg3pF/86Gwm6kQI11IC0vEme2DFHw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=f1QOk2Et; 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 144.217.243.247 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=f1QOk2Et; 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 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 61BEA25DF0 X-Spam-Score: 1.92 X-Migadu-Scanner: scn0.migadu.com X-TUID: +Df6USvi90wa 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") + 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 89eb744d..c379d140 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -564,26 +564,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