Add pwnlib.config module and documentation #893

Merged
merged 1 commit into from Feb 13, 2017

Conversation

Projects
None yet
2 participants
@zachriggle
Contributor

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 zachriggle requested a review from Idolf Feb 13, 2017

@zachriggle zachriggle self-assigned this Feb 13, 2017

@zachriggle zachriggle added the feature label Feb 13, 2017

@zachriggle zachriggle added this to the Someday milestone Feb 13, 2017

@zachriggle

This comment has been minimized.

Show comment
Hide comment
@zachriggle

zachriggle Feb 13, 2017

Contributor

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.

Contributor

zachriggle commented Feb 13, 2017

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.

pwnlib/context/__init__.py
+ from pwnlib.util import safeeval
+ for key, value in section.items():
+ if key not in ContextType.defaults:
+ continue

This comment has been minimized.

@Idolf

Idolf Feb 13, 2017

Contributor

Should this get a warning?

@Idolf

Idolf Feb 13, 2017

Contributor

Should this get a warning?

pwnlib/log.py
- if section not in _msgtype_prefixes:
+def read_log_config(settings):
+ for key, value in settings.items():
+ if '.' not in key:

This comment has been minimized.

@Idolf

Idolf Feb 13, 2017

Contributor

Same question.

@Idolf

Idolf Feb 13, 2017

Contributor

Same question.

- elif key == 'symbol':
- _msgtype_prefixes[section][1] = value
+ elif key == 'symbol':
+ _msgtype_prefixes[msgtype][1] = value

This comment has been minimized.

@Idolf

Idolf Feb 13, 2017

Contributor

Same question.

@Idolf

Idolf Feb 13, 2017

Contributor

Same question.

This comment has been minimized.

@zachriggle

zachriggle Feb 13, 2017

Contributor

Done

@zachriggle

zachriggle Feb 13, 2017

Contributor

Done

@zachriggle

This comment has been minimized.

Show comment
Hide comment
@zachriggle

zachriggle Feb 13, 2017

Contributor

Added warning messages, though it requires more circular imports

Contributor

zachriggle commented Feb 13, 2017

Added warning messages, though it requires more circular imports

Add pwnlib.config module and documentation
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.
@Idolf

Idolf approved these changes Feb 13, 2017

@zachriggle zachriggle merged commit 6585897 into dev Feb 13, 2017

4 checks passed

codacy/pr Good work! A positive pull request.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.003%) to 59.298%
Details

@zachriggle zachriggle deleted the config-file branch Feb 13, 2017

@Idolf Idolf 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