-
Notifications
You must be signed in to change notification settings - Fork 72
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
Save only valid D-Bus Names #454
base: master
Are you sure you want to change the base?
Conversation
@@ -23,12 +23,15 @@ const {GObject} = imports.gi; | |||
const {FlatpakSharedModel} = imports.models.shared; | |||
const {FlatsealOverrideStatus} = imports.models.overrideStatus; | |||
|
|||
/* https://dbus.freedesktop.org/doc/dbus-specification.html */ | |||
const EXP = /^(([A-Z]|[a-z]|[0-9]|_|-)+)(\.(([A-Z]|[a-z]|[0-9]|_|-)+))+(\.\*){0,1}$/; |
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.
- hyphens are not allowed
- regex can be simplified (
([A-Z]|[a-z])
->([A-Za-z])
) - names must not start with an digit
const EXP = /^(([A-Z]|[a-z]|[0-9]|_|-)+)(\.(([A-Z]|[a-z]|[0-9]|_|-)+))+(\.\*){0,1}$/; | |
const EXP = /^([A-Za-z_][A-Za-z0-9_]+)(\.[A-Za-z_][A-Za-z0-9_]+)+(\.\*)?$/; |
(untested suggestion)
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.
This RegEx is not from me. It is already used in Flatseal.
Flatseal/src/widgets/busNameRow.js
Lines 27 to 28 in 562ddec
/* https://dbus.freedesktop.org/doc/dbus-specification.html */ | |
const EXP = /^(([A-Z]|[a-z]|[0-9]|_|-)+)(\.(([A-Z]|[a-z]|[0-9]|_|-)+))+(\.\*){0,1}$/; |
It is used to display the valid icon in the D-Bus edit field. If it is wrong, it should be fixed in both places.
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.
hypens are allowed, but just on the last segment of the name
@@ -180,7 +183,9 @@ var FlatpakSessionBusModel = GObject.registerClass({ | |||
saveToKeyFile(keyFile) { | |||
const group = this.constructor.getGroup(); | |||
Object.entries(this._overrides).forEach(([key, value]) => { | |||
keyFile.set_value(group, key, value); | |||
if (this._expression.test(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.
For consistency, instead of doing this here, can you move this to updateFromProxyProperty
? Like I do it here https://github.com/tchx84/Flatseal/blob/master/src/models/variables.js#L86
@@ -23,12 +23,15 @@ const {GObject} = imports.gi; | |||
const {FlatpakSharedModel} = imports.models.shared; | |||
const {FlatsealOverrideStatus} = imports.models.overrideStatus; | |||
|
|||
/* https://dbus.freedesktop.org/doc/dbus-specification.html */ | |||
const EXP = /^(([A-Z]|[a-z]|[0-9]|_|-)+)(\.(([A-Z]|[a-z]|[0-9]|_|-)+))+(\.\*){0,1}$/; |
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.
To make this better than I currently do it, how about we officially move the definition of this esoteric regexp to this model (e.g. var BUS_NAME_REGEX = ...
), and then we import this constant here https://github.com/tchx84/Flatseal/blob/master/src/widgets/busNameRow.js#L28 (instead of duplicating it)
Flatpak has a Bug that Apps didn't start when you give them Permission to talk to a invalid D-Dbus name (flatpak/flatpak#4940). Until this is fixed, it is better to block writing invalid D-Bus names. If someone does accidental use a invalid D-Bus name for global and ignore the warning, no Flatpak App will start until the problem is solved with the Flatpak cli or the overrides file is deleted.