Package and guard the audited menu rollout
Some checks failed
plugins.yml / Package and guard the audited menu rollout (push) Failing after 0s
Some checks failed
plugins.yml / Package and guard the audited menu rollout (push) Failing after 0s
This commit is contained in:
parent
6418e229fd
commit
be7fd5ca1a
7 changed files with 118 additions and 7 deletions
|
|
@ -59,8 +59,12 @@ jobs:
|
|||
# exact historical connector against the original unchanged contract.
|
||||
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git 5d727d7f59e6af26fba07a3878fd79035a5923ce
|
||||
git worktree add --detach "$pillager_input/navigator" FETCH_HEAD
|
||||
gradle --no-daemon -p "$pillager_input/navigator/JarvisConnector" jar
|
||||
python3 tools/plugin_navigator_transition.py --historical-jarvis "$pillager_input/navigator/JarvisConnector/build/libs/jarvistranslator.jar"
|
||||
for module in JarvisConnector DuneRealmsGUI DuneMenus; do
|
||||
gradle --no-daemon -p "$pillager_input/navigator/$module" jar
|
||||
done
|
||||
python3 tools/plugin_navigator_transition.py --historical-jarvis "$pillager_input/navigator/JarvisConnector/build/libs/jarvistranslator.jar" \
|
||||
--historical-gui "$pillager_input/navigator/DuneRealmsGUI/build/libs/DunerealmsGUI.jar" \
|
||||
--historical-menus "$pillager_input/navigator/DuneMenus/build/libs/DuneMenus.jar"
|
||||
python3 tools/test_plugin_pillager_art.py -v
|
||||
python3 tools/test_plugin_fleet_install.py -v
|
||||
python3 tools/test_plugin_menu_pack.py -v
|
||||
|
|
@ -82,3 +86,13 @@ jobs:
|
|||
name: DuneRealms-Plugins
|
||||
path: plugin-artifacts/
|
||||
if-no-files-found: error
|
||||
mkdir audited-menus-artifacts
|
||||
cp plugin-artifacts/{DuneMenus.jar,DunerealmsGUI.jar,SOURCE_COMMIT} audited-menus-artifacts/
|
||||
python3 tools/write-plugin-manifest.py audited-menus-artifacts "$GITHUB_SHA"
|
||||
cp tools/{install-plugin-fleet,plugin_audited_menus,plugin_menu_pack,plugin_backend_abi,plugin_fleet_rollback,plugin_pack_properties,plugin_pillager_abi}.py audited-menus-artifacts/
|
||||
(cd audited-menus-artifacts && sha256sum -- *.jar *.json *.py SOURCE_COMMIT > SHA256SUMS)
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DuneRealms-Audited-Menus
|
||||
path: audited-menus-artifacts/
|
||||
if-no-files-found: error
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import java.security.MessageDigest
|
||||
plugins { java }
|
||||
group = "com.dunerealms"
|
||||
version = "2.0.10-housecompact1"
|
||||
version = "2.0.11-menuaudit1"
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
plugins { java }
|
||||
group = "com.dunerealms"
|
||||
version = "1.1.41-house1"
|
||||
version = "1.1.42-menuaudit1"
|
||||
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/"); maven("https://repo.opencollab.dev/main/") }
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
name: DunerealmsGUI
|
||||
main: com.dunerealms.gui.DuneGUI
|
||||
version: 1.1.41-house1
|
||||
version: 1.1.42-menuaudit1
|
||||
api-version: '1.21.8'
|
||||
depend: [JarvisTranslator]
|
||||
softdepend: [Citizens, MCGUI, DecentHolograms, DuneLobby, DuneCore, DuneEss, DuneNPC, Vault, floodgate, ViaVersion]
|
||||
|
|
|
|||
|
|
@ -75,9 +75,10 @@ def verify_dunechest_fleet_target(sid, root, unit, incoming, installed):
|
|||
|
||||
def plan(artifacts, inventory, expected_source):
|
||||
mode=inventory.get('mode')
|
||||
if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife','navigator','planet-dunechest','fleet-dunechest','arrakis-raw-spice','arrakis-jerboa','compact-menus','lobby-food','lobby-account','arrakis-dunegroups','fleet-dunegroups','arrakis-dunechat','fleet-dunechat'}:
|
||||
if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife','navigator','planet-dunechest','fleet-dunechest','arrakis-raw-spice','arrakis-jerboa','compact-menus','audited-menus','lobby-food','lobby-account','arrakis-dunegroups','fleet-dunegroups','arrakis-dunechat','fleet-dunechat'}:
|
||||
raise ValueError('An explicit supported rollout mode is required')
|
||||
compact_menus=mode=='compact-menus'
|
||||
audited_menus=mode=='audited-menus'
|
||||
dunegroups=mode in {'arrakis-dunegroups','fleet-dunegroups'}
|
||||
dunechat=mode in {'arrakis-dunechat','fleet-dunechat'}
|
||||
lobby_food=mode=='lobby-food'
|
||||
|
|
@ -96,6 +97,10 @@ def plan(artifacts, inventory, expected_source):
|
|||
allowed_names = {'DuneEss', 'DuneRealms', 'DuneCore', 'DuneLobby', 'DuneNPC', 'DunerealmsGUI', 'DuneTerrain', 'JarvisTranslator', 'DuneMenus'}
|
||||
if dunechest:
|
||||
allowed_names={'DuneChest'}
|
||||
if audited_menus:
|
||||
allowed_names = {'DuneMenus', 'DunerealmsGUI'}
|
||||
if inventory.get('menuPack') is not None or inventory.get('privatePrerequisites'):
|
||||
raise ValueError('Audited menus must retain the current pack and runtime')
|
||||
if compact_menus:
|
||||
allowed_names={'DuneMenus'}
|
||||
if inventory.get('menuPack') is not None:
|
||||
|
|
@ -183,7 +188,7 @@ def plan(artifacts, inventory, expected_source):
|
|||
raise ValueError('Server private prerequisites must be explicitly provided and reviewed')
|
||||
chosen = [files[name] for name in selected] + [prerequisites[key] for key in selected_prerequisites]
|
||||
wanted = {entry['name'].casefold() for entry in chosen}
|
||||
uses_menu=not compact_menus and ('dunemenus' in wanted or bool(menu and menu.get('unified') and not (crysknife or dunechest or jerboa)))
|
||||
uses_menu=not (compact_menus or audited_menus) and ('dunemenus' in wanted or bool(menu and menu.get('unified') and not (crysknife or dunechest or jerboa)))
|
||||
if menu and menu.get('unified') and not (crysknife or dunechest or jerboa) and 'dunerealmsgui' not in wanted:
|
||||
raise ValueError('Unified pack rollout must select its matching DunerealmsGUI adapter')
|
||||
if not (pillager or crysknife or navigator or dunechest or raw_spice or jerboa or lobby_food or lobby_account or dunegroups or dunechat) and wanted - {'dunemenus','dunerealmsgui','dunenpc','dunelobby','mcgui'}:
|
||||
|
|
@ -193,6 +198,11 @@ def plan(artifacts, inventory, expected_source):
|
|||
if (sid not in DUNECHEST_PLANETS | {'lobby'} or root != expected_root or unit != f'dune-{sid}.service'
|
||||
or wanted != {'dunemenus'} or selected_prerequisites):
|
||||
raise ValueError('Compact menus may only replace DuneMenus on a reviewed server')
|
||||
if audited_menus:
|
||||
expected_root = Path('/opt/dunerealms/lobby') if sid == 'lobby' else Path('/opt/dunerealms/servers') / sid
|
||||
if (sid not in DUNECHEST_PLANETS | {'lobby'} or root != expected_root or unit != f'dune-{sid}.service'
|
||||
or wanted != {'dunemenus', 'dunerealmsgui'} or selected_prerequisites):
|
||||
raise ValueError('Audited menus must replace exactly the two presentation plugins')
|
||||
if jerboa and (sid != 'arrakis' or root != ARRAKIS_ROOT or unit != 'dune-arrakis.service'
|
||||
or wanted != {'duneterrain'} or selected_prerequisites):
|
||||
raise ValueError('Jerboa rollout may only replace Terrain on Arrakis')
|
||||
|
|
@ -371,6 +381,18 @@ def plan(artifacts, inventory, expected_source):
|
|||
replaced={entry['filename'] for entry in previous}
|
||||
retained=[{'filename':path.name,'sha256':digest(path),'metadata':metadata(path)}
|
||||
for path in sorted(plugins.glob('*.jar')) if path.name not in replaced]
|
||||
if audited_menus:
|
||||
from plugin_audited_menus import MCGUI_SHA, verify_transition
|
||||
if not {'dunerealmsgui', 'dunemenus', 'jarvistranslator', 'mcgui'}.issubset(existing_paths):
|
||||
raise ValueError('Audited menus require the reviewed presentation runtimes')
|
||||
if digest(existing_paths['mcgui']) != MCGUI_SHA:
|
||||
raise ValueError('Unexpected MCGUI renderer')
|
||||
for entry in chosen:
|
||||
identity_name = entry['name'].casefold()
|
||||
verify_transition(sid, identity_name, existing_paths[identity_name], entry['source'])
|
||||
replaced = {entry['filename'] for entry in previous}
|
||||
retained = [{'filename': path.name, 'sha256': digest(path), 'metadata': metadata(path)}
|
||||
for path in sorted(plugins.glob('*.jar')) if path.name not in replaced]
|
||||
if compact_menus:
|
||||
from plugin_compact_menus import BASELINE_SHA256, verify_jar
|
||||
installed = existing_paths.get('dunemenus')
|
||||
|
|
|
|||
69
tools/plugin_audited_menus.py
Normal file
69
tools/plugin_audited_menus.py
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
"""Check the menu release against each retained Lobby or planet archive."""
|
||||
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
import re
|
||||
import zipfile
|
||||
|
||||
|
||||
MCGUI_SHA = '69a454291cc27c36cdbc680bfbde245a90a3913de53cc1591c502a5a49124300'
|
||||
BASELINES = {
|
||||
'lobby': {
|
||||
'dunerealmsgui': '73061d45ba727aa9fd7aac462a62a8efb0681b2d6baa1662db514730abb83163',
|
||||
'dunemenus': '0e06d86fda465cf0a65469632da90f26bfca9b0c4899a4bdbdb4199d6a3eed04',
|
||||
},
|
||||
'planet': {
|
||||
'dunerealmsgui': '54735136fb8e15852a69271cfa5b436af4116914876bc539fe9994140854378a',
|
||||
'dunemenus': '4585825d0ac6cc70b0c95988cf4e8eb0f378e473d33a10b0a98c4b75fee51a8d',
|
||||
},
|
||||
}
|
||||
GUI = 'com/dunerealms/gui/'
|
||||
MENUS = 'com/dunerealms/menus/'
|
||||
QUEST_COMMAND = (b' quest:\n description: Claim all ready in-game quest rewards\n'
|
||||
b' usage: /quest redeem\n')
|
||||
CHANGES = {
|
||||
'dunerealmsgui': {GUI + name + '.class' for name in (
|
||||
'DuneGUI', 'DuneGUI$1', 'ExchangeMenus', 'OrganisationMenus',
|
||||
'OrganisationMenus$1', 'SuppliedMenus', 'QuestMenus'
|
||||
)},
|
||||
'dunemenus': {MENUS + name + '.class' for name in (
|
||||
'DuneMenusPlugin', 'HubMenu', 'NativeServiceMenu', 'SuppliedDocument'
|
||||
)},
|
||||
}
|
||||
VERSIONS = {'dunerealmsgui': b'1.1.42-menuaudit1', 'dunemenus': b'2.0.11-menuaudit1'}
|
||||
REMOVED = MENUS + 'LoreArchiveMenu.class'
|
||||
ADDED = GUI + 'QuestMenus$ClaimBatch.class'
|
||||
|
||||
|
||||
def archive(path):
|
||||
with zipfile.ZipFile(path) as jar:
|
||||
names = [name for name in jar.namelist() if not name.endswith('/')]
|
||||
if len(set(names)) != len(names):
|
||||
raise ValueError('Duplicate menu archive entry')
|
||||
return {name: jar.read(name) for name in names}
|
||||
|
||||
|
||||
def verify_transition(server, name, installed, candidate):
|
||||
prior = hashlib.sha256(Path(installed).read_bytes()).hexdigest()
|
||||
if prior != BASELINES['lobby' if server == 'lobby' else 'planet'][name]:
|
||||
raise ValueError('Unexpected installed menu archive: ' + name)
|
||||
old, new = archive(installed), archive(candidate)
|
||||
added, removed = (set(new) - set(old), set(old) - set(new))
|
||||
expected = ({ADDED}, set()) if name == 'dunerealmsgui' else (set(), {REMOVED})
|
||||
if (added, removed) != expected:
|
||||
raise ValueError('Unexpected menu archive entry set: ' + name)
|
||||
for entry in (old.keys() & new.keys()) - CHANGES[name]:
|
||||
actual = new[entry]
|
||||
if entry == 'plugin.yml' and name == 'dunerealmsgui':
|
||||
if actual.count(QUEST_COMMAND) != 1:
|
||||
raise ValueError('Missing reviewed quest command')
|
||||
actual = actual.replace(QUEST_COMMAND, b'', 1)
|
||||
prior_entry = old[entry]
|
||||
if entry == 'plugin.yml':
|
||||
version = re.search(br'^version: ([^\r\n]+)$', actual, re.M)
|
||||
if version is None or version[1] != VERSIONS[name]:
|
||||
raise ValueError('Unexpected audited menu version: ' + name)
|
||||
prior_entry = re.sub(br'^version: [^\r\n]+$', b'version: <reviewed>', prior_entry, flags=re.M)
|
||||
actual = re.sub(br'^version: [^\r\n]+$', b'version: <reviewed>', actual, flags=re.M)
|
||||
if prior_entry != actual:
|
||||
raise ValueError('Unexpected retained menu entry: ' + entry)
|
||||
|
|
@ -103,6 +103,8 @@ def main():
|
|||
parser.add_argument('--abi', type=Path, default=Path('JarvisConnector/src/test/resources/retained-jarvis-public-abi.json'))
|
||||
parser.add_argument('--stage-pillager-baseline', type=Path)
|
||||
parser.add_argument('--historical-jarvis', type=Path)
|
||||
parser.add_argument('--historical-gui', type=Path)
|
||||
parser.add_argument('--historical-menus', type=Path)
|
||||
args = parser.parse_args()
|
||||
fixture = json.loads(args.contract.read_text())
|
||||
if args.stage_pillager_baseline is not None:
|
||||
|
|
@ -111,6 +113,10 @@ def main():
|
|||
for name, path in JARS.items():
|
||||
if name == 'JarvisTranslator' and args.historical_jarvis is not None:
|
||||
path = args.historical_jarvis
|
||||
elif name == 'DunerealmsGUI' and args.historical_gui is not None:
|
||||
path = args.historical_gui
|
||||
elif name == 'DuneMenus' and args.historical_menus is not None:
|
||||
path = args.historical_menus
|
||||
guard = fixture['modules'][name]
|
||||
report = verify_jarvis(path, guard, json.loads(args.abi.read_text())) if name == 'JarvisTranslator' else verify_module(path, guard)
|
||||
print(name, json.dumps(report, sort_keys=True))
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff