| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…its configured password Fixes mitmproxy#8138
|
|
||
| def load_pem_private_key(data: bytes, password: bytes | None) -> rsa.RSAPrivateKey: | ||
| """ | ||
| like cryptography's load_pem_private_key, but silently falls back to not using a password | ||
| like cryptography's load_pem_private_key, but falls back to not using a password | ||
| if the private key is unencrypted. | ||
| """ | ||
| try: | ||
| return serialization.load_pem_private_key(data, password) # type: ignore | ||
| except TypeError: | ||
| if password is not None: | ||
| logger.warning( | ||
| "A password was configured for a private key that is not encrypted. " | ||
| "Ignoring the password and loading the key without one." | ||
| ) | ||
| return load_pem_private_key(data, None) | ||
| raise |
There was a problem hiding this comment.
remove this unrelated stuff please
Sorry, something went wrong.
| assert cert.crl_distribution_points == crls | ||
|
|
||
|
|
||
| class TestLoadPemPrivateKey: |
There was a problem hiding this comment.
same
Sorry, something went wrong.
| - Unquoted regexes must not contain parentheses, whitespace, or the `~`, `'`, `"` | ||
| characters, as these are used for grouping and quoting. A regex containing any | ||
| of these, e.g. one using `(...)` for grouping, must be wrapped in quotes - | ||
| `~u "get(Info|Routers)"` - or it will be parsed as multiple filter expressions. |
There was a problem hiding this comment.
| - Unquoted regexes must not contain parentheses, whitespace, or the `~`, `'`, `"` | |
| characters, as these are used for grouping and quoting. A regex containing any | |
| of these, e.g. one using `(...)` for grouping, must be wrapped in quotes - | |
| `~u "get(Info|Routers)"` - or it will be parsed as multiple filter expressions. | |
| - Regexes containing parentheses, whitespace, or the `~`, `'`, `"` characters must be quoted because these characters are reserved by the filter expression syntax. Otherwise, the expression may be parsed differently or rejected. For example, use ~u "get(Info|Routers)". |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
#7715 reports that an unquoted regex containing grouping parentheses, e.g. ~u get(Info|Routers), is silently misparsed: ( and ) are reserved characters used by the boolean-grouping grammar in mitmproxy/flowfilter.py (unicode_words = pp.CharsNotIn("()~'\"" + DEFAULT_WHITE_CHARS)), so the filter actually becomes ~u get & ~u "Info|Routers" rather than a single regex match. I confirmed this by parsing several expressions directly with mitmproxy.flowfilter.parse():
Redesigning the grammar to disambiguate regex-parens from grouping-parens is a real design trade-off a maintainer should own, so rather than touch the parser this PR only fixes the documentation, which currently states "Regexes can be specified as quoted strings" without mentioning that some regexes must be quoted to parse correctly - contradicting user expectations as described in the issue.
Fixes #7715
Changes