3131from python_gardenlinux_lib .oras .crypto import (
3232 calculate_sha256 ,
3333 verify_sha256 ,
34- Signer ,
3534)
3635from python_gardenlinux_lib .oras .defaults import (
3736 annotation_signature_key ,
@@ -136,7 +135,6 @@ class GlociRegistry(Registry):
136135 def __init__ (
137136 self ,
138137 container_name : str ,
139- signer : Signer ,
140138 insecure : bool = False ,
141139 token : Optional [str ] = None ,
142140 config_path : Optional [str ] = None ,
@@ -146,7 +144,6 @@ def __init__(
146144 self .container_name = container_name
147145 self .registry_url = self .container .registry
148146 self .config_path = config_path
149- self .signer = signer
150147 if not token :
151148 logger .info ("No Token provided." )
152149 else :
@@ -168,7 +165,6 @@ def get_manifest_json(
168165 get_manifest = f"{ self .prefix } ://{ container .manifest_url ()} "
169166 response = self .do_request (get_manifest , "GET" , headers = headers )
170167 self ._check_200_response (response )
171- self .verify_manifest_signature (response .json ())
172168 return response
173169
174170 @ensure_container
@@ -252,7 +248,6 @@ def get_manifest_meta_data_by_cname(
252248 and manifest_meta ["annotations" ]["architecture" ] == arch
253249 and manifest_meta ["platform" ]["os.version" ] == version
254250 ):
255- self .verify_manifest_meta_signature (manifest_meta )
256251 return manifest_meta
257252
258253 return None
@@ -278,7 +273,6 @@ def get_manifest_by_digest(
278273 self ._check_200_response (response )
279274 manifest = response .json ()
280275 verify_sha256 (digest , response .content )
281- self .verify_manifest_signature (manifest )
282276 jsonschema .validate (manifest , schema = oras_manifest_schema )
283277 return manifest
284278
@@ -367,8 +361,6 @@ def attach_layer(
367361 self .container , cname , version , architecture
368362 )
369363
370- self .verify_manifest_signature (manifest )
371-
372364 layer = self .create_layer (file_path , cname , version , architecture , media_type )
373365 self ._check_200_response (self .upload_blob (file_path , self .container , layer ))
374366
@@ -384,7 +376,6 @@ def attach_layer(
384376 new_manifest_metadata ["size" ] = self .get_manifest_size (manifest_container )
385377 new_manifest_metadata ["platform" ] = NewPlatform (architecture , version )
386378
387- self .sign_manifest_entry (new_manifest_metadata , version , architecture , cname )
388379 new_index = self .update_index (old_manifest_digest , new_manifest_metadata )
389380 self ._check_200_response (self .upload_index (new_index ))
390381
@@ -535,6 +526,7 @@ def push_image_manifest(
535526 :param str build_artifacts_dir: directory where the build artifacts are located
536527 :param str feature_set: the expanded list of the included features of this manifest. It will be set in the
537528 manifest itself and in the index entry for this manifest
529+ :returns the digest of the pushed manifest
538530 """
539531
540532 # TODO: construct oci_artifacts default data
@@ -594,6 +586,8 @@ def push_image_manifest(
594586 f"{ self .container_name } -{ cname } -{ architecture } "
595587 )
596588
589+ local_digest = f"sha256:{ hashlib .sha256 (json .dumps (manifest_image ).encode ('utf-8' )).hexdigest ()} "
590+
597591 self ._check_200_response (
598592 self .upload_manifest (manifest_image , manifest_container )
599593 )
@@ -603,13 +597,14 @@ def push_image_manifest(
603597 attach_state (metadata_annotations , "" )
604598 metadata_annotations ["feature_set" ] = feature_set
605599 manifest_digest = self .get_digest (manifest_container )
600+ if manifest_digest != local_digest :
601+ raise ValueError ("local and remotely calculated digests do not match" )
606602 manifest_index_metadata = NewManifestMetadata (
607603 manifest_digest ,
608604 self .get_manifest_size (manifest_container ),
609605 metadata_annotations ,
610606 NewPlatform (architecture , version ),
611607 )
612- self .sign_manifest_entry (manifest_index_metadata , version , architecture , cname )
613608
614609 old_manifest_meta_data = self .get_manifest_meta_data_by_cname (
615610 self .container , cname , version , architecture
@@ -624,7 +619,7 @@ def push_image_manifest(
624619 self ._check_200_response (self .upload_index (new_index ))
625620
626621 print (f"Successfully pushed { self .container } " )
627- return response
622+ return local_digest
628623
629624 def create_layer (
630625 self ,
@@ -639,9 +634,6 @@ def create_layer(
639634 layer ["annotations" ] = {
640635 oras .defaults .annotation_title : os .path .basename (file_path ),
641636 }
642- self .sign_layer (
643- layer , cname , version , architecture , checksum_sha256 , media_type
644- )
645637 return layer
646638
647639 def push_from_tar (self , architecture : str , version : str , cname : str , tar : str ):
@@ -667,7 +659,7 @@ def push_from_tar(self, architecture: str, version: str, cname: str, tar: str):
667659 break
668660 file .close ()
669661
670- self .push_image_manifest (
662+ digest = self .push_image_manifest (
671663 architecture , cname , version , tmpdir , oci_metadata , features
672664 )
673665 except Exception as e :
@@ -677,6 +669,7 @@ def push_from_tar(self, architecture: str, version: str, cname: str, tar: str):
677669 exit (1 )
678670 shutil .rmtree (tmpdir , ignore_errors = True )
679671 print ("removed tmp files." )
672+ return digest
680673
681674
682675def extract_tar (tar : str , tmpdir : str ):
0 commit comments