TUF 最小浏览器兼容性
最小类型脚本执行 最新框架(TUF) 规格,优化为浏览器兼容性.
这是一个轻量级的替代方案 tu 侧重于浏览器环境中安全软件更新所需的TUF核心功能.
[叹息]
该图书馆没有收到独立的安全审计。 维护工作由志愿者进行,该项目没有得到新闻自由基金会的正式支持或认可.
特征
- TUF 核心安全: 实施必要的TUF安全保障,包括回滚保护、密钥旋转和连贯的快照
- 浏览器- 第一: 为网络浏览器设计,支持本地Storage、Chrome扩展存储和文件系统后端
- 最小依赖性: 最大兼容性的0个外部依赖性
- 相相竞: 通过对辅助特性的 TUF 兼容性测试
- ECDSA & Ed25519 支助: 使用Web Crypto API进行ECDSA-P256和Ed25519签名
没有原生 Ed25519 的浏览器需要应用程序调用
installEd25519Fallback()从@freedomofpress/crypto-browser/noble一次开始.
限制
此最小执行故意省略某些 TUF 特性以优化大小和浏览器相容性 :
- 无代表团支持
- 没有RSA密钥支持(只有ECDSA和Ed25519)
- 没有镜像列表
- 没有自定义下载限制
使用量
import { TUFClient } from 'tuf-browser';
// Initialize client with repository URL and root metadata
const client = new TUFClient(
'https://repository.example.com/metadata/',
rootMetadata,
'my-app'
);
// Fetch and verify a target file
const targetData = await client.getTarget('path/to/target.json');
存储后端
库根据运行时环境自动选择合适的存储后端 :
| 环境 | 使用的后端 | 页:1 |
|---|---|---|
| 节点.js(CLI/测试) | FSBackend | 将元数据和目标写入磁盘 。 要求遵守图瓦卢福林协定. |
| 浏览器扩展 | ExtensionStorageBackend | 使用 browser.storage.local API (Firefox/Chrome扩展存储). |
| 浏览器网页 | LocalStorageBackend | 用途 localStorage最小持续存储. |
发展
# Install dependencies
npm install
# Build the project
npm run build
实例: CLI 使用
下载 1.root.json (英语) 或更新的 并触发新鲜.
$ node ./dist/cli.js \
--metadata-dir /tmp/ \
--metadata-url https://tuf-repo-cdn.sigstore.dev \
refresh 1.root.json
示例输出 :
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/2.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/3.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/4.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/5.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/6.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/7.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/8.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/9.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/10.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/11.root.json
KeyId 7247f0dbad85b147e1863bade761243cc785dcb7aa410e7105dd3d2b61a36d2c does not match the expected 0c87432c3bf09fd99189fdc32fa5eaedf4e4a5fac7bab73fa04a2e0fc64af6f5, importing anyway the provided one for proper referencing.
KeyId 7247f0dbad85b147e1863bade761243cc785dcb7aa410e7105dd3d2b61a36d2c does not match the expected 0c87432c3bf09fd99189fdc32fa5eaedf4e4a5fac7bab73fa04a2e0fc64af6f5, importing anyway the provided one for proper referencing.
KeyId 7247f0dbad85b147e1863bade761243cc785dcb7aa410e7105dd3d2b61a36d2c does not match the expected 0c87432c3bf09fd99189fdc32fa5eaedf4e4a5fac7bab73fa04a2e0fc64af6f5, importing anyway the provided one for proper referencing.
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/12.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/13.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/14.root.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/timestamp.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/162.snapshot.json
[TUF] Fetching https://tuf-repo-cdn.sigstore.dev/13.targets.json
CLI 行为遵循 TUF 客户端的规格 遵守规定 套间.
说明:CLI是符合性测试的最低限度参考执行. 它执行核心 init, (中文(简体) ), refresh,以及 download 命令但缺少一些命令(例如, metadata某些符合性测试要求。 用于生产、进口和使用 TUFClient 阶级直接而不是依赖CLI.
运行 TUF 合规测试套件
需要Python 3.11和虚拟env.
git clone https://github.com/theupdateframework/tuf-conformance
cd tuf-conformance
make env/pyvenv.cfg
./env/bin/pytest -v tuf_conformance \
--entrypoint "/usr/bin/node /tuf-browser/dist/cli.js" \
--repository-dump-dir /tmp/
遵约
在108项TUF合规性测试中,这项实施工作通过了75项。 其余的测试涵盖有意不支持的特性(代表团,RSA密钥).
已知问题和待办事宜
采用了TUF的核心功能(元数据核查、签名核对、回滚保护、用SHA-256/SHA-512支持的散列核查)。 其余合格测试失败:
-
根元数据字节保存 (单位:千美元)
test_metadata_bytes_match(中文(简体) )Root 元数据在写入时重新序列化(页:1 用途
setInCache→backend.write),而其他角色则正确使用writeRaw用于保存字节. -
快速恢复 (3次测试
test_rollback.py(中文(简体) )部分执行: 缓存元数据在键旋转时被清除( Q)图:245 - 267) (中文(简体) ). 该代码严格拒绝版本降级,而不是尝试恢复.
-
其他测试失败 (~10个剩余测试)
各种失败与文件下载,静态寄存器,和边缘大小写有关.
许可证
麻省理工学院执照 - 看 自由主义 详细文件。 本套件的几分部分包含代码来自 缩写 并获得Apache许可证2.0许可。 这些章节在相应的源文件头中被清楚地标明.