mirror of
https://github.com/saphid/frame-control.git
synced 2026-10-26 23:01:47 +01:00
29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
"""Digest-scoped observations, never a trust or execution guarantee."""
|
|
import json
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
|
|
DATA = Path(__file__).with_name('framey-compatibility.json')
|
|
|
|
|
|
@lru_cache(maxsize=2)
|
|
def _records(path):
|
|
return json.loads(path.read_text())['plugins']
|
|
|
|
|
|
def lookup(plugin_id, digest, version):
|
|
unknown = {'status': 'unverified', 'reason': 'This exact store version has not been audited on Frame.',
|
|
'verification': [], 'blockInstall': False}
|
|
if type(plugin_id) is not int or not isinstance(digest, str) or not isinstance(version, str):
|
|
return unknown
|
|
try:
|
|
records = _records(DATA)
|
|
matches = [p for p in records if p['id'] == plugin_id and p['sha256'] == digest and p['version'] == version]
|
|
if len(matches) != 1:
|
|
return unknown
|
|
record = matches[0]
|
|
return {key: record[key] for key in ('status', 'reason', 'verification', 'blockInstall')}
|
|
except (OSError, ValueError, KeyError, TypeError):
|
|
return unknown
|