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

Add pwnlib.config module and documentation #893

Merged
merged 1 commit into from
Feb 13, 2017
Merged

Add pwnlib.config module and documentation #893

merged 1 commit into from
Feb 13, 2017

Conversation

zachriggle
Copy link
Member

@zachriggle zachriggle commented Feb 13, 2017

This adds functionality for user configuration files at ~/.pwn.conf
and /etc/pwn.conf. Previously this was only used by the pwnlib.log
module, and was entirely undocumented.

This is now documented, and offers an easy mechanism for other parts
of the code to have extension points.

An example configuration might look like:

[log]
success.symbol=😎
error.symbol=☠
info.color=blue

[context]
adb_port=4141
randomize=1
timeout=60
terminal=['x-terminal-emulator', '-e']

@zachriggle
Copy link
Member Author

It's not clear whether we should continue to use ~/.pwn.conf or use something else. I think we can use ~/.pwn.conf as a fall-back without any ill consequences, if we want to advertise a different "preferred" location.

from pwnlib.util import safeeval
for key, value in section.items():
if key not in ContextType.defaults:
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this get a warning?

pwnlib/log.py Outdated
if section not in _msgtype_prefixes:
def read_log_config(settings):
for key, value in settings.items():
if '.' not in key:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question.

elif key == 'symbol':
_msgtype_prefixes[section][1] = value
elif key == 'symbol':
_msgtype_prefixes[msgtype][1] = value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@zachriggle
Copy link
Member Author

Added warning messages, though it requires more circular imports

This adds functionality for user configuration files at ~/.pwn.conf
and /etc/pwn.conf.  Previously this was only used by the pwnlib.log
module, and was entirely undocumented.

This is now documented, and offers an easy mechanism for other parts
of the code to have extension points.
@zachriggle zachriggle merged commit 6585897 into dev Feb 13, 2017
@zachriggle zachriggle deleted the config-file branch February 13, 2017 22:55
@TethysSvensson TethysSvensson modified the milestones: 3.6.0, Someday Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants