1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

CVE-2023-4154 dsdb/tests: Use self.addCleanup() and delete_force()

Thie helps ensure this test is reliable even in spite of errors while
running.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15424

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andrew Bartlett 2023-08-07 13:15:40 +12:00 committed by Jule Anger
parent 6578a65ed7
commit 07d2b28fb3
2 changed files with 3 additions and 9 deletions

View File

@ -98,7 +98,9 @@ class ConfidentialAttrCommon(samba.tests.TestCase):
userou = "OU=conf-attr-test"
self.ou = "{0},{1}".format(userou, self.base_dn)
samba.tests.delete_force(self.ldb_admin, self.ou, controls=['tree_delete:1'])
self.ldb_admin.create_ou(self.ou)
self.addCleanup(samba.tests.delete_force, self.ldb_admin, self.ou, controls=['tree_delete:1'])
# use a common username prefix, so we can use sAMAccountName=CATC-* as
# a search filter to only return the users we're interested in
@ -139,10 +141,6 @@ class ConfidentialAttrCommon(samba.tests.TestCase):
"{0} searchFlags already {1}".format(self.conf_attr,
search_flags))
def tearDown(self):
super(ConfidentialAttrCommon, self).tearDown()
self.ldb_admin.delete(self.ou, ["tree_delete:1"])
def add_attr(self, dn, attr, value):
m = Message()
m.dn = Dn(self.ldb_admin, dn)

View File

@ -137,10 +137,6 @@ class SimpleDirsyncTests(DirsyncBaseTests):
if self.ouname:
delete_force(self.ldb_admin, self.ouname)
self.sd_utils.modify_sd_on_dn(self.base_dn, self.desc_sddl)
try:
self.ldb_admin.deletegroup("testgroup")
except Exception:
pass
# def test_dirsync_errors(self):
@ -499,6 +495,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
self.assertEqual(len(res[0].get("member")), size)
self.ldb_admin.newgroup("testgroup")
self.addCleanup(self.ldb_admin.deletegroup, "testgroup")
self.ldb_admin.add_remove_group_members("testgroup", [self.simple_user],
add_members_operation=True)
@ -537,7 +534,6 @@ class SimpleDirsyncTests(DirsyncBaseTests):
attrs=["member"],
controls=[control1])
self.ldb_admin.deletegroup("testgroup")
self.assertEqual(len(res[0].get("member")), 0)
def test_dirsync_deleted_items(self):