ashirt-ops / ashirt

It records your screenshots and code, then lets you upload to ASHIRT
MIT License
49 stars 10 forks source link

AppConfig to QSettings #186

Closed crizzitello closed 2 years ago

crizzitello commented 2 years ago

Currently Does

jrozner commented 2 years ago

If we don't switch over to using QSettings is any of the rest of this worthwhile? What is the benefit to using QSettings over JSON? Go doesn't have an ini parser as part of the std library and we'd need to update aterm in order to make this change.

crizzitello commented 2 years ago

If we don't switch over to using QSettings is any of the rest of this worthwhile?

Yes some of this can be applied to the old code. The singleton pattern, use of QStrings, the CONFIG struct

What is the benefit to using QSettings over JSON?

QSettings makes the code alot easier to read and is really the class made for Settings. We can read or write a single value instead of always reading the full file. QSettings does allow us to define a QSettings "Backend", The default is to use a system backend ( conf on linux and registry on windows).

Go doesn't have an ini parser as part of the std library and we'd need to update aterm in order to make this change.

Parsing the ini format is pretty easy. Values can be a bit different if we store things like QtObjects. The keys without a / are put in the "general" section.

[General]
accessKey=xxxxxxxxxxxxxxxxxxxxxxxx
apiURL=http://localhost:3000
captureClipboardShortcut=Ctrl+Alt+3
captureWindowExec=spectacle -a -bno %file
captureWindowShortcut=Ctrl+Alt+2
evidenceRepo=/home/chris/evidence
screenshotCommand=spectacle -r -bno %file
screenshotShortcut=Ctrl+Alt+1
secretKey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

other sections could be in the file these depend on the key string used for example a keys of screenshot/command and screenshot/shortcut would put in the file

[screenshot]
command=value
shortcut=value
crizzitello commented 2 years ago

Now with a json backend.