[bitbake-devel] [PATCH v3 1/7] bitbake: utils.py: add sha384_file and sha512_file functions

Richard Purdie richard.purdie at linuxfoundation.org
Fri Nov 22 16:26:51 UTC 2019


On Wed, 2019-11-20 at 10:34 +0100, Jean-Marie LEMETAYER wrote:
> This commit adds the "sha384_file" and "sha512_file" functions in
> order
> to check the integrity of the downloaded npm packages as npm now use
> subresource integrity:
> 
>   https://w3c.github.io/webappsec-subresource-integrity
> 
> Signed-off-by: Jean-Marie LEMETAYER <
> jean-marie.lemetayer at savoirfairelinux.com>
> ---
>  lib/bb/utils.py | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/lib/bb/utils.py b/lib/bb/utils.py
> index d035949b..34152855 100644
> --- a/lib/bb/utils.py
> +++ b/lib/bb/utils.py
> @@ -562,6 +562,30 @@ def sha1_file(filename):
>              s.update(line)
>      return s.hexdigest()
>  
> +def sha384_file(filename):
> +    """
> +    Return the hex string representation of the SHA384 checksum of
> the filename
> +    """
> +    import hashlib
> +
> +    s = hashlib.sha384()
> +    with open(filename, "rb") as f:
> +        for line in f:
> +            s.update(line)
> +    return s.hexdigest()
> +
> +def sha512_file(filename):
> +    """
> +    Return the hex string representation of the SHA512 checksum of
> the filename
> +    """
> +    import hashlib
> +
> +    s = hashlib.sha512()
> +    with open(filename, "rb") as f:
> +        for line in f:
> +            s.update(line)
> +    return s.hexdigest()
> +
>  def preserved_envvars_exported():

Note that:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=9d2fd91844fe387186b780b5457d0c02bea998e7 
merged, so this patch probably needs tweaking to match, thanks.

Cheers,

Richard



More information about the bitbake-devel mailing list