mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-29 09:35:38 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d584d2cadc | ||
|
|
486b1d3758 | ||
|
|
72a7c18797 |
No files matched your search
@@ -73,6 +73,8 @@ jobs:
|
||||
set -euo pipefail
|
||||
git fetch --no-tags origin main
|
||||
echo "base-sha=$(git rev-parse origin/main)" >> "$GITHUB_OUTPUT"
|
||||
- name: Verify checked-in binary provenance
|
||||
run: python3 tools/provenance/check.py
|
||||
- name: Record pinned source tree
|
||||
id: source
|
||||
run: echo "tree-sha=$(git rev-parse 'HEAD^{tree}')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
# Tracked binary provenance
|
||||
|
||||
This is an **exception inventory**, not evidence that every distributed binary is
|
||||
built from source. `prebuilt.json` hashes opaque, checked-in payloads and records
|
||||
their known upstream *project*, not a verified corresponding source revision.
|
||||
|
||||
Run `python3 tools/provenance/check.py` locally. CI runs the same gate after
|
||||
merging a PR onto `main`, before the component builds. Adding or modifying any
|
||||
tracked native executable, shared library, compressed runtime archive, model,
|
||||
or other detected binary requires an explicit allowlist change reviewed in the
|
||||
same PR. Changed paths, hashes, or unexpectedly removed files fail the job.
|
||||
|
||||
## Outstanding source-build work
|
||||
|
||||
1. **Wayland server**: two identical checked-in copies of
|
||||
`libwayland-server.so`; `waylandcomp/CMakeLists.txt` imports one prebuilt
|
||||
directly. Pin the matching Wayland source and Android-specific patch/toolchain
|
||||
inputs, build the library in CI, and stage a single resulting ELF to JNI.
|
||||
Check required symbols, SONAME, Android ABI, and compositor boot before
|
||||
removing the checked-in copies.
|
||||
2. **PulseAudio / libffi / libltdl / libsndfile**: the audio recipe downloads
|
||||
PulseAudio 13.0 *sources* to build extra sink modules, but the base
|
||||
`pulseaudio.tzst` and JNI libraries are already compiled. Add explicit
|
||||
source builds for the base runtime/dependencies and verify ABI + plugin
|
||||
linkage. Avoid changing the working audio bundle until an Android smoke
|
||||
test exercises playback and suspend/resume.
|
||||
3. **Innoextract / Boost**: the runtime asset task stages a checked-in AArch64
|
||||
executable and five Boost shared libraries. Build innoextract from a pinned
|
||||
upstream revision and cross-build matching dependencies, or remove the
|
||||
prebuilt tool if another source-built extraction path covers its use cases.
|
||||
4. **Turnip archives**: verify their exact Mesa commits, build toolchains and
|
||||
redistribution notices. Migrate to pinned, checked source builds or
|
||||
independently verified upstream artifacts with documented provenance.
|
||||
|
||||
The `source_revision` value `unverified` explicitly means we have **not**
|
||||
established which upstream source produced the checked-in bytes. A project
|
||||
homepage and SHA-256 hash do not establish reproducibility, correspondence
|
||||
to source, license compliance, or supply-chain safety. They make unresolved
|
||||
items visible and prevent silent binary additions.
|
||||
|
||||
This gate intentionally inventories build tooling and opaque data separately
|
||||
from executable runtime code. It does not scan binaries downloaded dynamically
|
||||
or produced during CI: those are governed by the existing component recipes,
|
||||
hash pins, artifact handoff, and release checks. The build's verified preload
|
||||
snapshots are likewise covered by `tools/components/preloads.py`, not by
|
||||
this tracked-file exception list.
|
||||
|
||||
To remove an exception, migrate the build to source and delete its tracked
|
||||
artifact and manifest entry in the same PR. To update one, show the exact
|
||||
upstream revision, source URL, license/notice, patch set, build command,
|
||||
toolchain and validation evidence in the PR; don't just refresh the hash.
|
||||
@@ -0,0 +1,178 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fail closed on unreviewed, checked-in binary components.
|
||||
|
||||
This is a tracked-binary inventory and checksum gate, NOT a source-build,
|
||||
reproducibility, or licensing attestation.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
MANIFEST = "tools/provenance/prebuilt.json"
|
||||
BINARY_SUFFIXES = {
|
||||
".so", ".a", ".o", ".dll", ".exe", ".jar", ".aar", ".apk",
|
||||
".tzst", ".zst", ".task", ".wasm", ".bin", ".zip", ".7z",
|
||||
}
|
||||
MAGICS = (
|
||||
b"\x7fELF", b"MZ", b"\x00asm", # ELF, PE, WebAssembly
|
||||
b"\xcf\xfa\xed\xfe", b"\xfe\xed\xfa\xcf", # Mach-O
|
||||
b"\xca\xfe\xba\xbe", b"\x28\xb5\x2f\xfd", # universal, zstd
|
||||
b"PK\x03\x04", b"\x1f\x8b", b"\xfd7zXZ", b"7z\xbc\xaf\x27\x1c", # compressed archives
|
||||
)
|
||||
SHA256_RE = re.compile(r"^[a-f0-9]{64}$")
|
||||
VALID_STATES = {"prebuilt-exception", "binary-data", "build-tool"}
|
||||
|
||||
|
||||
def tracked_paths(root: Path) -> list[str]:
|
||||
data = subprocess.check_output(
|
||||
["git", "ls-files", "--cached", "--stage", "-z"], cwd=root
|
||||
)
|
||||
paths = []
|
||||
for item in data.split(b"\0"):
|
||||
if not item:
|
||||
continue
|
||||
meta, path = item.split(b"\t", 1)
|
||||
# Gitlinks contain an object ID, not a file blob. They are checked
|
||||
# separately by the pinned submodule source/build process.
|
||||
if meta.split()[0] == b"160000":
|
||||
continue
|
||||
paths.append((os.fsdecode(path), meta.split()[0]))
|
||||
return sorted(paths)
|
||||
|
||||
|
||||
def is_binary_payload(relpath: str, prefix: bytes) -> bool:
|
||||
name = Path(relpath).name.lower()
|
||||
return (
|
||||
name.endswith(tuple(BINARY_SUFFIXES))
|
||||
or ".so." in name
|
||||
or any(prefix.startswith(magic) for magic in MAGICS)
|
||||
)
|
||||
|
||||
|
||||
def hash_content(rel: str, handle) -> str | None:
|
||||
prefix = handle.read(8)
|
||||
if not is_binary_payload(rel, prefix):
|
||||
return None
|
||||
digest = hashlib.sha256()
|
||||
digest.update(prefix)
|
||||
for chunk in iter(lambda: handle.read(1024 * 1024), b""):
|
||||
digest.update(chunk)
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def discover(root: Path) -> dict[str, str]:
|
||||
"""Hash tracked binary payloads, including paths omitted by sparse checkout.
|
||||
|
||||
Git's index still holds blob IDs for sparse entries, so read those entries
|
||||
from Git rather than silently skipping them. A missing blob fails the gate.
|
||||
"""
|
||||
result: dict[str, str] = {}
|
||||
for rel, mode in tracked_paths(root):
|
||||
file = root / rel
|
||||
# A Git symlink blob stores the link target string, not target bytes.
|
||||
# Always hash that blob to match sparse and full checkouts.
|
||||
if mode != b"120000" and file.is_file():
|
||||
with file.open("rb") as handle:
|
||||
digest = hash_content(rel, handle)
|
||||
else:
|
||||
# The source CI checkout deliberately omits docs/releases/media.
|
||||
# Read the index version so an ELF added there cannot evade the gate.
|
||||
with subprocess.Popen(
|
||||
["git", "show", f":{rel}"], cwd=root,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
) as proc:
|
||||
assert proc.stdout is not None
|
||||
digest = hash_content(rel, proc.stdout)
|
||||
# Drain even non-binary files before checking the exit status.
|
||||
for _ in iter(lambda: proc.stdout.read(1024 * 1024), b""):
|
||||
pass
|
||||
error = proc.stderr.read() if proc.stderr else b""
|
||||
if proc.wait() != 0:
|
||||
raise RuntimeError(
|
||||
f"cannot read tracked Git blob for {rel}: {error.decode(errors='replace')}"
|
||||
)
|
||||
if digest is not None:
|
||||
result[rel] = digest
|
||||
return result
|
||||
|
||||
|
||||
def validate(root: Path, manifest: Path) -> list[str]:
|
||||
try:
|
||||
data = json.loads(manifest.read_text(encoding="utf-8"))
|
||||
if not isinstance(data, dict) or data.get("schema") != 1:
|
||||
return ["manifest must be a schema: 1 object"]
|
||||
records = data["artifacts"]
|
||||
if not isinstance(records, list):
|
||||
return ["artifacts must be a list"]
|
||||
except (OSError, ValueError, KeyError) as exc:
|
||||
return [f"invalid manifest: {exc}"]
|
||||
|
||||
errors: list[str] = []
|
||||
expected: dict[str, str] = {}
|
||||
for index, item in enumerate(records):
|
||||
if not isinstance(item, dict):
|
||||
errors.append(f"artifacts[{index}] must be an object")
|
||||
continue
|
||||
rel = item.get("path")
|
||||
if not isinstance(rel, str) or not rel or rel.startswith("/") or ".." in Path(rel).parts:
|
||||
errors.append(f"artifacts[{index}]: invalid repository-relative path")
|
||||
continue
|
||||
if rel in expected:
|
||||
errors.append(f"duplicate manifest entry: {rel}")
|
||||
digest = item.get("sha256")
|
||||
if not isinstance(digest, str) or not SHA256_RE.fullmatch(digest):
|
||||
errors.append(f"{rel}: invalid sha256")
|
||||
else:
|
||||
expected[rel] = digest
|
||||
if item.get("status") not in VALID_STATES:
|
||||
errors.append(f"{rel}: status must be one of {sorted(VALID_STATES)}")
|
||||
if not isinstance(item.get("origin"), str) or not item["origin"].strip():
|
||||
errors.append(f"{rel}: origin must describe the source project")
|
||||
if not isinstance(item.get("source_revision"), str) or not item["source_revision"].strip():
|
||||
errors.append(f"{rel}: source_revision required (use 'unverified' if unknown)")
|
||||
if not isinstance(item.get("note"), str) or len(item["note"].strip()) < 12:
|
||||
errors.append(f"{rel}: note must explain this exception")
|
||||
|
||||
found = discover(root)
|
||||
for rel in sorted(set(found) - set(expected)):
|
||||
errors.append(f"UNREVIEWED binary: {rel} (sha256 {found[rel]})")
|
||||
for rel in sorted(set(expected) - set(found)):
|
||||
errors.append(f"manifest lists missing/untracked binary: {rel}")
|
||||
for rel in sorted(set(found) & set(expected)):
|
||||
if found[rel] != expected[rel]:
|
||||
errors.append(f"CHANGED binary: {rel} (expected {expected[rel]}, got {found[rel]})")
|
||||
return errors
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--root", type=Path, default=REPO)
|
||||
parser.add_argument("--manifest", type=Path, default=None)
|
||||
parser.add_argument("--list", action="store_true", help="print discovered paths and hashes")
|
||||
args = parser.parse_args()
|
||||
root = args.root.resolve()
|
||||
if args.list:
|
||||
for rel, digest in discover(root).items():
|
||||
print(f"{digest} {rel}")
|
||||
return 0
|
||||
manifest = args.manifest or root / MANIFEST
|
||||
errors = validate(root, manifest)
|
||||
for error in errors:
|
||||
print(f"::error::{error}", file=sys.stderr)
|
||||
if errors:
|
||||
print(f"Prebuilt inventory failed: {len(errors)} problem(s)", file=sys.stderr)
|
||||
return 1
|
||||
print(f"Prebuilt inventory verified: {len(discover(root))} tracked binary payloads")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,206 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"description": "Checksums for tracked opaque binaries; an explicit exception list, not a source-build or license certification.",
|
||||
"artifacts": [
|
||||
{
|
||||
"path": "app/src/main/assets/desktop-removal/emulators-keep.txt.gzip",
|
||||
"sha256": "8ee6bb678884767ee597e829e1df6dda70c55a23e727c301d14e817ab9b18344",
|
||||
"status": "binary-data",
|
||||
"origin": "DroidDeck generated desktop-removal inventories",
|
||||
"source_revision": "repository asset",
|
||||
"note": "Gzip-compressed text inventory; not executable. Review the generator and inputs when regenerating."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/assets/desktop-removal/kde-keep.txt.gzip",
|
||||
"sha256": "103fcc4c5238190b71af8064838cf2710d76fa0f35c85bb1d05d082237084e21",
|
||||
"status": "binary-data",
|
||||
"origin": "DroidDeck generated desktop-removal inventories",
|
||||
"source_revision": "repository asset",
|
||||
"note": "Gzip-compressed text inventory; not executable. Review the generator and inputs when regenerating."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/assets/desktop-removal/kde-remove.tsv.gzip",
|
||||
"sha256": "a6f9bb05ba52402e85ebadabfb632f65b359f7cd9721d65e8560a35a1415eac3",
|
||||
"status": "binary-data",
|
||||
"origin": "DroidDeck generated desktop-removal inventories",
|
||||
"source_revision": "repository asset",
|
||||
"note": "Gzip-compressed text inventory; not executable. Review the generator and inputs when regenerating."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/assets/desktop-removal/lxqt-r1.tsv.gzip",
|
||||
"sha256": "c2cc0c0bf2e58cb8134ca933a65baa5dd450e01d68eb06a9d5b388cb4a9dd140",
|
||||
"status": "binary-data",
|
||||
"origin": "DroidDeck generated desktop-removal inventories",
|
||||
"source_revision": "repository asset",
|
||||
"note": "Gzip-compressed text inventory; not executable. Review the generator and inputs when regenerating."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/assets/graphics_driver/adrenotools-turnip-sdk36.tzst",
|
||||
"sha256": "da8a3e83ea61f11b8ccee274524de3c0ad8a45f3be8921e23e1f162d26279b93",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://gitlab.freedesktop.org/mesa/mesa",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in Turnip driver archive; per-archive source revision and build recipe need verification."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/assets/graphics_driver/adrenotools-turnip25.1.0.tzst",
|
||||
"sha256": "b3824227a3bcac367352bae86a34ed95add9b99fae50c16b7c7f48506d7ce197",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://gitlab.freedesktop.org/mesa/mesa",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in Turnip driver archive; per-archive source revision and build recipe need verification."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/assets/pulseaudio.tzst",
|
||||
"sha256": "4ec3ce78220007ccb36108fabeb395671fd25bfe1069fb05a719fef7d067c859",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/pulseaudio/pulseaudio",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in PulseAudio runtime archive; the CI audio recipe adds source-built sinks but reuses this base."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/cpp/waylandcomp/prebuilt/lib/libwayland-server.so",
|
||||
"sha256": "2daff7500b6acee55291567d786653ba75f5aecf5a5e648fce4c10fe6bc7a8ea",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://gitlab.freedesktop.org/wayland/wayland",
|
||||
"source_revision": "unverified",
|
||||
"note": "Wayland server prebuilt imported into Android CMake; exact source revision and build recipe unverified."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/jniLibs/arm64-v8a/libffi.so",
|
||||
"sha256": "8855ba6dc12e9abf40729481a7a99aa391ac7b2e77bad4fbe0bb51cd66216c0e",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/libffi/libffi",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in native dependency; source-build wiring is missing from Android CI."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/jniLibs/arm64-v8a/libltdl.so",
|
||||
"sha256": "14d616028b38a4b778576477c675c1ce34618582b84ccc5c3fd2492e6518196f",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://www.gnu.org/software/libtool/",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in libltdl; exact source revision and Android build command unverified."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/jniLibs/arm64-v8a/libpulse.so",
|
||||
"sha256": "8ce9c5ba9710aee64c70356b051a8df4f88396075b0264048b992ab7c337f2e6",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/pulseaudio/pulseaudio",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in PulseAudio ARM64 library; source-build wiring is missing from Android CI."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/jniLibs/arm64-v8a/libpulseaudio.so",
|
||||
"sha256": "a9256b038381b192593c019ba779e219419f71b2a66aa1c1e29a756314489ed7",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/pulseaudio/pulseaudio",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in PulseAudio ARM64 library; source-build wiring is missing from Android CI."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/jniLibs/arm64-v8a/libpulsecommon-13.0.so",
|
||||
"sha256": "3ef683f23660898933a66fb032976e06905cbca8e01027aa1ce9891e1d854c2b",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/pulseaudio/pulseaudio",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in PulseAudio ARM64 library; source-build wiring is missing from Android CI."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/jniLibs/arm64-v8a/libpulsecore-13.0.so",
|
||||
"sha256": "1305d78969858a7a60e030a75c383901148b980518fc2d337b9c028c968c3f95",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/pulseaudio/pulseaudio",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in PulseAudio ARM64 library; source-build wiring is missing from Android CI."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/jniLibs/arm64-v8a/libsndfile.so",
|
||||
"sha256": "ab999a10cd3f6979580447169a19c1c9c121e0d8340b2bc810c54dc916bb3ee0",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/libsndfile/libsndfile",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in libsndfile; exact source revision and Android build command unverified."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/jniLibs/arm64-v8a/libwayland-server.so",
|
||||
"sha256": "2daff7500b6acee55291567d786653ba75f5aecf5a5e648fce4c10fe6bc7a8ea",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://gitlab.freedesktop.org/wayland/wayland",
|
||||
"source_revision": "unverified",
|
||||
"note": "Wayland server prebuilt imported into Android CMake; exact source revision and build recipe unverified."
|
||||
},
|
||||
{
|
||||
"path": "app/src/main/resources/rockstar/legacy-cipher.bin",
|
||||
"sha256": "43a5bf698bd546954b3bc6eee65a6aa63cb4bc0c98677344843602b9ea93a2ae",
|
||||
"status": "binary-data",
|
||||
"origin": "DroidDeck repository",
|
||||
"source_revision": "unverified",
|
||||
"note": "Opaque cipher resource data; not a native library or executable."
|
||||
},
|
||||
{
|
||||
"path": "gradle/wrapper/gradle-wrapper.jar",
|
||||
"sha256": "e996d452d2645e70c01c11143ca2d3742734a28da2bf61f25c82bdc288c9e637",
|
||||
"status": "build-tool",
|
||||
"origin": "https://github.com/gradle/gradle",
|
||||
"source_revision": "unverified",
|
||||
"note": "Gradle bootstrap tool; not packaged as DroidDeck runtime code."
|
||||
},
|
||||
{
|
||||
"path": "tools/linuxfs/innoextract/linuxfs/usr/local/lib/droiddeck-inno/innoextract",
|
||||
"sha256": "67bda7fc5fd54d20488f8d7ad349655b65eb911e068e3fd7e348e13e2aec1a40",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/dscharrer/innoextract",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in ARM64 innoextract executable, directly staged into the APK's runtime assets."
|
||||
},
|
||||
{
|
||||
"path": "tools/linuxfs/innoextract/linuxfs/usr/local/lib/droiddeck-inno/libboost_container.so.1.92.0",
|
||||
"sha256": "ed95491c8f1718354bfdb23b8c6fd52ebcf8f72b85ed26429f856376527e34d9",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/boostorg/boost",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in Boost 1.92 runtime dependency of innoextract; not rebuilt by CI."
|
||||
},
|
||||
{
|
||||
"path": "tools/linuxfs/innoextract/linuxfs/usr/local/lib/droiddeck-inno/libboost_filesystem.so.1.92.0",
|
||||
"sha256": "eafdc0eb4f5470ad19f9bc09a0a2def56615dadc0684c6e173cfe82a0b510a5f",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/boostorg/boost",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in Boost 1.92 runtime dependency of innoextract; not rebuilt by CI."
|
||||
},
|
||||
{
|
||||
"path": "tools/linuxfs/innoextract/linuxfs/usr/local/lib/droiddeck-inno/libboost_iostreams.so.1.92.0",
|
||||
"sha256": "fa222fc97b48fe5360da9cdd3fb11b78a41083161da8b7052a5f88d3bb2a1804",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/boostorg/boost",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in Boost 1.92 runtime dependency of innoextract; not rebuilt by CI."
|
||||
},
|
||||
{
|
||||
"path": "tools/linuxfs/innoextract/linuxfs/usr/local/lib/droiddeck-inno/libboost_program_options.so.1.92.0",
|
||||
"sha256": "ded51b938d6ec5b979633b8d9f771478c2ea6390eee81cb7131b54cb969415a0",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/boostorg/boost",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in Boost 1.92 runtime dependency of innoextract; not rebuilt by CI."
|
||||
},
|
||||
{
|
||||
"path": "tools/linuxfs/innoextract/linuxfs/usr/local/lib/droiddeck-inno/libboost_random.so.1.92.0",
|
||||
"sha256": "c6db8078fa8d6bb287e4f987afef642290e7b69d22c59dea883c444edff80500",
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://github.com/boostorg/boost",
|
||||
"source_revision": "unverified",
|
||||
"note": "Checked-in Boost 1.92 runtime dependency of innoextract; not rebuilt by CI."
|
||||
},
|
||||
{
|
||||
"path": "tools/packs/tracking/hand_landmarker_lite.task",
|
||||
"sha256": "173c0f47ecee7e935bd4a1e93aa580756b4180c1307c07d709313e82c28672c8",
|
||||
"status": "binary-data",
|
||||
"origin": "https://ai.google.dev/edge/mediapipe",
|
||||
"source_revision": "unverified",
|
||||
"note": "Model data; see tools/packs/tracking provenance, not an executable."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
"""Regression tests for the checked-in binary allowlist and hash gate."""
|
||||
import importlib.util
|
||||
import json
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
SOURCE = Path(__file__).resolve().parents[1] / "provenance" / "check.py"
|
||||
spec = importlib.util.spec_from_file_location("prebuilt_check", SOURCE)
|
||||
check = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(check)
|
||||
|
||||
|
||||
class PrebuiltInventoryTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.root = Path(self.tmp.name)
|
||||
subprocess.run(["git", "init", "-q"], cwd=self.root, check=True)
|
||||
(self.root / "note.txt").write_text("not binary", encoding="utf-8")
|
||||
self.binary = self.root / "vendor.so"
|
||||
self.binary.write_bytes(b"\x7fELF\x00example")
|
||||
subprocess.run(["git", "add", "."], cwd=self.root, check=True)
|
||||
sha = check.discover(self.root)["vendor.so"]
|
||||
self.record = {
|
||||
"path": "vendor.so",
|
||||
"sha256": sha,
|
||||
"status": "prebuilt-exception",
|
||||
"origin": "https://example.org/source",
|
||||
"source_revision": "unverified",
|
||||
"note": "An existing vendor binary awaiting source build.",
|
||||
}
|
||||
self.manifest = self.root / "prebuilt.json"
|
||||
self.write_manifest([self.record])
|
||||
|
||||
def write_manifest(self, entries):
|
||||
self.manifest.write_text(
|
||||
json.dumps({"schema": 1, "artifacts": entries}), encoding="utf-8"
|
||||
)
|
||||
|
||||
def test_known_binary_passes(self):
|
||||
self.assertEqual(check.validate(self.root, self.manifest), [])
|
||||
|
||||
def test_added_binary_is_rejected(self):
|
||||
(self.root / "new.exe").write_bytes(b"MZadditional")
|
||||
subprocess.run(["git", "add", "new.exe"], cwd=self.root, check=True)
|
||||
self.assertTrue(any("UNREVIEWED binary" in x for x in check.validate(self.root, self.manifest)))
|
||||
|
||||
def test_changed_hash_is_rejected(self):
|
||||
self.binary.write_bytes(b"\x7fELF\x00tampered")
|
||||
self.assertTrue(any("CHANGED binary" in x for x in check.validate(self.root, self.manifest)))
|
||||
|
||||
def test_disguised_extensionless_elf_is_detected(self):
|
||||
(self.root / "ordinary").write_bytes(b"\x7fELF\x00hidden")
|
||||
subprocess.run(["git", "add", "ordinary"], cwd=self.root, check=True)
|
||||
self.assertTrue(any("ordinary" in x for x in check.validate(self.root, self.manifest)))
|
||||
|
||||
def test_compressed_archive_is_detected(self):
|
||||
(self.root / "payload.dat").write_bytes(b"\x1f\x8b\x08\x00compressed")
|
||||
subprocess.run(["git", "add", "payload.dat"], cwd=self.root, check=True)
|
||||
self.assertTrue(any("payload.dat" in x for x in check.validate(self.root, self.manifest)))
|
||||
|
||||
def test_untracked_file_is_ignored(self):
|
||||
(self.root / "untracked.so").write_bytes(b"\x7fELF\x00local")
|
||||
self.assertEqual(check.validate(self.root, self.manifest), [])
|
||||
|
||||
def test_sparse_missing_binary_is_checked_from_git(self):
|
||||
self.binary.unlink()
|
||||
self.assertEqual(check.validate(self.root, self.manifest), [])
|
||||
|
||||
def test_sparse_unlisted_binary_is_rejected(self):
|
||||
hidden = self.root / "docs" / "releases" / "media" / "payload.exe"
|
||||
hidden.parent.mkdir(parents=True)
|
||||
hidden.write_bytes(b"MZhidden")
|
||||
subprocess.run(["git", "add", "docs/releases/media/payload.exe"], cwd=self.root, check=True)
|
||||
hidden.unlink() # Mimics a sparse-checkout file missing on disk.
|
||||
self.assertTrue(any("UNREVIEWED binary" in x for x in check.validate(self.root, self.manifest)))
|
||||
|
||||
def test_symlink_hash_is_identical_in_full_and_sparse_checkout(self):
|
||||
alias = self.root / "alias.so"
|
||||
alias.symlink_to("vendor.so")
|
||||
subprocess.run(["git", "add", "alias.so"], cwd=self.root, check=True)
|
||||
full = check.discover(self.root)
|
||||
self.assertEqual(full["alias.so"], __import__("hashlib").sha256(b"vendor.so").hexdigest())
|
||||
alias.unlink()
|
||||
sparse = check.discover(self.root)
|
||||
self.assertEqual(full, sparse)
|
||||
|
||||
def test_unlisted_symlink_is_rejected(self):
|
||||
alias = self.root / "alias.so"
|
||||
alias.symlink_to("vendor.so")
|
||||
subprocess.run(["git", "add", "alias.so"], cwd=self.root, check=True)
|
||||
self.assertTrue(any("UNREVIEWED binary: alias.so" in x for x in check.validate(self.root, self.manifest)))
|
||||
|
||||
def test_removed_index_entry_is_rejected(self):
|
||||
subprocess.run(["git", "rm", "--cached", "vendor.so"], cwd=self.root, check=True, stdout=subprocess.DEVNULL)
|
||||
self.assertTrue(any("missing/untracked" in x for x in check.validate(self.root, self.manifest)))
|
||||
|
||||
def test_duplicate_manifest_entry_is_rejected(self):
|
||||
self.write_manifest([self.record, self.record])
|
||||
self.assertTrue(any("duplicate manifest" in x for x in check.validate(self.root, self.manifest)))
|
||||
|
||||
def test_missing_provenance_is_rejected(self):
|
||||
self.write_manifest([{**self.record, "source_revision": ""}])
|
||||
self.assertTrue(any("source_revision required" in x for x in check.validate(self.root, self.manifest)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user