q1sh101/adamas

GitHub: q1sh101/adamas

针对 Flatpak 应用的默认拒绝沙盒加固工具,通过最小权限配置和 portal 权限重置来收紧应用的实际访问边界。

Stars: 0 | Forks: 0

# adamas ![Linux](https://img.shields.io/badge/Linux-FFA500?logo=linux&logoColor=black&labelColor=FFA500) ![Flatpak](https://img.shields.io/badge/Flatpak-4A90D9?logo=flatpak&logoColor=white) ![Shell](https://img.shields.io/badge/Shell-2ea44f?logo=gnu-bash&logoColor=white) 针对 Flatpak 应用的默认拒绝沙盒机制。 清单会索取所有权限。配置决定它实际获得什么。 ## 快速入门 ``` git clone https://github.com/q1sh101/adamas && cd adamas # 复制 template,设置 APP_ID,命名 app 所需的内容 cp apps/example.conf apps/myapp.conf bash adamas.sh install myapp # install from Flathub bash adamas.sh harden myapp # route launches through adamas bash adamas.sh run myapp # launch in the stateless sandbox bash adamas.sh verify myapp # audit the route ``` ## 它的功能 - 使用 `--sandbox` 将 Flatpak 应用的权限彻底清零,然后仅恢复配置中指定的权限。 - 使用 `env -i` 对环境进行净化:只保留基准变量和 `ALLOW_ENV`,其余一律清除。 - 在每次启动时重置 portal 权限存储,并默认拒绝 8 个敏感的 portal。 - 通过修补 `.desktop` 文件或安装 launcher hook 来将启动路由到 adamas,并在该路由发生变化时报告偏移。 - 除非 `PERSIST` 指定了路径,否则将应用状态保留在 RAM 中。 ## 命令 ``` bash adamas.sh run [args...] launch with stateless sandbox bash adamas.sh install install from Flathub bash adamas.sh harden patch .desktop route or install hook bash adamas.sh verify audit route / hook integrity bash adamas.sh auto scan installed apps, generate missing configs, harden bash adamas.sh watch install|remove|status manage systemd automation bash adamas.sh trace [--runtime] [--save] observe app needs, generate draft config bash adamas.sh list show available configs ``` ## 文件 ``` apps/example.conf template - copy and edit APP_ID apps/.conf per-app allow-list apps/webapps/.conf optional grouping, one level deep lib/ command implementations ``` 关键配置字段: ``` APP_ID reverse-DNS Flatpak id (required) ALLOW_SHARE / SOCKET / DEVICE / FEATURE sandbox surface ALLOW_FILESYSTEM paths the app may see ALLOW_DBUS_TALK / ALLOW_DBUS_OWN session bus names NEED_PORTAL run the session bus proxy ALLOW_PORTAL / DENY_PORTAL portal permission store entries SHARE_PORTAL share one ceiling across an app id ALLOW_DBUS_CALL method-level filtering (patched flatpak) PERSIST paths that survive exit SET_ENV / ALLOW_ENV environment HOOK_NAME + HOOK_DIR route through an external launcher AUTO_SKIP leave this app's launch route alone ``` ## portal 最小权限 Flatpak 根据 application id 而非 sandbox 来管理 portal 权限,因此一个配置文件 所授予的权限等同于所有配置文件都拥有该权限,而“仅为此 webapp 开启摄像头”则 无处安放。adamas 正是围绕这一空白设计的:它宁可拒绝访问,也绝不扩大共享的 授权。我曾提议引入 `--dbus-call` ([flatpak#6526](https://github.com/flatpak/flatpak/pull/6526))将决定权移入 sandbox 中;上游更倾向于基于 portal 的 entitlement 模型 ([xdg-desktop-portal#1924](https://github.com/flatpak/xdg-desktop-portal/pull/1924), 未关闭),因此它作为一个 [fork](https://github.com/q1sh101/flatpak) 保留在分支 `add-dbus-call-option` 上。当安装了该 fork 时,`apps/` 中注释掉的代码块会将相同的配置切换为基于 sandbox 的默认拒绝(default-deny)。 ## 参考 - [ARCHITECTURE.md](docs/ARCHITECTURE.md) - 完整的系统架构图。 - [MIT License](LICENSE)
标签:Cutter, Flatpak, Shell, Streamlit, 子域名枚举, 权限最小化, 沙箱, 系统安全, 访问控制