Block explicit HACL* HMAC constructors.
(name)
| 999 | |
| 1000 | |
| 1001 | def _block_builtin_hmac_constructor(name): |
| 1002 | """Block explicit HACL* HMAC constructors.""" |
| 1003 | info = get_hmac_item_info(name) |
| 1004 | assert info.module_name is None or info.module_name == "_hmac", info |
| 1005 | if (wrapped := info.import_member()) is None: |
| 1006 | # function shouldn't exist for this implementation |
| 1007 | return contextlib.nullcontext() |
| 1008 | |
| 1009 | @functools.wraps(wrapped) |
| 1010 | def wrapper(key, obj): |
| 1011 | raise ValueError(f"blocked hash name: {name}") |
| 1012 | |
| 1013 | _ensure_wrapper_signature(wrapper, wrapped) |
| 1014 | return unittest.mock.patch(info.fullname, wrapper) |
| 1015 | |
| 1016 | |
| 1017 | @contextlib.contextmanager |
no test coverage detected
searching dependent graphs…