@@ -36,26 +36,24 @@ class TracebackEntry(namedtuple.abc):
def _get_frame_args(frame):
"""Get the formatted arguments and class (if available) for a frame"""
- arginfo = inspect.getargvalues(frame)
+ args, varargs, keywords, local = inspect.getargvalues(frame)
+ if not args:
+ return '', None
- if not arginfo.args:
- return '', None
-
- firstarg = arginfo.args[0]
+ firstarg = args[0]
if firstarg == 'self':
- self = arginfo.locals['self']
+ self = local['self']
cls = self.__class__.__name__
- arginfo.args.pop(0)
- try:
- del arginfo.locals['self']
- except TypeError:
- # FIXME - python 3.13 FrameLocalsProxy can't be modified
- pass
+ args.pop(0)
+ del local['self']
else:
cls = None
- formatted = inspect.formatargvalues(*arginfo)
+ if local.get("HIDE_FRAME_ARGS", False):
+ return '(HIDDEN)', cls
+
+ formatted = inspect.formatargvalues(args, varargs, keywords, local)
return formatted, cls
def extract_traceback(tb, context=1):
The exception code in bitbake prints out the arguments to functions calls, and while this is very useful, it means that if there are secret credentials in arguments (like the password for bitbake hashserver client), they will be shown in the logs and potentially leaked. To prevent this, add code that checks for the local variable HIDE_FRAME_ARGS in the function. If present and set to True, the exception code will not print the value of any of the function arguments. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> --- bitbake/lib/bb/exceptions.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)