CoreyD97 / Burp-Montoya-Utilities

A collection of utilities for building extensions using Burp's Montoya API
GNU Affero General Public License v3.0
46 stars 9 forks source link

When persistedDefault == false, `preferences` shares instance with `preferenceDefaults` #10

Closed CrazyKidJack closed 8 months ago

CrazyKidJack commented 8 months ago

Description: I believe the example code referenced in this issue contained a bug and that code was accidentally part of this PR which was recently merged.

If persistDefault is false, the new code will put() into preferences a reference to the same instance of defaultValue as what is put into preferenceDefaults.

I believe this would have the effect that if the user were to make any modifications to the value put in preferences those changes would get reflected in the stored default as well (which is obviously not what we want).

I believe the solution is to do what your set() method does: use GSON to create a copy, and put() that copy into preferences.

Steps To Reproduce: I haven't actually tested it yet

Expected behavior: Modifying the object stored in preferences should not also modify the object stored in preferenceDefaults

CrazyKidJack commented 8 months ago

I'll submit a PR to fix this shortly