From nobody Thu Mar 20 04:31:05 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZJCLz1gYYz5rG9p; Thu, 20 Mar 2025 04:31:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZJCLy0B9Mz41TX; Thu, 20 Mar 2025 04:31:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1742445066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ll1e3eTGqwAmjfP5/46QCUtS7L/aZ1l4fnCGipgxnTY=; b=QVLgB2ySASkInyiqH9f2rVCrhIKi3vKVYRcECIez35qscvXHrjpL3rvnUT27k65rs5wPdF NhaxvMFSMEs0JW41Ep/T5UvSXkD3L93G/psX00mcGIDlEGBgKrXgUKXJeyKf1+0UNVLlIo 0KtpWn6Vk7E7TBhSvrJmoPRPZNsdHaL0hA2YIKyUxZ3OtR/3+tsUvQ1f71pVKGjekNU7ia 2J2FcfKkT4/rnLdUz/abYXOk2B1Nd18yMJYDU+m804WoLHvsowtATRfF97/nMlTqlWfoqr qjBdWn7S2i1Firm7yoUhJI96K5HaCEPVaMZTWrTtSB21VDr2APIqA0252x8WFQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1742445066; a=rsa-sha256; cv=none; b=tkSYFvfybc5DheCI/nReZDE0ZJzykh9yJ3kVm0pI6uLT/kTFUIr1zwb0QgikhDK4YsUWfL U5BCsRwj3K4gZ+tIbg/nepsztJaSfFA/I3uLZ/7QnQ2X1/SQ38A8ABvw719ydp7l/3CzHy EzFgah+3/ftC1gwu1D0AeGTkBQkNtXN5xhZ7YMiauV+T7h6cpA1gqQJlmdrPNM7Ut3E8lc 7H/9Ih+MtYR+uhz0U18R8jDjZeF6VmPsU7F3Idud3DG0l69XCLOwmiYkr0zfv1XRNT2/iY LY+JL5UJVbo2nTzk1jlA7tGYmXdwf1OIKXTlrcttxjM4E0bZk/MOxtUgIMFh3A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1742445066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ll1e3eTGqwAmjfP5/46QCUtS7L/aZ1l4fnCGipgxnTY=; b=e2JGwjYcG37iEGGv7tN9FkgtoTdFbSzAFWVlroCp1W4MBK/ijV1rzTIrnxLjn2Xxgyek2l sQ/CFVO6TrRMvmEsRIc+XnW6m5J3UgPA0BXC4XffrvRE/IrBNVbBgZPVoohPxSKQPQSFAE 4gmRjOIZuhmD6P+mF1N1Q11yP1zlpHPfoR6C9YHKNELNJ+6so16TZG0sES0gptkoj1JWA3 d2fBClzrS5E9gY6nGgt9/vG+e/0QA+6SzSwHq6E0IB58t9T3ZCU7mk45NAixePX1fPD6XS D1Xv4B2EGI5hn2+dZTB8ouOTb1HHFeSqSwStZGxYp/vFije6sW6eNjzTjfMnFg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZJCLx634Dzqr7; Thu, 20 Mar 2025 04:31:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 52K4V5TS030948; Thu, 20 Mar 2025 04:31:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 52K4V5N7030945; Thu, 20 Mar 2025 04:31:05 GMT (envelope-from git) Date: Thu, 20 Mar 2025 04:31:05 GMT Message-Id: <202503200431.52K4V5N7030945@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: c849f5333260 - main - pf tests: add a basic snmp_pf test case List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c849f533326026501c28cb2c344b16723862551a Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=c849f533326026501c28cb2c344b16723862551a commit c849f533326026501c28cb2c344b16723862551a Author: Kristof Provost AuthorDate: 2025-03-19 06:42:42 +0000 Commit: Kristof Provost CommitDate: 2025-03-20 04:29:54 +0000 pf tests: add a basic snmp_pf test case Event: Tokyo Hackathon 202503 --- tests/sys/netpfil/pf/Makefile | 6 +++- tests/sys/netpfil/pf/bsnmpd.conf | 47 ++++++++++++++++++++++++++ tests/sys/netpfil/pf/snmp.sh | 71 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-) diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 8a24fae47dcb..3b1ba2085f43 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -45,6 +45,7 @@ ATF_TESTS_SH+= altq \ sctp \ set_skip \ set_tos \ + snmp \ src_track \ status \ syncookie \ @@ -63,7 +64,9 @@ ATF_TESTS_PYTEST+= sctp.py TEST_METADATA+= execenv="jail" TEST_METADATA+= execenv_jail_params="vnet allow.raw_sockets" -${PACKAGE}FILES+= CVE-2019-5597.py \ +${PACKAGE}FILES+= \ + bsnmpd.conf \ + CVE-2019-5597.py \ CVE-2019-5598.py \ daytime_inetd.conf \ echo_inetd.conf \ @@ -79,6 +82,7 @@ ${PACKAGE}FILES+= CVE-2019-5597.py \ rdr-srcport.py \ utils.subr +${PACKAGE}FILESMODE_bsnmpd.conf= 0555 ${PACKAGE}FILESMODE_CVE-2019-5597.py= 0555 ${PACKAGE}FILESMODE_CVE-2019-5598.py= 0555 ${PACKAGE}FILESMODE_fragcommon.py= 0555 diff --git a/tests/sys/netpfil/pf/bsnmpd.conf b/tests/sys/netpfil/pf/bsnmpd.conf new file mode 100644 index 000000000000..27abdda6cbd3 --- /dev/null +++ b/tests/sys/netpfil/pf/bsnmpd.conf @@ -0,0 +1,47 @@ +location := "A galaxy far, far away" +contact := "skywalker@Tatooine" +system := 1 + +read := "public" +write := "geheim" +trap := "mytrap" + +NoAuthProtocol := 1.3.6.1.6.3.10.1.1.1 +HMACMD5AuthProtocol := 1.3.6.1.6.3.10.1.1.2 +HMACSHAAuthProtocol := 1.3.6.1.6.3.10.1.1.3 +NoPrivProtocol := 1.3.6.1.6.3.10.1.2.1 +DESPrivProtocol := 1.3.6.1.6.3.10.1.2.2 +AesCfb128Protocol := 1.3.6.1.6.3.10.1.2.4 + +securityModelAny := 0 +securityModelSNMPv1 := 1 +securityModelSNMPv2c := 2 +securityModelUSM := 3 + +MPmodelSNMPv1 := 0 +MPmodelSNMPv2c := 1 +MPmodelSNMPv3 := 3 + +noAuthNoPriv := 1 +authNoPriv := 2 +authPriv := 3 + +%snmpd +begemotSnmpdDebugDumpPdus = 2 +begemotSnmpdDebugSyslogPri = 7 + +begemotSnmpdCommunityString.0.1 = $(read) +begemotSnmpdCommunityDisable = 1 + +begemotSnmpdTransInetStatus.1.4.0.0.0.0.161.1 = 4 +begemotSnmpdTransInetStatus.2.16.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.161.1 = 4 + +begemotSnmpdLocalPortStatus."/var/run/snmpd.sock" = 1 +begemotSnmpdLocalPortType."/var/run/snmpd.sock" = 4 + +sysContact = $(contact) +sysLocation = $(location) +sysObjectId = 1.3.6.1.4.1.12325.1.1.2.1.$(system) + +begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" +begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so" diff --git a/tests/sys/netpfil/pf/snmp.sh b/tests/sys/netpfil/pf/snmp.sh new file mode 100644 index 000000000000..0d6b2eb10ec7 --- /dev/null +++ b/tests/sys/netpfil/pf/snmp.sh @@ -0,0 +1,71 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2025 Kristof Provost +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +. $(atf_get_srcdir)/utils.subr + +atf_test_case "basic" "cleanup" +basic_head() +{ + atf_set descr 'Basic pf_snmp test' + atf_set require.user root +} + +basic_body() +{ + pft_init + + epair=$(vnet_mkepair) + + ifconfig ${epair}b 192.0.2.2/24 up + + vnet_mkjail alcatraz ${epair}a + jexec alcatraz ifconfig ${epair}a 192.0.2.1/24 up + + # Start bsnmpd + jexec alcatraz bsnmpd -c $(atf_get_srcdir)/bsnmpd.conf + + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "pass" + + # Sanity check, and create state + atf_check -s exit:0 -o ignore \ + ping -c 1 192.0.2.1 + + # pf should be enabled + atf_check -s exit:0 -o match:'pfStatusRunning.0 = true' \ + bsnmpwalk -s public@192.0.2.1 -i pf_tree.def begemot +} + +basic_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "basic" +}