Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3175d14
Redact secrets when logging
seanbudd Apr 17, 2026
e3a0dea
Apply suggestions from code review
seanbudd Apr 17, 2026
a0702a8
fix inclusion
seanbudd Apr 17, 2026
94c1668
fix up detection and formatting
seanbudd Apr 17, 2026
520d9bc
Pre-commit auto-fix
pre-commit-ci[bot] Apr 17, 2026
098b3cb
document changes
seanbudd Apr 17, 2026
fb2fe7e
review suggestions
seanbudd Apr 17, 2026
9b266b5
Pre-commit auto-fix
pre-commit-ci[bot] Apr 17, 2026
a2551f4
add unit tests
seanbudd Apr 17, 2026
c15a546
Pre-commit auto-fix
pre-commit-ci[bot] Apr 17, 2026
86851a5
Merge remote-tracking branch 'origin/master' into detectSecrets
seanbudd Apr 20, 2026
f58c1f6
fix detect_secrets inclusion
seanbudd Apr 20, 2026
cb35311
fix up
seanbudd Apr 20, 2026
143bd04
Merge remote-tracking branch 'origin/master' into detectSecrets
seanbudd Apr 21, 2026
bec0131
Add log level and warning
seanbudd Apr 21, 2026
cdc846f
Fix behaviour
seanbudd Apr 21, 2026
2d8e7ed
Merge remote-tracking branch 'origin/master' into detectSecrets
seanbudd Apr 21, 2026
0b52053
Pre-commit auto-fix
pre-commit-ci[bot] Apr 21, 2026
3177144
fix elif
seanbudd Apr 21, 2026
43d007b
Add help id
seanbudd Apr 21, 2026
ccc6aa2
Apply suggestion from @seanbudd
seanbudd Apr 21, 2026
00eb8bf
Apply suggestion from @seanbudd
seanbudd Apr 21, 2026
8f54736
restore mathcat?
seanbudd Apr 21, 2026
f0c7c4b
Merge remote-tracking branch 'refs/remotes/origin/detectSecrets' into…
seanbudd Apr 21, 2026
49b2043
Update source/logHandler.py
seanbudd Apr 21, 2026
3924102
Update source/logHandler.py
seanbudd Apr 21, 2026
7c982ff
line end
seanbudd Apr 22, 2026
c71c883
Merge remote-tracking branch 'origin/master' into detectSecrets
seanbudd Apr 22, 2026
85dab52
fix ineq
seanbudd Apr 22, 2026
8a70eba
Merge remote-tracking branch 'origin/master' into detectSecrets
seanbudd Apr 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dependencies = [
"mdx-gh-links==0.4",
"l2m4m==1.0.4",
"pymdown-extensions==10.17.1",
"detect-secrets==1.5.0",
]

[project.urls]
Expand Down
3 changes: 2 additions & 1 deletion source/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def _loadConfig(self, fn, fileError=False):
profileUpgrader.upgrade(profile, self.validator, writeProfileFunc)
except Exception as e:
# Log at level info to ensure that the profile is logged.
log.info("Config before schema update:\n%s" % profileCopy, exc_info=False)
log.info("Config before schema update:\n%s" % profileCopy, exc_info=False, redactSecrets=True)
raise e
# since profile settings are not yet imported we have to "peek" to see
# if debug level logging is enabled.
Expand All @@ -618,6 +618,7 @@ def _loadConfig(self, fn, fileError=False):
"Config loaded (after upgrade, and in the state it will be used by NVDA):\n{0}".format(
profile,
),
redactSecrets=True,
)
return profile

Expand Down
44 changes: 36 additions & 8 deletions source/logHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,30 @@ class Logger(logging.Logger):

def _log(
self,
level,
msg,
level: int,
msg: str,
args,
exc_info=None,
extra=None,
codepath=None,
activateLogViewer=False,
stack_info=None,
exc_info: _excInfo_t | Literal[True] | BaseException = None,
extra: dict | None = None,
codepath: str | None = None,
activateLogViewer: bool = False,
stack_info: list[traceback.FrameSummary] | bool | None = None,
Comment thread
seanbudd marked this conversation as resolved.
Outdated
redactSecrets: bool = False,
):
"""Logs a message with the given severity level.

:param level: The severity level of the log message.
:param msg: The log message, which may contain format specifiers that will be replaced by the values in `args`.
:param args: The arguments to be merged into `msg` using the `%` operator for string formatting.
:param exc_info: Exception information to be logged, defaults to None
:param extra: Additional information to be logged, defaults to None
:param codepath: The code path where the log was generated, defaults to None
:param activateLogViewer: Whether to activate the log viewer, defaults to False
:param stack_info: Stack information to be logged, defaults to None
:param redactSecrets: Whether to check for and redact secrets in the log message, defaults to False
Comment thread
seanbudd marked this conversation as resolved.
Outdated
:return: The result of the logging operation
Comment thread
seanbudd marked this conversation as resolved.
Outdated
"""
Comment thread
seanbudd marked this conversation as resolved.
Outdated

if not extra:
extra = {}

Expand Down Expand Up @@ -273,7 +288,20 @@ def _log(
"".join(traceback.format_list(stack_info)).rstrip(),
)

res = super()._log(level, msg, args, exc_info, extra)
if redactSecrets:
from detect_secrets.core.scan import scan_line
from detect_secrets.settings import default_settings

formattedMsg = msg % args if args else msg

with default_settings():
for secret in list(scan_line(formattedMsg)):
Comment thread
seanbudd marked this conversation as resolved.
Outdated
formattedMsg = formattedMsg.replace(secret.secret_value, "****")

res = super()._log(level, formattedMsg, (), exc_info, extra)
Comment thread
seanbudd marked this conversation as resolved.
Outdated

else:
res = super()._log(level, msg, args, exc_info, extra)
Comment thread
seanbudd marked this conversation as resolved.
Outdated

if activateLogViewer:
# Make the log text we just wrote appear in the log viewer.
Expand Down
2 changes: 2 additions & 0 deletions source/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ def _genManifestTemplate(shouldHaveUIAccess: bool) -> tuple[int, int, bytes]:
"mdx_truly_sane_lists",
"mdx_gh_links",
"pymdownx",
# Force as only import is scoped in a function.
"detect_secrets",
],
"includes": [
"nvdaBuiltin",
Expand Down
4 changes: 4 additions & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ Please refer to [the developer guide](https://download.nvaccess.org/documentatio
* uv to 0.11.4. (#19548, #19908)
* Requests to 2.33.0. (#19877)
* cryptography to 46.0.6. (#19877)
* A new parameter `redactSecrets` has been added to logging functions e.g. `log.debug`. (#19966)
* When set to `True`, logging output will be sanitized to replace detected secrets with asterisks.
* This is set to `False` by default for performance purposes.
* It is encouraged to enable this when logging anything particularly sensitive e.g. clipboard content.
* NVDA libraries built by the build system are now linked with the [/SETCOMPAT](https://learn.microsoft.com/en-us/cpp/build/reference/cetcompat) flag, improving protection against certain malware attacks. (#19435, @LeonarddeR)
* Subclasses of `browseMode.BrowseModeDocumentTreeInterceptor` that support screen layout being on and off should override the `_toggleScreenLayout` method, rather than implementing `script_toggleScreenLayout` directly. (#19487)
* A new method has been added to the UIA.UIA class, called `_getUIACacheablePropertyValue_handleCOMErrors`. (#19646, @Emil-18)
Expand Down
15 changes: 15 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading