CVE-2023-4154 dsdb/tests: Speed up DirSync test by only checking positive matches...
authorAndrew Bartlett <abartlet@samba.org>
Mon, 7 Aug 2023 23:18:46 +0000 (11:18 +1200)
committerJule Anger <janger@samba.org>
Sun, 8 Oct 2023 20:06:23 +0000 (22:06 +0200)
When we (expect to) get back a result, do not waste time against a potentially
slow server confirming we also get back results for all the other attribute
combinations.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/tests/python/confidential_attr.py

index ee7f554a0080760089e370bc4292b623da3f7bd8..678a5a82948ae9c6d61640c3a67a229752aa9b53 100755 (executable)
@@ -742,7 +742,13 @@ class ConfidentialAttrTestDirsync(ConfidentialAttrCommon):
         #   want to weed out results from any previous test runs
         search = "(&{0}{1})".format(expr, self.extra_filter)
 
-        for attr in self.attr_filters:
+        # If we expect to return multiple results, only check the first
+        if expected_num > 0:
+            attr_filters = [self.attr_filters[0]]
+        else:
+            attr_filters = self.attr_filters
+
+        for attr in attr_filters:
             res = samdb.search(base_dn, expression=search, scope=SCOPE_SUBTREE,
                                attrs=attr, controls=self.dirsync)
             self.assertEqual(len(res), expected_num,