INNER CODE UNIT · Python

gitoid_sha1

wolfSSL/wolfssl · scripts/bomsh_verify.py:50

def gitoid_sha1(path):
    """OmniBOR `gitoid:blob:sha1:<hex>` is the canonical Git blob hash:
    sha1(b"blob <len>\\0" + content).  Symlinks are followed transparently
    by `open()`, which matches what bomsh records (the trace sees the
    target, not the symlink)."""
    with open(path, 'rb') as f:
        data = f.read()
    h = hashlib.sha1()
    h.update(f'blob {len(data)}\0'.encode())
    h.update(data)
    return h.hexdigest()


def load_spdx_gitoids(spdx_path):
    """Return [(package_name, gitoid_hex), ...] for every externalRef
    of referenceType 'gitoid' in the SPDX document at spdx_path.

    Raises ValueError on a malformed locator (anything that isn't

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…