mirror of
https://github.com/aphrody-labs/cef.git
synced 2026-10-13 21:07:07 +00:00
Introduce a hash of Chromium sandbox interface files to detect incompatibilities between bootstrap.exe and libcef.dll at runtime, allowing the strict version check to be skipped when interfaces match. Core implementation: - Add sandbox_compat_hash.py to calculate SHA-256 of interface files (chrome_elf_main.h, sandbox.h, sandbox_types.h, sandbox.mojom) - Update make_version_header.py to generate CEF_SANDBOX_COMPAT_HASH - Add sandbox_compat_hash field to cef_version_info_t struct - Add entry 3 to cef_api_hash() for retrieving the hash - Compare hashes in cef_scoped_library_loader_win.cc during load Version management: - Include sandbox_compat in cef_api_versions.json and cef_api_untracked.json - Compare sandbox_compat for untracked versions (NEXT, EXPERIMENTAL) - Trigger version bumps when sandbox interface files change Build automation: - Update cefbuilds JSON builder to include sandbox_compat in version records - Run version_manager.py -a after Chromium updates on release branches to auto-detect hash changes and add new API versions
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
# Copyright (c) 2026 The Chromium Embedded Framework Authors. All rights
|
|
# reserved. Use of this source code is governed by a BSD-style license that
|
|
# can be found in the LICENSE file.
|
|
|
|
from __future__ import absolute_import
|
|
import hashlib
|
|
import os
|
|
import sys
|
|
|
|
|
|
def calculate_sandbox_compat_hash(file_paths, verbose=False):
|
|
"""
|
|
Calculate a compatibility hash from the contents of the given files.
|
|
Returns a truncated SHA-256 hash (first 16 hex characters).
|
|
All files must exist or an error is raised.
|
|
"""
|
|
hasher = hashlib.sha256()
|
|
|
|
for file_path in sorted(file_paths): # Sort for deterministic order
|
|
if not os.path.exists(file_path):
|
|
raise FileNotFoundError(f"Required file not found: {file_path}")
|
|
|
|
with open(file_path, 'r', encoding='utf-8', errors='replace') as f:
|
|
content = f.read()
|
|
# Normalize line endings for cross-platform consistency
|
|
content = content.replace('\r\n', '\n')
|
|
hasher.update(content.encode('utf-8'))
|
|
if verbose:
|
|
print(f"Hashed: {file_path} ({len(content)} bytes)")
|
|
|
|
return hasher.hexdigest()[:16]
|
|
|
|
|
|
def main(argv):
|
|
if len(argv) < 2:
|
|
print(f"Usage: {argv[0]} <file1> [file2] ...")
|
|
sys.exit(1)
|
|
|
|
hash_value = calculate_sandbox_compat_hash(argv[1:], verbose=True)
|
|
print(f"Sandbox compatibility hash: {hash_value}")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv)
|