mirror of
https://github.com/daijro/camoufox.git
synced 2026-11-19 00:07:28 +00:00
check_asset() already reads the asset's digest from the GitHub API and
stores it as installed_sha256, and AvailableVersion carries a sha256
field through to version.json. Nothing compared either against the
bytes that were downloaded: every sha256 equality check in the package
compares metadata to metadata when selecting an installed version, and
hashlib appeared only in utils.py to key a config cache.
So the archive that gets extracted over the install directory, and then
chmod 755'd and executed, was accepted on transport security alone. The
digest needed to catch a substituted or truncated asset was already in
hand and unused.
Add verify_sha256() and call it between download and extraction on both
install paths -- install_versioned() for the CLI and InstallWorker for
the GUI. It hashes in 1 MiB blocks so a multi-hundred-megabyte asset
does not have to be held in memory, and rewinds the buffer afterwards
so unzip() still reads from the start.
When no digest is published the install proceeds with a warning rather
than failing: some sources publish no digest, and refusing to install
from them would be a regression, not a fix.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 65cda21b4f)
211 lines
3.1 KiB
Python
211 lines
3.1 KiB
Python
class UnsupportedVersion(Exception):
|
|
"""
|
|
Raised when the Camoufox executable is outdated.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class MissingRelease(Exception):
|
|
"""
|
|
Raised when a required GitHub release asset is missing.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class CorruptedDownload(Exception):
|
|
"""
|
|
Raised when a downloaded asset does not match its expected sha256 digest.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class UnsupportedArchitecture(Exception):
|
|
"""
|
|
Raised when the architecture is not supported.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class UnsupportedOS(Exception):
|
|
"""
|
|
Raised when the OS is not supported.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class UnknownProperty(Exception):
|
|
"""
|
|
Raised when the property is unknown.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class InvalidPropertyType(Exception):
|
|
"""
|
|
Raised when the property type is invalid.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class InvalidAddonPath(FileNotFoundError):
|
|
"""
|
|
Raised when the addon path is invalid.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class InvalidDebugPort(ValueError):
|
|
"""
|
|
Raised when the debug port is invalid.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class MissingDebugPort(ValueError):
|
|
"""
|
|
Raised when the debug port is missing.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class LocaleError(Exception):
|
|
"""
|
|
Raised when the locale is invalid.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class InvalidIP(Exception):
|
|
"""
|
|
Raised when an IP address is invalid.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class InvalidProxy(Exception):
|
|
"""
|
|
Raised when a proxy is invalid.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class UnknownIPLocation(LocaleError):
|
|
"""
|
|
Raised when the location of an IP is unknown.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class InvalidLocale(LocaleError):
|
|
"""
|
|
Raised when the locale input is invalid.
|
|
"""
|
|
|
|
@classmethod
|
|
def invalid_input(cls, locale: str) -> 'InvalidLocale':
|
|
return cls(
|
|
f"Invalid locale: '{locale}'. Must be either a region, language, "
|
|
"language-region, or language-script-region."
|
|
)
|
|
|
|
|
|
class UnknownTerritory(InvalidLocale):
|
|
"""
|
|
Raised when the territory is unknown.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class UnknownLanguage(InvalidLocale):
|
|
"""
|
|
Raised when the language is unknown.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class NotInstalledGeoIPExtra(ImportError):
|
|
"""
|
|
Raised when the geoip2 module is not installed.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class NonFirefoxFingerprint(Exception):
|
|
"""
|
|
Raised when a passed Browserforge fingerprint is invalid.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class InvalidOS(ValueError):
|
|
"""
|
|
Raised when the target OS is invalid.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class VirtualDisplayError(Exception):
|
|
"""
|
|
Raised when there is an error with the virtual display.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class CannotFindXvfb(VirtualDisplayError):
|
|
"""
|
|
Raised when Xvfb cannot be found.
|
|
"""
|
|
|
|
...
|
|
pass
|
|
|
|
|
|
class CannotExecuteXvfb(VirtualDisplayError):
|
|
"""
|
|
Raised when Xvfb cannot be executed.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class VirtualDisplayNotSupported(VirtualDisplayError):
|
|
"""
|
|
Raised when the user tried to use a virtual display on a non-Linux OS.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class CamoufoxNotInstalled(FileNotFoundError):
|
|
"""
|
|
Raised when camoufox is not installed.
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
class ProfileDirectoryError(RuntimeError):
|
|
"""Raised when Camoufox's required runtime directory cannot be prepared."""
|
|
|
|
...
|