MCPcopy Index your code
hub / github.com/python/cpython / test_security

Method test_security

Lib/test/test_gettext.py:571–585  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

569
570 @support.skip_wasi_stack_overflow()
571 def test_security(self):
572 raises = self.assertRaises
573 # Test for a dangerous expression
574 raises(ValueError, gettext.c2py, "os.chmod('/etc/passwd',0777)")
575 # issue28563
576 raises(ValueError, gettext.c2py, '"(eval(foo) && ""')
577 raises(ValueError, gettext.c2py, 'f"{os.system(\'sh\')}"')
578 # Maximum recursion depth exceeded during compilation
579 raises(ValueError, gettext.c2py, 'n+'*10000 + 'n')
580 self.assertEqual(gettext.c2py('n+'*100 + 'n')(1), 101)
581 # MemoryError during compilation
582 raises(ValueError, gettext.c2py, '('*100 + 'n' + ')'*100)
583 # Maximum recursion depth exceeded in C to Python translator
584 raises(ValueError, gettext.c2py, '('*10000 + 'n' + ')'*10000)
585 self.assertEqual(gettext.c2py('('*20 + 'n' + ')'*20)(1), 1)
586
587 def test_chained_comparison(self):
588 # C doesn't chain comparison as Python so 2 == 2 == 2 gets different results

Callers

nothing calls this directly

Calls 2

raisesFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected