示例#1
0
def test_features_for():
    vuln_report_filename = os.path.join(
        os.path.dirname(os.path.abspath(__file__)), "vulnerabilityreport.json")
    security_info_filename = os.path.join(
        os.path.dirname(os.path.abspath(__file__)), "securityinformation.json")

    with open(vuln_report_filename) as vuln_report_file:
        vuln_report = json.load(vuln_report_file)

        with open(security_info_filename) as security_info_file:
            security_info = json.load(security_info_file)

        features_for_sec_info = SecurityInformation(
            Layer(
                "sha256:b05ac1eeec8635442fa5d3e55d6ef4ad287b9c66055a552c2fd309c334563b0a",
                "",
                "",
                4,
                features_for(vuln_report),
            )).to_dict()

        assert json.dumps(
            canonicalize(features_for_sec_info,
                         preserve_sequence_order=False)) == json.dumps(
                             canonicalize(security_info["data"],
                                          preserve_sequence_order=False))
示例#2
0
文件: image.py 项目: epasham/quay-1
def _get_uniqueness_hash(varying_metadata):
    if not varying_metadata:
        return None

    return hashlib.sha256(
        json.dumps(
            canonicalize(varying_metadata)).encode("utf-8")).hexdigest()
示例#3
0
def canonical_kid(jwk):
    """
    This function returns the SHA256 hash of a canonical JWK.

    Args:
      jwk (object): the JWK for which a kid will be generated.

    Returns:
      string: the unique kid for the given JWK.
    """
    return sha256(json.dumps(canonicalize(jwk), separators=(",", ":"))).hexdigest()