DLP error message name cannot contain capital letter, special characters or punctuation marks
Categories
(Enterprise Products :: Console, defect)
Tracking
(Not tracked)
People
(Reporter: pmagyari, Assigned: julienw)
References
(Depends on 1 open bug, Blocks 1 open bug, Regression)
Details
(Keywords: regression)
Attachments
(2 files)
Affected version
- All
Affected platforms
- All
Steps to reproduce
- Log into FxE.
- Open Admin console.
- Attempt to set up DLP and add a custom error message name.
Expected result
- Name of the error message can start/contain a capital letter(s).
Actual result
- If the name of the message contains a capital letter, special character or punctuation mark it does not let you apply the rule.
Note
- " - " is allowed in the name of the message.
| Assignee | ||
Comment 1•2 months ago
|
||
Yeah, this is likely incorrect and was added in bug 2044495. But Firefox doesn't look at the pattern information in the schema so the issue wasn't caught at the time.
I think we can use something much less strict such as ^.{1,64}$. What do you think Jonathan?
| Assignee | ||
Comment 2•2 months ago
|
||
After changing it in the policies file in the firefox codebase, we'll have to refresh the policies in the console, with apologies to Michael :-)
| Assignee | ||
Comment 3•2 months ago
|
||
While we're there we could also add minLength: 1 on Domain and ContentPatterns items, along with a pattern that forbids spaces (at least for the domain)
I'm confused. There is no pattern information for the Message field (only for the Name field).
I'm also not sure what you mean by "Firefox doesn't look at the pattern information", as my understanding is that the policies do get validated against the pattern information during ingestion? For example if I use "Restricted." in the Name field in a local policies.json policy, I get a validation error in about:policies
| Assignee | ||
Comment 5•2 months ago
|
||
(In reply to jmendez from comment #4)
Created attachment 9647449 [details]
NamePolicyPatternError.pngI'm confused. There is no pattern information for the Message field (only for the Name field).
Yes, the problem is on the Name field. I think the screenshot above is misleading :-)
I'm also not sure what you mean by "Firefox doesn't look at the pattern information", as my understanding is that the policies do get validated against the pattern information during ingestion? For example if I use "Restricted." in the Name field in a local policies.json policy, I get a validation error in
about:policies
I was trusting the comment in https://searchfox.org/firefox-main/rev/9e9b5f17f56187c1f5c8b9cdf79a01ff51a7b643/toolkit/components/utils/JsonSchemaValidator.sys.mjs#12 but in the code I see it's actually handled indeed: https://searchfox.org/firefox-main/rev/9e9b5f17f56187c1f5c8b9cdf79a01ff51a7b643/toolkit/components/utils/JsonSchemaValidator.sys.mjs#291-305 :-) so ignore my comment about that !
I would like clarity from pmagyari on what this Bug is capturing. Is the unexpected behavior for the "Message" field (with "Restricted." in the screenshot) or for the "Name" field (with "Warning" in the screenshot)?
If it's the "Name" field, the pattern is intentional and matching what's in the spec (see Validation section on the Option A tab). It's a Product-level decision to change it.
If it's the "Message" field, then the behavior is unexpected and a bug that would need investigation for the console behavior.
| Assignee | ||
Comment 7•2 months ago
|
||
I see!
Hey Brian, it looks like the restriction on the Name field was in the spec. While it's not a big issue it seems like an arbitrary restriction to me. Especially capital letters are forbidden which sounds silly :-) and also letters with accent which might be useful in a country like France.
I'm also not sure how to ensure the uniqueness of the name. Surely it is enforced in Firefox but it's not in the console because it can't be expressed in JSON schema. So this might silently fail without the admin knowing directly (of course they might know indirectly). I don't have a solution for that right now but thought it would be good you know about that.
Thanks !
Comment 8•2 months ago
|
||
Thanks, all. Maybe we missed this when looking at the schema initially, the rule name was a shorthand / convenience for admins. Maybe this would have been better:
"Rules": {
"warn-ai-paste": {
"Enabled":
Then we could enforce uniqueness. Right now in events, we report the rule name, so it's possible for two different rules to have the same name, which could be confusing. I think it was an oversight that JSON schema can't express that, unfortunately.
| Assignee | ||
Comment 9•1 month ago
|
||
Discussed with Andi: we can show the actual pattern in the input description (the "description" attribute for moz-input-text). For a technical UI this sounds about right to show the technical details.
Comment 10•1 month ago
|
||
Thanks a lot. Do we need to discuss the uniqueness issue? We still have some flexibility on the shape of the schema, but maybe not for long.
Comment 11•1 month ago
|
||
If we want to enforce the uniqueness, I see two options on the client side:
- I have an existing
validateDlpRules()that currently checks for invalid regex in the content patterns. I could add a uniqueness check for the names there. This way would need a similar check on the console side.- This path would surface a problem in about:policies's error section. For multiple rules by the same name we could either pick the first one or drop all of them.
- As suggested above, change the shape of the rules in the schema to be name-keyed objects. This way probably would need some editor love in the console, but I believe :bsmth mentioned already wanting a custom editor there.
Either way is pretty easy client-side (if we don't care about migrating existing policies in the old shape). Let me know what direction you'd like to go.
Separately, do we actually want to drop the current restrictions on the rule name? That part still isn't clear to me.
| Reporter | ||
Updated•1 month ago
|
| Assignee | ||
Comment 12•1 month ago
|
||
The restrictions on the name look pretty arbitrary to me...
About the shape, using a keyed record with arbitrary keys (I think this would be "pattern properties" in the schema) isn't super well supported in the editor indeed. Given we want a dedicated editor anyway I think we can keep the current shape, adding a description to the field mentioning the uniqueness.
Comment 13•1 month ago
|
||
Maybe we can discuss it, but I have two thoughts on it:
- We have one precedent with extensions:
{
"policies": {
"ExtensionSettings": {
"uBlock0@raymondhill.net": {
"installation_mode": "force_installed"
}
}
}
}
Meaning, we can't or shouldn't have conflicts by extension ID. We should check that we handle this properly, I'm assuming we do. But the implication is that the editor needs to handle these kinds of cases, in general.
- I'm a little hesitant to add validation on the console editor that's not expressed in the schema - over time, we'll end up maintaining two different rule sets, and diverging behavior will bite us, most likely (if we can imagine a rule that works in the console, but not in
policies.jsonand vice versa).
The restrictions on the name look pretty arbitrary to me...
Yes, I think the idea was just to stick to (lowercase?) alphanumeric with hyphens, just to simplify and prevent edge cases with strange input. I can defer to eng judgement here for what is convenient / is a good format for error prevention.
| Assignee | ||
Comment 14•1 month ago
|
||
(In reply to Brian Thomas Smith [:bsmth] from comment #13)
Meaning, we can't or shouldn't have conflicts by extension ID. We should check that we handle this properly, I'm assuming we do. But the implication is that the editor needs to handle these kinds of cases, in general.
We filed bug 2077185 to handle these cases better, for now it's pretty bad...
Comment 15•1 month ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #14)
(In reply to Brian Thomas Smith [:bsmth] from comment #13)
Meaning, we can't or shouldn't have conflicts by extension ID. We should check that we handle this properly, I'm assuming we do. But the implication is that the editor needs to handle these kinds of cases, in general.
We filed bug 2077185 to handle these cases better, for now it's pretty bad...
TY! I'm also curious how handling is on the policy engine side; i.e., what happens in the following cases:
{
"policies": {
"ExtensionSettings": {
"uBlock0@raymondhill.net": {
"installation_mode": "force_installed"
},
"uBlock0@raymondhill.net": {
"installation_mode": "blocked"
}
}
}
}
| Assignee | ||
Comment 16•1 month ago
|
||
I'd say this is just JSON parsing: the second overrides the first. Though I'm not sure if the console does that before by saving this JSON or if we just pass it along to the browser as-is...
Comment 17•1 month ago
|
||
The standard says that the last one wins for duplicates: https://262.ecma-international.org/6.0/#sec-internalizejsonproperty
I am pretty sure we don't de-duplicate at any point currently.
Comment 18•1 month ago
|
||
I will try to validate what happens if we should get duplicates. But I don't think we should change this unless we have line of sight for a custom editor. Looking at the similar "Extension Settings" policy on the Staging console, the visual editor doesn't look like it has any way to add or edit settings other than for "*", and with DLP being a visible policy for FxE I wouldn't want to make it be the policy to force people into the json editor. How quickly would we be able to get a custom editor for DLP?
| Assignee | ||
Comment 19•1 month ago
|
||
Yeah, we want to implement bug 2077185 pretty soon, I'd say in a month.
Frankly I'm more on your side Jonathan, I think this can be documented (including in a description on the "name" property) and that should be good enough.
| Assignee | ||
Comment 20•1 month ago
|
||
Also I think we should make the string restriction less strict (if strict at all) but I could live if we keep the restriction. In the UI we should show what the restriction is in the description, we'll implement that anyway.
Comment 21•1 month ago
|
||
Well for what it's worth, I did verify that in the case of patternProperties properties like the existing ExtensionSettings, if Firefox receives duplicates the last one wins in our policy engine as documented in the standard (no error shows up in "about:policies", and it only shows the winning policy, as if the earlier duplicate didn't even exist).
I'm generally fine removing the string restriction on the Name property but I want to double-check that won't cause problems (off the top of my head I know we serialize to UTF-8 for the wasm, but I think as long as that works out there shouldn't be other issues).
If we want to just document that Names should be unique (rather than enforce via schema), that could be ok with some caveats:
- We currently use the rule name to identify which custom message to show (if provided) when an action is warned/blocked; if there are multiple rules by the same name we would end up picking one of them which could result in a wrong/out-of-context message.
- Note: We already have potential ambiguity in that multiple rules might both trigger a block for an action, so we pick just one of the rules to use for the message - in this case the message isn't wrong, but arguably "incomplete" in that the other rule's message doesn't get shown.
- We currently use the rule name as part of the security event that is reported. Currently this would not be technically "wrong" (we would report the correct name) but just ambiguous for the admin.
Description
•