Closed Bug 2044429 Opened 5 months ago Closed 5 months ago

Switch enterprise policies to the vendored cfworker schema in the tree

Categories

(Firefox :: Enterprise Policies, task)

task

Tracking

()

RESOLVED FIXED
154 Branch
Tracking Status
firefox-esr153 --- fixed
firefox154 --- fixed

People

(Reporter: mkaply, Assigned: mkaply)

References

Details

Attachments

(8 external files, 4 obsolete files)

We currently uses a custom schema validator which makes things a little painful when using our schema in other places.

Want to switch to a standard schema (already in the tree).

Thin enterprise-local wrapper around the compliant validator in
JsonSchema.sys.mjs (vendored @cfworker/json-schema). It delegates
structural validation to that validator and reproduces the
policy-specific coercion the legacy JsonSchemaValidator provided:
0/1 to boolean, JSON-string parsing, URL/origin objects, and lenient
origin arrays. No consumers yet.

Rewrites the custom schema types (URL, URLorEmpty, origin, JSON) in
policies-schema.json to standard JSON Schema plus annotation keywords
the validator ignores (x-moz-format, contentMediaType,
x-moz-drop-invalid-items), and switches EnterprisePoliciesParent to
PolicySchemaValidator.

Behavior is preserved, including several quirks of the legacy validator:
boolean fields that are also numeric keep their 0/1 integer value;
URL/origin failures log the same messages; DisplayBookmarksToolbar and
DisplayMenuBar accept a boolean or an enumerated string (now via anyOf,
since the legacy validator skipped enum checks for booleans); and
SecurityDevices keeps accepting both its flat name-to-path form and the
Add/Delete form (its catch-all patternProperties now excludes Add and
Delete so they do not collide under the compliant validator's combined
properties + patternProperties semantics).

The documentation tab dumps the policy schema verbatim. Convert it
back to its pre-migration presentation (URL/URLorEmpty/origin/JSON,
strict, and boolean-or-enum types) so the internal x-moz-* and
contentMediaType keywords introduced by the migration do not leak
into the admin-facing view.

macOS delivers booleans as 0/1 integers (NSNumber) and nests via
unflattened keys; no existing policy-engine test exercises those value
shapes against the validator. This validates representative macOS-shaped
values (integer booleans, nested objects, origin arrays) against the real
schema, guarding the coercion the macOS path depends on. It is
platform-independent (the macOS-only parser/reader are covered by
test_macosparser_unflatten.js and by manual config-profile testing).

Thin enterprise-local wrapper around the compliant validator in
JsonSchema.sys.mjs (vendored @cfworker/json-schema). It delegates
structural validation to that validator and reproduces the
policy-specific coercion the legacy JsonSchemaValidator provided:
0/1 to boolean, JSON-string parsing, URL/origin objects, and lenient
origin arrays. No consumers yet.

Rewrites the custom schema types (URL, URLorEmpty, origin, JSON) in
policies-schema.json to standard JSON Schema plus annotation keywords
the validator ignores (x-moz-format, contentMediaType,
x-moz-drop-invalid-items), and switches EnterprisePoliciesParent to
PolicySchemaValidator.

Behavior is preserved, including several quirks of the legacy validator:
boolean fields that are also numeric keep their 0/1 integer value;
URL/origin failures log the same messages; DisplayBookmarksToolbar and
DisplayMenuBar accept a boolean or an enumerated string (now via anyOf,
since the legacy validator skipped enum checks for booleans); and
SecurityDevices keeps accepting both its flat name-to-path form and the
Add/Delete form (its catch-all patternProperties now excludes Add and
Delete so they do not collide under the compliant validator's combined
properties + patternProperties semantics).

The documentation tab dumps the policy schema verbatim. Convert it
back to its pre-migration presentation (URL/URLorEmpty/origin/JSON,
strict, and boolean-or-enum types) so the internal x-moz-* and
contentMediaType keywords introduced by the migration do not leak
into the admin-facing view.

macOS delivers booleans as 0/1 integers (NSNumber) and nests via
unflattened keys; no existing policy-engine test exercises those value
shapes against the validator. This validates representative macOS-shaped
values (integer booleans, nested objects, origin arrays) against the real
schema, guarding the coercion the macOS path depends on. It is
platform-independent (the macOS-only parser/reader are covered by
test_macosparser_unflatten.js and by manual config-profile testing).

Attachment #9592690 - Attachment is obsolete: true
Attachment #9592689 - Attachment is obsolete: true
Attachment #9592688 - Attachment is obsolete: true
Attachment #9592687 - Attachment is obsolete: true
Assignee: nobody → mozilla
Attachment #9592696 - Attachment description: WIP: Bug 2044429 - Add PolicySchemaValidator helper for enterprise policies (WIP) → Bug 2044429 - Add PolicySchemaValidator helper for enterprise policies r?apieper
Status: NEW → ASSIGNED
Attachment #9592697 - Attachment description: WIP: Bug 2044429 - Migrate enterprise policy validation to the compliant JSON Schema validator (WIP) → Bug 2044429 - Migrate enterprise policy validation to the compliant JSON Schema validator r?apieper
Attachment #9592698 - Attachment description: WIP: Bug 2044429 - Hide internal schema keywords from about:policies documentation (WIP) → Bug 2044429 - Hide internal schema keywords from about:policies documentation r?apieper
Attachment #9592699 - Attachment description: WIP: Bug 2044429 - Add macOS value-shape validation test for enterprise policies (WIP) → Bug 2044429 - Add macOS value-shape validation test for enterprise policies r?apieper
Attachment #9592698 - Attachment description: Bug 2044429 - Hide internal schema keywords from about:policies documentation r?apieper → Bug 2044429 - Hide verbose schema keywords from about:policies documentation r?apieper
Pushed by mozilla@kaply.com: https://github.com/mozilla-firefox/firefox/commit/47f3b29b927d https://hg.mozilla.org/integration/autoland/rev/dc4ee0738da7 Add PolicySchemaValidator helper for enterprise policies r=apieper,bsmth https://github.com/mozilla-firefox/firefox/commit/c88756952dcb https://hg.mozilla.org/integration/autoland/rev/9c5e0cfe8eb6 Migrate enterprise policy validation to the compliant JSON Schema validator r=apieper,bsmth https://github.com/mozilla-firefox/firefox/commit/25b006cd49cf https://hg.mozilla.org/integration/autoland/rev/e058295ac228 Hide verbose schema keywords from about:policies documentation r=apieper,bsmth https://github.com/mozilla-firefox/firefox/commit/3637c6d3acc5 https://hg.mozilla.org/integration/autoland/rev/14f5d279154f Add macOS value-shape validation test for enterprise policies r=apieper,bsmth
See Also: → 2050747
Regressions: 2051089
Regressions: 2052532
Regressions: 2054043
QA Whiteboard: [qa-triage-done-c155/b154]

PolicySchemaValidator wraps the compliant validator in JsonSchema.sys.mjs
and turns raw policy input into validated, ready-to-use data in three
stages: normalize source quirks into standard JSON (0/1 to boolean, and
JSON-string to object for fields marked contentMediaType application/json),
validate against standard JSON Schema, then hydrate format:uri strings into
URL objects. Each list entry is validated on its own, so an invalid entry
is dropped and logged rather than discarding the whole list. No consumers
yet.

Original Revision: https://phabricator.services.mozilla.com/D304186

Attachment #9620578 - Flags: approval-mozilla-esr153?

Rewrites the custom schema types (URL, URLorEmpty, origin, JSON) in
policies-schema.json to standard JSON Schema and switches
EnterprisePoliciesParent to PolicySchemaValidator. Validity now lives
entirely in the schema (format:uri, pattern, anyOf), so the same file can
be validated by off-the-shelf tooling; contentMediaType marks the fields
that may arrive as a JSON string. Shared types (url, urlOrEmpty, origin)
are defined once under "definitions" and referenced with $ref, resolved
when the schema is loaded for the per-policy validator. The $schema is
bumped to draft-07 to match the keywords used.

Behavior is preserved: boolean fields that are also numeric keep their 0/1
integer value; DisplayBookmarksToolbar and DisplayMenuBar accept a boolean
or an enumerated string (via anyOf); SecurityDevices and ExtensionSettings
exclude their literal special keys from the catch-all patternProperties so
those keys are not validated against two schemas at once; and an invalid
entry in a list is dropped rather than discarding the whole policy. Also
fixes a misplaced "required" in AutoLaunchProtocolsFromOrigins.

Original Revision: https://phabricator.services.mozilla.com/D304187

Attachment #9620579 - Flags: approval-mozilla-esr153?

about:policies prints the policy schema to administrators. The schema is
standard JSON Schema, but a few constructs (format and pattern for URLs and
origins, contentMediaType for JSON-string fields) are verbose, so the
documentation view rewrites them into the shorter presentation used
historically (URL, origin, JSON). This is a display-only transform.

Original Revision: https://phabricator.services.mozilla.com/D304188

Attachment #9620580 - Flags: approval-mozilla-esr153?

firefox-esr153 Uplift Approval Request

  • User impact if declined/Reason for urgency: Not having this in 153 means we'll have to do extra work for all other uplifts to 153 because of internal schema differences.

This is an enterprise policy change is thoroughly tested (although there is a followon for better errors)

  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Policy only.
  • String changes made/needed?: None
  • Is Android affected?: no
Attachment #9620581 - Flags: approval-mozilla-esr153?

macOS delivers booleans as 0/1 integers (NSNumber) and nests via
unflattened keys; no existing policy-engine test exercises those value
shapes against the validator. This validates representative macOS-shaped
values (integer booleans, nested objects, origin arrays) against the real
schema, guarding the coercion the macOS path depends on. It is
platform-independent (the macOS-only parser/reader are covered by
test_macosparser_unflatten.js and by manual config-profile testing).

Original Revision: https://phabricator.services.mozilla.com/D304189

Flags: in-testsuite+
Attachment #9620578 - Flags: approval-mozilla-esr153? → approval-mozilla-esr153+
Attachment #9620579 - Flags: approval-mozilla-esr153? → approval-mozilla-esr153+
Attachment #9620580 - Flags: approval-mozilla-esr153? → approval-mozilla-esr153+
Attachment #9620581 - Flags: approval-mozilla-esr153? → approval-mozilla-esr153+
Regressions: 2065965
Regressions: 2067819
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: