-
Notifications
You must be signed in to change notification settings - Fork 5
Stop polling when backend state is unavailable #470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
a567876
2845068
6720fd1
8ae8009
ac0f313
e3396fe
8625a11
966d965
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,16 @@ | |
| re.IGNORECASE, | ||
| ) | ||
|
|
||
| # Some Newznab indexers return download URLs shaped like | ||
| # ``/getnzb/id.nzb&i=ACCOUNT&r=APIKEY``. Because there is no ``?``, both | ||
| # credentials are parsed as part of the URL path rather than query params. | ||
| # Restrict the short ``i``/``r`` names to getnzb-looking paths so ordinary | ||
| # application URLs using those names are not over-redacted. | ||
| _GETNZB_PATH_CRED_RE = re.compile( | ||
| r"([&;](?:i|r))=([^&\s\"'<>]+)", | ||
| re.IGNORECASE, | ||
| ) | ||
|
|
||
|
Comment on lines
+44
to
+53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
rg -n "_REDACT_PARAM_NAMES" repo/plugin.video.nzbdav/resources/lib/http_util.py -B2 -A10Repository: Appz4Fun/nzbdavkodi Length of output: 1244 🏁 Script executed: #!/bin/bash
set -euo pipefail
sed -n '1,130p' repo/plugin.video.nzbdav/resources/lib/http_util.py | cat -n
printf '\n--- occurrences ---\n'
rg -n "_GETNZB_PATH_CRED_RE|redact_url|_REDACT_PARAM_NAMES|getnzb" repo/plugin.video.nzbdav/resources/lib
printf '\n--- read-only parser probe ---\n'
python3 - <<'PY'
import urllib.parse as up
url = "https://example.com/getnzb/id.nzb?i=ACCOUNT&r=APIKEY"
parts = up.urlparse(url)
print("scheme", parts.scheme)
print("netloc", parts.netloc)
print("path", parts.path)
print("query", parts.query)
print("parsed qsl keys:", [k for k, v in up.parse_qsl(parts.query, keep_blank_values=True)])
PYRepository: Appz4Fun/nzbdavkodi Length of output: 11415 Redact
🤖 Prompt for AI Agents |
||
| # Catch ``scheme://user:password@host`` userinfo embedded in free-form text. | ||
| # urllib / socket / xbmcvfs errors sometimes echo the failing URL — e.g. the | ||
| # NZBGet JSON-RPC URL or the ``smb://user:pass@host/...`` completed-folder | ||
|
|
@@ -91,9 +101,10 @@ def redact_url(url): | |
| # WebDAV stack used to accept). Strip the password half before | ||
| # logging. TODO.md §H.2-H2d. | ||
| netloc = _redact_netloc_userinfo(parts.netloc) | ||
| return urlunsplit( | ||
| (parts.scheme, netloc, parts.path, urlencode(query), parts.fragment) | ||
| ) | ||
| path = parts.path | ||
| if "getnzb" in path.lower() or ".nzb&" in path.lower(): | ||
| path = _GETNZB_PATH_CRED_RE.sub(r"\1=REDACTED", path) | ||
| return urlunsplit((parts.scheme, netloc, path, urlencode(query), parts.fragment)) | ||
|
|
||
|
|
||
| def _redact_netloc_userinfo(netloc): | ||
|
|
@@ -113,22 +124,14 @@ def _redact_netloc_userinfo(netloc): | |
| return "{}@{}".format(userinfo, host) | ||
|
|
||
|
|
||
| def _redact_url_userinfo_span(match): | ||
| """Strip the password from a URL span's ``user:pass@host`` userinfo. | ||
| def _redact_url_span(match): | ||
| """Redact credentials only within a matched URL span. | ||
|
|
||
| Reuses the same ``rpartition('@')`` / ``partition(':')`` logic as | ||
| ``redact_url`` so an ``@`` *inside* the password (or an empty username) | ||
| can't leak. Spans with no userinfo round-trip unchanged. | ||
| Reusing ``redact_url`` covers both URL userinfo and non-standard Newznab | ||
| path credentials without applying short ``i``/``r`` parameter names to | ||
| unrelated text elsewhere in the same message. | ||
| """ | ||
| span = match.group(0) | ||
| try: | ||
| parts = urlsplit(span) | ||
| except (ValueError, TypeError): | ||
| return span | ||
| if not parts.netloc or "@" not in parts.netloc: | ||
| return span | ||
| netloc = _redact_netloc_userinfo(parts.netloc) | ||
| return urlunsplit((parts.scheme, netloc, parts.path, parts.query, parts.fragment)) | ||
| return redact_url(match.group(0)) | ||
|
|
||
|
|
||
| def redact_text(text): | ||
|
|
@@ -146,7 +149,7 @@ def redact_text(text): | |
| # ``\1`` is the key group; a backreference replacement avoids a per-match | ||
| # Python callback on this hot logging/error path. | ||
| redacted = _EMBEDDED_CRED_RE.sub(r"\1=REDACTED", str(text)) | ||
| return _EMBEDDED_URL_RE.sub(_redact_url_userinfo_span, redacted) | ||
| return _EMBEDDED_URL_RE.sub(_redact_url_span, redacted) | ||
|
|
||
|
|
||
| _WHITESPACE_RE = re.compile(r"\s+") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.