Release Vulpes OS Preview 26 with Gecko 161.0 and Tundra 0.2.0
This commit is contained in:
parent
3a1fba4efe
commit
e241a42d2f
1 changed files with 1305 additions and 331 deletions
|
|
@ -1,6 +1,7 @@
|
|||
"""Private ordinary-web-app store. No Gaia permissions are read from packages."""
|
||||
import base64
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
|
@ -19,9 +20,15 @@ class InstalledApps:
|
|||
token.chmod(0o600)
|
||||
self.items = {}
|
||||
for path in self.root.glob('user-*.json'):
|
||||
item = json.loads(path.read_text())
|
||||
if self.valid_id(item.get('id')):
|
||||
self.items[item['id']] = item
|
||||
try:
|
||||
item = json.loads(path.read_text())
|
||||
self.validate(item)
|
||||
if item['id'] != path.stem:
|
||||
raise ValueError('Package filename does not match its ID')
|
||||
except (ValueError, OSError) as error:
|
||||
logging.warning('Skipping unreadable installed app %s: %s', path.name, error)
|
||||
continue
|
||||
self.items[item['id']] = item
|
||||
|
||||
@staticmethod
|
||||
def valid_id(value):
|
||||
|
|
@ -37,13 +44,18 @@ class InstalledApps:
|
|||
return dict(id=item['id'], origin=origin, manifestURL=origin+'/manifest.webapp',
|
||||
manifest=manifest, removable=True, installed=True)
|
||||
|
||||
def save(self, item):
|
||||
if not self.valid_id(item.get('id')) or not isinstance(item.get('files'), dict):
|
||||
def validate(self, item):
|
||||
if (not isinstance(item, dict) or not self.valid_id(item.get('id'))
|
||||
or not isinstance(item.get('manifest'), dict) or not isinstance(item.get('files'), dict)):
|
||||
raise ValueError('INVALID_PACKAGE')
|
||||
# A second boundary check keeps the storage API independent of ZIP parsing.
|
||||
for name, content in item['files'].items():
|
||||
if not isinstance(name, str) or not isinstance(content, str):
|
||||
raise ValueError('INVALID_PACKAGE')
|
||||
base64.b64decode(content, validate=True)
|
||||
|
||||
def save(self, item):
|
||||
self.validate(item)
|
||||
with self.lock:
|
||||
target = self.root / (item['id']+'.json')
|
||||
stage = target.with_suffix('.tmp')
|
||||
|
|
|
|||
Loading…
Reference in a new issue