Skip to content
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

Invalid format 'format' for '%' style #176

Closed
obilodeau opened this issue Jan 15, 2020 · 5 comments
Closed

Invalid format 'format' for '%' style #176

obilodeau opened this issue Jan 15, 2020 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@obilodeau
Copy link
Member

Stacktrace trying to use PyRDP mitm on arch linux:

Traceback (most recent call last):
  File "./bin/pyrdp-mitm.py", line 302, in <module>
    main()
  File "./bin/pyrdp-mitm.py", line 176, in main
    prepareLoggers(logLevel, args.log_filter, args.sensor_id, outDir)
  File "./bin/pyrdp-mitm.py", line 83, in prepareLoggers
    log.prepareSSLLogger(logDir / "ssl.log")
  File "/home/olivier/Documents/gosecure/src/pyrdp/pyrdp/logging/log.py", line 37, in prepareSSLLogger
    formatter = SSLSecretFormatter()
  File "/home/olivier/Documents/gosecure/src/pyrdp/pyrdp/logging/formatters.py", line 75, in __init__
    super().__init__("format")
  File "/usr/lib/python3.8/logging/__init__.py", line 576, in __init__
    self._style.validate()
  File "/usr/lib/python3.8/logging/__init__.py", line 429, in validate
    raise ValueError("Invalid format '%s' for '%s' style" % (self._fmt, self.default_format[0]))
ValueError: Invalid format 'format' for '%' style

I recently upgraded to Python 3.8 and the Formatter class changed: https://docs.python.org/3/library/logging.html#logging.Formatter. I think this is what caused it.

@obilodeau obilodeau added the bug Something isn't working label Jan 15, 2020
@obilodeau obilodeau self-assigned this Jan 15, 2020
@Res260
Copy link
Collaborator

Res260 commented Jan 15, 2020

That would make sense. When thinking about the logging infrastructure, we made the decision to tweak our logging beyond the "intended" use of %()s-style formatting.

We use arbitrary names which are passed to the logging operation by a dictionnary in the second argument (ex myLogger.info('my log statement with a non-standard %(variable)s', {'variable': 'variable name'}) )

hmu if you need details

@Res260
Copy link
Collaborator

Res260 commented Jan 15, 2020

If I understand correctly, setting validate=False in the Formatter's constructor would fix the problem.

@obilodeau
Copy link
Member Author

It's simpler than that. I'm pushing the patch in a few seconds.

@Res260
Copy link
Collaborator

Res260 commented Jan 15, 2020

You can wait a bit to have 1337 commits for a little bit longer :D

image

@obilodeau
Copy link
Member Author

Haha too late 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants