Closed Bug 1433271 Opened 2 years ago Closed 2 years ago

Both "allow" and "block" fields are required to set a "block" policy

Categories

(Firefox :: Enterprise Policies, defect)

60 Branch
defect
Not set

Tracking

()

VERIFIED FIXED
Firefox 60
Tracking Status
firefox60 --- fixed

People

(Reporter: Abe_LV, Assigned: Felipe)

Details

Attachments

(1 file)

1. Set your policy as:
{
  "policies": {
    "install_addons": {  
      "block": [            
           "https://duckduckgo.com",      
      ]
    }
  }
}
 
2. Open browser console and check for warnings

Actual Result:
Throws warnings-
PoliciesValidator.jsm:Array expected but not received  PoliciesValidator.jsm:56
Enterprise Policies:Invalid parameters specified for install_addons.  EnterprisePolicies.js:120

Expected Result:
Users should not include an empty array for "allow" if they only want to set a block policy.

For the above policy to work, it should be re-written as:

{
  "policies": {
    "install_addons": {
      "allow": [      
     
      ],
      "block": [            
           "https://duckduckgo.com",
      
      ]
    }
  }
}
Flags: needinfo?(felipc)
Assignee: nobody → felipc
Status: NEW → ASSIGNED
Flags: needinfo?(felipc)
Note: I started implementing the "required" part of the JSON-Schema spec to fix this bug, but it was getting more complicated than initially thought, so I decided not to do it here and just go for the simple fix, since this problem is getting in the way of the GPO work.
Comment on attachment 8948866 [details]
Bug 1433271 - Don't fail policy validation if an array inside a object is missing.

https://reviewboard.mozilla.org/r/218260/#review224050


Code analysis found 1 defect in this patch:
 - 1 defect found by mozlint

You can run this analysis locally with:
 - `./mach lint path/to/file` (JS/Python)


If you see a problem in this automated review, please report it here: http://bit.ly/2y9N9Vx


::: browser/components/enterprisepolicies/tests/browser/browser_policies_validate_and_parse_API.js:259
(Diff revision 1)
> +    allow: [true, true, true]
> +  }, schema);
> +
> +  ok(valid, "Object is valid");
> +  is(parsed.allow.length, 3, "Allow array is correct.");
> +  is(parsed.block, undefined, "Block array is undefined, as expected.")

Error: Missing semicolon. [eslint: semi]
(In reply to Code Review Bot [:reviewbot] from comment #4)
> Error: Missing semicolon. [eslint: semi]

I fixed this in the updated review request (comment 3)
Comment on attachment 8948866 [details]
Bug 1433271 - Don't fail policy validation if an array inside a object is missing.

https://reviewboard.mozilla.org/r/218260/#review224346
Attachment #8948866 - Flags: review?(dtownsend) → review+
Pushed by felipc@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/8130dd208393
Don't fail policy validation if an array inside a object is missing. r=Mossop
https://hg.mozilla.org/mozilla-central/rev/8130dd208393
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
We tested this fix on Windows-10x64, Windows-7x86, Ubuntu 16.04 and OSX 10.13. We verified this as fixed.
Test cases and runs are here-https://testrail.stage.mozaws.net/index.php?/plans/view/7734
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.