docstr: address ReDOS vulnerability:
  https://github.com/numpy/numpy/issues/23338
docstr_tok: ["address","ReDOS","vulnerability",":","https",":","\/\/github.com\/numpy\/numpy\/issues\/23338"]
code: def test_nameargspattern_backtracking(self, adversary):
      """address ReDOS vulnerability:
      https://github.com/numpy/numpy/issues/23338"""
      trials_per_batch = 12
      batches_per_regex = 4
      start_reps, end_reps = 15, 25
      for ii in range(start_reps, end_reps):
          repeated_adversary = adversary * ii
          # test times in small batches.
          # this gives us more chances to catch a bad regex
          # while still catching it before too long if it is bad
          for _ in range(batches_per_regex):
              times = []
              for _ in range(trials_per_batch):
                  t0 = time.perf_counter()
                  mtch = nameargspattern.search(repeated_adversary)
                  times.append(time.perf_counter() - t0)
              # our pattern should be much faster than 0.2s per search
              # it's unlikely that a bad regex will pass even on fast CPUs
              assert np.median(times) < 0.2
          assert not mtch
          # if the adversary is capped with @)@, it becomes acceptable
          # according to the old version of the regex.
          # that should still be true.
          good_version_of_adversary = repeated_adversary + "@)@"
          assert nameargspattern.search(good_version_of_adversary)
  
imports: import importlib
  import codecs
  import time
  import unicodedata
  import pytest
  import numpy
  from numpy.f2py.crackfortran import markinnerspaces, nameargspattern
  from .None import util
  from numpy.f2py import crackfortran
  import textwrap
  import contextlib
  import io
label_desc: Use image node_id 1 for calling the TestNameArgsPatternBacktracking obj's underlying member method code with example usage: obj.test_nameargspattern_backtracking(adversary) without return types