Skip to content

Commit 4e1da4f

Browse files
authored
Emit an error when data_collection_permissions is specified in the manifest (#5632)
1 parent 4de8dc9 commit 4e1da4f

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

docs/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,11 @@ <h2 id="web-extensions-%2F-manifest.json" tabindex="-1">Web Extensions / manifes
598598
<td>error</td>
599599
<td>The <code>browser_specific_settings.gecko.admin_install_only</code> property must be set to &quot;true&quot; in an enterprise add-on</td>
600600
</tr>
601+
<tr>
602+
<td><code>DATA_COLLECTION_PERMISSIONS_PROP_RESERVED</code></td>
603+
<td>error</td>
604+
<td>The <code>data_collection_permissions</code> property is reserved for future usage and cannot be used in an extension at the moment</td>
605+
</tr>
601606
</tbody>
602607
</table>
603608
<h3 id="static-theme-%2F-manifest.json" tabindex="-1">Static Theme / manifest.json <a class="header-anchor" href="#static-theme-%2F-manifest.json"></a></h3>

docs/rules.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Rules are sorted by severity.
137137
| `INCOGNITO_SPLIT_UNSUPPORTED` | warning | The incognito "split" value is unsupported in Firefox |
138138
| `ADMIN_INSTALL_ONLY_PROP_RESERVED` | error | The `browser_specific_settings.gecko.admin_install_only` property is reserved and can only be used in enterprise add-ons |
139139
| `ADMIN_INSTALL_ONLY_REQUIRED` | error | The `browser_specific_settings.gecko.admin_install_only` property must be set to "true" in an enterprise add-on |
140+
| `DATA_COLLECTION_PERMISSIONS_PROP_RESERVED` | error | The `data_collection_permissions` property is reserved for future usage and cannot be used in an extension at the moment |
140141

141142
### Static Theme / manifest.json
142143

src/messages/manifestjson.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,3 +836,11 @@ export const ADMIN_INSTALL_ONLY_REQUIRED = {
836836
in an enterprise add-on.`),
837837
file: MANIFEST_JSON,
838838
};
839+
840+
export const DATA_COLLECTION_PERMISSIONS_PROP_RESERVED = {
841+
code: 'DATA_COLLECTION_PERMISSIONS_PROP_RESERVED',
842+
message: i18n._('The "data_collection_permissions" property is reserved.'),
843+
description: i18n._(`The "data_collection_permissions" property is reserved
844+
for future usage and cannot be used in an extension at the moment.`),
845+
file: MANIFEST_JSON,
846+
};

src/parsers/manifestjson.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,16 @@ export default class ManifestJSONParser extends JSONParser {
538538
this.isValid = false;
539539
}
540540

541+
if (
542+
this.parsedJSON.browser_specific_settings?.gecko
543+
?.data_collection_permissions
544+
) {
545+
this.collector.addError(
546+
messages.DATA_COLLECTION_PERMISSIONS_PROP_RESERVED
547+
);
548+
this.isValid = false;
549+
}
550+
541551
if (this.parsedJSON.content_security_policy != null) {
542552
this.validateCspPolicy(this.parsedJSON.content_security_policy);
543553
}

tests/unit/parsers/test.manifestjson.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5762,4 +5762,29 @@ describe('ManifestJSONParser', () => {
57625762
}
57635763
);
57645764
});
5765+
5766+
describe('data_collection_permissions', () => {
5767+
it('emits an error when data_collection_permissions is specified', () => {
5768+
const linter = new Linter({ _: ['bar'] });
5769+
5770+
const manifestJSONParser = new ManifestJSONParser(
5771+
JSON.stringify({
5772+
manifest_version: 2,
5773+
name: 'some name',
5774+
version: '1',
5775+
browser_specific_settings: {
5776+
gecko: { data_collection_permissions: {} },
5777+
},
5778+
}),
5779+
linter.collector
5780+
);
5781+
5782+
expect(manifestJSONParser.isValid).toEqual(false);
5783+
expect(linter.collector.errors).toEqual([
5784+
expect.objectContaining(
5785+
messages.DATA_COLLECTION_PERMISSIONS_PROP_RESERVED
5786+
),
5787+
]);
5788+
});
5789+
});
57655790
});

0 commit comments

Comments
 (0)