-
Notifications
You must be signed in to change notification settings - Fork 12
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
Load settings based on env variable #29
Conversation
1923d8e is a workaround to the 2) of #23 (comment) |
src/main/kotlin/burp/BurpExtender.kt
Outdated
} else if (serialized != null) { | ||
return Piper.Config.parseFrom(decompress(unpad4(Z85.Z85Decoder(serialized)))) | ||
} else { | ||
throw Exception("Fallback to default config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the message? Since you catch it with a wildcard catch
below, nobody will see this. Did you mean to print it to some console?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's just meant to be a kind of self-documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if I understand it right, this will then just silently load the default config for any exception (e.g. YAML syntax error). Is this desired/planned behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is intentional. A lot of things can go wrong during loading files alone, so my thinking was that if anything fails, we just go with the defaults. This would be an indication for the user about misconfiguration, but we may need some better signal.
src/main/kotlin/burp/BurpExtender.kt
Outdated
@@ -578,13 +579,25 @@ class BurpExtender : IBurpExtender, ITab, ListDataListener, IHttpListener { | |||
|
|||
private fun loadConfig(): Piper.Config { | |||
val serialized = callbacks.loadExtensionSetting(EXTENSION_SETTINGS_KEY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why load it if you potentially will never use it anyway? I'd only load it if env
is null
, which would also make the code easier to read/follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Resolved in 2754328
If PIPER_CONFIG environment variable is set, Piper will try to load a configuration from the file specified by the variable.
Filenames ending with .yml or .yaml are interpreted as YAML configs, otherwise Protobuf is assumed.
If something goes wrong, Piper gracefully falls back to default config (user-specific saved settings are skipped).