Download tasks/t23-dance-blob/environment/install-gui-only.py from refreshdotdev/Refresh-GUI-dataset: direct link, hf CLI and curl.
- Browser
- Download file 3.18 kB
-
https://huggingface.co/datasets/refreshdotdev/Refresh-GUI-dataset/resolve/main/tasks/t23-dance-blob/environment/install-gui-only.py
- Command line
-
hf download hf://datasets/refreshdotdev/Refresh-GUI-dataset/tasks/t23-dance-blob/environment/install-gui-only.py
-
curl -L -o install-gui-only.py https://huggingface.co/datasets/refreshdotdev/Refresh-GUI-dataset/resolve/main/tasks/t23-dance-blob/environment/install-gui-only.py
3.18 kB
| """Trusted environment setup. Run before exposing screenshots/actions to a model.""" | |
| import json | |
| import os | |
| from pathlib import Path | |
| import subprocess | |
| import xml.etree.ElementTree as ET | |
| BLOCKED = 'xterm uxterm lxterm koi8rxterm x-terminal-emulator xfce4-terminal gnome-terminal gnome-terminal-server konsole mate-terminal lxterminal qterminal terminator tilix sakura rxvt urxvt zutty xfce4-appfinder xfrun4 exo-desktop-item-edit xfce4-settings-editor xfce4-settings-manager thunar Thunar mousepad xfce4-keyboard-settings xfce4-mime-settings'.split() | |
| stub = Path('/usr/local/bin/gui-only-denied') | |
| stub.write_text('''#!/bin/sh | |
| mkdir -p /logs/artifacts | |
| printf '%s %s\\n' "$(date -u +%FT%TZ)" "$0" >> /logs/artifacts/gui-only-denied.log | |
| exit 126 | |
| ''') | |
| stub.chmod(0o755) | |
| for name in BLOCKED: | |
| for directory in ['/usr/bin','/usr/local/bin','/bin']: | |
| p = Path(directory)/name | |
| if directory == '/bin' and Path('/bin').resolve() == Path('/usr/bin'):continue | |
| if p.exists() or p.is_symlink():p.unlink() | |
| p.symlink_to(stub) | |
| # Remove shell launch surfaces without removing native editor file dialogs. | |
| for root in ['/root/Desktop','/usr/share/applications','/usr/local/share/applications','/root/.local/share/applications']: | |
| for p in Path(root).glob('*.desktop'): | |
| text=p.read_text(errors='replace').lower() | |
| if any(x in text for x in ['terminal','appfinder','xfrun','settings-editor','keyboard-settings','mime-settings','desktop-item-edit','text-editor','mousepad','chromium','web-browser']):p.unlink() | |
| # Only the harness launches the editor; disable duplicate session autostarts. | |
| for root in ['/root/.config/autostart','/etc/xdg/autostart']: | |
| for p in Path(root).glob('*.desktop'): | |
| if any(x in p.read_text(errors='replace').lower() for x in ['shotcut','filmcraft','x11vnc']): | |
| p.write_text('[Desktop Entry]\nType=Application\nHidden=true\n') | |
| for root in ['/etc/xdg/xfce4/xfconf/xfce-perchannel-xml','/root/.config/xfce4/xfconf/xfce-perchannel-xml']: | |
| p=Path(root)/'xfce4-keyboard-shortcuts.xml' | |
| if p.exists(): | |
| tree=ET.parse(p) | |
| for parent in tree.iter(): | |
| for child in list(parent): | |
| if any(x in child.get('value','').lower() for x in ['terminal','appfinder','xfrun']):parent.remove(child) | |
| tree.write(p,encoding='unicode') | |
| kiosk=Path('/etc/xdg/xfce4/kiosk/kioskrc');kiosk.parent.mkdir(parents=True,exist_ok=True) | |
| kiosk.write_text('[xfce4-panel]\nCustomizePanel=NONE\n[xfdesktop]\nCustomizeDesktopMenu=NONE\nCustomizeWindowlist=NONE\nUserMenu=NONE\n[xfce4-session]\nCustomizeCompatibility=NONE\nCustomizeSecurity=NONE\n') | |
| # Custom file-manager commands can launch shells. Keep file navigation/native dialogs. | |
| actions=Path('/root/.config/Thunar/uca.xml');actions.parent.mkdir(parents=True,exist_ok=True);actions.write_text('<actions/>\n') | |
| for name in BLOCKED: | |
| r=subprocess.run(['/usr/bin/'+name,'--version'],capture_output=True,timeout=5) | |
| if r.returncode !=126:raise RuntimeError('GUI-only guard failed: '+name) | |
| Path('/logs/artifacts').mkdir(parents=True,exist_ok=True) | |
| Path('/logs/artifacts/gui-only-policy.json').write_text(json.dumps({'version':1,'terminal_tools':False,'blocked_launchers':BLOCKED,'self_check':'passed'},indent=2)) | |
| print('GUI_ONLY_SELF_CHECK_PASSED') | |