From fc5bd5c170a5644b08438565ed9346421f78de72 Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Wed, 15 Jun 2022 22:53:19 +0530 Subject: [PATCH 01/14] Made the sample test repository Removed the folders "metadata.staged" and "metadata" and added all the metadata inside the "1.0.0" and "2.0.0" Signed-off-by: Abhisman Sarkar --- .../repository/{metadata.staged => 1.0.0}/1.root.json | 0 .../repository/{metadata.staged => 1.0.0}/role1.json | 0 .../repository/{metadata => 1.0.0}/role2.json | 0 .../repository/{metadata.staged => 1.0.0}/root.json | 0 .../repository/{metadata.staged => 1.0.0}/snapshot.json | 0 .../repository/{metadata.staged => 1.0.0}/targets.json | 0 .../repository/{metadata.staged => 1.0.0}/timestamp.json | 0 .../repository/{metadata => 2.0.0}/1.root.json | 0 .../repository/{metadata => 2.0.0}/role1.json | 0 .../repository/{metadata.staged => 2.0.0}/role2.json | 6 +----- .../repository/{metadata => 2.0.0}/root.json | 0 .../repository/{metadata => 2.0.0}/snapshot.json | 0 .../repository/{metadata => 2.0.0}/targets.json | 0 .../repository/{metadata => 2.0.0}/timestamp.json | 0 14 files changed, 1 insertion(+), 5 deletions(-) rename tests/repository_data/repository/{metadata.staged => 1.0.0}/1.root.json (100%) rename tests/repository_data/repository/{metadata.staged => 1.0.0}/role1.json (100%) rename tests/repository_data/repository/{metadata => 1.0.0}/role2.json (100%) rename tests/repository_data/repository/{metadata.staged => 1.0.0}/root.json (100%) rename tests/repository_data/repository/{metadata.staged => 1.0.0}/snapshot.json (100%) rename tests/repository_data/repository/{metadata.staged => 1.0.0}/targets.json (100%) rename tests/repository_data/repository/{metadata.staged => 1.0.0}/timestamp.json (100%) rename tests/repository_data/repository/{metadata => 2.0.0}/1.root.json (100%) rename tests/repository_data/repository/{metadata => 2.0.0}/role1.json (100%) rename tests/repository_data/repository/{metadata.staged => 2.0.0}/role2.json (55%) rename tests/repository_data/repository/{metadata => 2.0.0}/root.json (100%) rename tests/repository_data/repository/{metadata => 2.0.0}/snapshot.json (100%) rename tests/repository_data/repository/{metadata => 2.0.0}/targets.json (100%) rename tests/repository_data/repository/{metadata => 2.0.0}/timestamp.json (100%) diff --git a/tests/repository_data/repository/metadata.staged/1.root.json b/tests/repository_data/repository/1.0.0/1.root.json similarity index 100% rename from tests/repository_data/repository/metadata.staged/1.root.json rename to tests/repository_data/repository/1.0.0/1.root.json diff --git a/tests/repository_data/repository/metadata.staged/role1.json b/tests/repository_data/repository/1.0.0/role1.json similarity index 100% rename from tests/repository_data/repository/metadata.staged/role1.json rename to tests/repository_data/repository/1.0.0/role1.json diff --git a/tests/repository_data/repository/metadata/role2.json b/tests/repository_data/repository/1.0.0/role2.json similarity index 100% rename from tests/repository_data/repository/metadata/role2.json rename to tests/repository_data/repository/1.0.0/role2.json diff --git a/tests/repository_data/repository/metadata.staged/root.json b/tests/repository_data/repository/1.0.0/root.json similarity index 100% rename from tests/repository_data/repository/metadata.staged/root.json rename to tests/repository_data/repository/1.0.0/root.json diff --git a/tests/repository_data/repository/metadata.staged/snapshot.json b/tests/repository_data/repository/1.0.0/snapshot.json similarity index 100% rename from tests/repository_data/repository/metadata.staged/snapshot.json rename to tests/repository_data/repository/1.0.0/snapshot.json diff --git a/tests/repository_data/repository/metadata.staged/targets.json b/tests/repository_data/repository/1.0.0/targets.json similarity index 100% rename from tests/repository_data/repository/metadata.staged/targets.json rename to tests/repository_data/repository/1.0.0/targets.json diff --git a/tests/repository_data/repository/metadata.staged/timestamp.json b/tests/repository_data/repository/1.0.0/timestamp.json similarity index 100% rename from tests/repository_data/repository/metadata.staged/timestamp.json rename to tests/repository_data/repository/1.0.0/timestamp.json diff --git a/tests/repository_data/repository/metadata/1.root.json b/tests/repository_data/repository/2.0.0/1.root.json similarity index 100% rename from tests/repository_data/repository/metadata/1.root.json rename to tests/repository_data/repository/2.0.0/1.root.json diff --git a/tests/repository_data/repository/metadata/role1.json b/tests/repository_data/repository/2.0.0/role1.json similarity index 100% rename from tests/repository_data/repository/metadata/role1.json rename to tests/repository_data/repository/2.0.0/role1.json diff --git a/tests/repository_data/repository/metadata.staged/role2.json b/tests/repository_data/repository/2.0.0/role2.json similarity index 55% rename from tests/repository_data/repository/metadata.staged/role2.json rename to tests/repository_data/repository/2.0.0/role2.json index 93f378a758..9c49e16570 100644 --- a/tests/repository_data/repository/metadata.staged/role2.json +++ b/tests/repository_data/repository/2.0.0/role2.json @@ -2,15 +2,11 @@ "signatures": [ { "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", - "sig": "6c32f8cc2c642803a7b3b022ede0cf727e82964c1aa934571ef366bd5050ed02cfe3fdfe5477c08d0cbcc2dd17bb786d37ab1ce2b27e01ad79faf087594e0300" + "sig": "75b196a224fd200e46e738b1216b3316c5384f61083872f8d14b8b0a378b2344e64b1a6f1a89a711206a66a0b199d65ac0e30fe15ddbc4de89fa8ff645f99403" } ], "signed": { "_type": "targets", - "delegations": { - "keys": {}, - "roles": [] - }, "expires": "2030-01-01T00:00:00Z", "spec_version": "1.0.0", "targets": {}, diff --git a/tests/repository_data/repository/metadata/root.json b/tests/repository_data/repository/2.0.0/root.json similarity index 100% rename from tests/repository_data/repository/metadata/root.json rename to tests/repository_data/repository/2.0.0/root.json diff --git a/tests/repository_data/repository/metadata/snapshot.json b/tests/repository_data/repository/2.0.0/snapshot.json similarity index 100% rename from tests/repository_data/repository/metadata/snapshot.json rename to tests/repository_data/repository/2.0.0/snapshot.json diff --git a/tests/repository_data/repository/metadata/targets.json b/tests/repository_data/repository/2.0.0/targets.json similarity index 100% rename from tests/repository_data/repository/metadata/targets.json rename to tests/repository_data/repository/2.0.0/targets.json diff --git a/tests/repository_data/repository/metadata/timestamp.json b/tests/repository_data/repository/2.0.0/timestamp.json similarity index 100% rename from tests/repository_data/repository/metadata/timestamp.json rename to tests/repository_data/repository/2.0.0/timestamp.json From 5a4332b45c9942657b25165a3ff87c304cd2f9da Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Thu, 16 Jun 2022 00:20:32 +0530 Subject: [PATCH 02/14] Updated spec versions inside 2.0.0 Updated the spec version inside the metadata files inside the "2.0.0" folder Signed-off-by: Abhisman Sarkar --- tests/repository_data/repository/1.0.0/role1.json | 2 +- tests/repository_data/repository/1.0.0/role2.json | 2 +- tests/repository_data/repository/2.0.0/1.root.json | 2 +- tests/repository_data/repository/2.0.0/role1.json | 2 +- tests/repository_data/repository/2.0.0/root.json | 2 +- tests/repository_data/repository/2.0.0/snapshot.json | 2 +- tests/repository_data/repository/2.0.0/targets.json | 2 +- tests/repository_data/repository/2.0.0/timestamp.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/repository_data/repository/1.0.0/role1.json b/tests/repository_data/repository/1.0.0/role1.json index 0ac4687e77..66ec049d73 100644 --- a/tests/repository_data/repository/1.0.0/role1.json +++ b/tests/repository_data/repository/1.0.0/role1.json @@ -34,7 +34,7 @@ ] }, "expires": "2030-01-01T00:00:00Z", - "spec_version": "1.0.0", + "spec_version": "2.0.0", "targets": { "file3.txt": { "hashes": { diff --git a/tests/repository_data/repository/1.0.0/role2.json b/tests/repository_data/repository/1.0.0/role2.json index 9c49e16570..252f2aa88d 100644 --- a/tests/repository_data/repository/1.0.0/role2.json +++ b/tests/repository_data/repository/1.0.0/role2.json @@ -8,7 +8,7 @@ "signed": { "_type": "targets", "expires": "2030-01-01T00:00:00Z", - "spec_version": "1.0.0", + "spec_version": "2.0.0", "targets": {}, "version": 1 } diff --git a/tests/repository_data/repository/2.0.0/1.root.json b/tests/repository_data/repository/2.0.0/1.root.json index 214d8db01b..25595b3f38 100644 --- a/tests/repository_data/repository/2.0.0/1.root.json +++ b/tests/repository_data/repository/2.0.0/1.root.json @@ -81,7 +81,7 @@ "threshold": 1 } }, - "spec_version": "1.0.0", + "spec_version": "2.0.0", "version": 1 } } \ No newline at end of file diff --git a/tests/repository_data/repository/2.0.0/role1.json b/tests/repository_data/repository/2.0.0/role1.json index 0ac4687e77..66ec049d73 100644 --- a/tests/repository_data/repository/2.0.0/role1.json +++ b/tests/repository_data/repository/2.0.0/role1.json @@ -34,7 +34,7 @@ ] }, "expires": "2030-01-01T00:00:00Z", - "spec_version": "1.0.0", + "spec_version": "2.0.0", "targets": { "file3.txt": { "hashes": { diff --git a/tests/repository_data/repository/2.0.0/root.json b/tests/repository_data/repository/2.0.0/root.json index 214d8db01b..25595b3f38 100644 --- a/tests/repository_data/repository/2.0.0/root.json +++ b/tests/repository_data/repository/2.0.0/root.json @@ -81,7 +81,7 @@ "threshold": 1 } }, - "spec_version": "1.0.0", + "spec_version": "2.0.0", "version": 1 } } \ No newline at end of file diff --git a/tests/repository_data/repository/2.0.0/snapshot.json b/tests/repository_data/repository/2.0.0/snapshot.json index 7c8c091a2e..51aa78a5a6 100644 --- a/tests/repository_data/repository/2.0.0/snapshot.json +++ b/tests/repository_data/repository/2.0.0/snapshot.json @@ -19,7 +19,7 @@ "version": 1 } }, - "spec_version": "1.0.0", + "spec_version": "2.0.0", "version": 1 } } \ No newline at end of file diff --git a/tests/repository_data/repository/2.0.0/targets.json b/tests/repository_data/repository/2.0.0/targets.json index 8e21c269b4..9517c048d0 100644 --- a/tests/repository_data/repository/2.0.0/targets.json +++ b/tests/repository_data/repository/2.0.0/targets.json @@ -36,7 +36,7 @@ ] }, "expires": "2030-01-01T00:00:00Z", - "spec_version": "1.0.0", + "spec_version": "2.0.0", "targets": { "file1.txt": { "custom": { diff --git a/tests/repository_data/repository/2.0.0/timestamp.json b/tests/repository_data/repository/2.0.0/timestamp.json index 9a0daf078b..9d38e7c7ed 100644 --- a/tests/repository_data/repository/2.0.0/timestamp.json +++ b/tests/repository_data/repository/2.0.0/timestamp.json @@ -17,7 +17,7 @@ "version": 1 } }, - "spec_version": "1.0.0", + "spec_version": "2.0.0", "version": 1 } } \ No newline at end of file From 88c140a3bab59bc929b3bfda02caccd72b0a8a7b Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Fri, 17 Jun 2022 17:19:56 +0530 Subject: [PATCH 03/14] Updated the directory structure Added the all the metadata files alongside the "1.0.0", "2.0.0" and "targets" folders Signed-off-by: Abhisman Sarkar --- tests/repository_data/repository/1.root.json | 87 +++++++++++++++++++ tests/repository_data/repository/role1.json | 49 +++++++++++ tests/repository_data/repository/role2.json | 15 ++++ tests/repository_data/repository/root.json | 87 +++++++++++++++++++ .../repository_data/repository/snapshot.json | 25 ++++++ tests/repository_data/repository/targets.json | 61 +++++++++++++ .../repository_data/repository/timestamp.json | 23 +++++ 7 files changed, 347 insertions(+) create mode 100644 tests/repository_data/repository/1.root.json create mode 100644 tests/repository_data/repository/role1.json create mode 100644 tests/repository_data/repository/role2.json create mode 100644 tests/repository_data/repository/root.json create mode 100644 tests/repository_data/repository/snapshot.json create mode 100644 tests/repository_data/repository/targets.json create mode 100644 tests/repository_data/repository/timestamp.json diff --git a/tests/repository_data/repository/1.root.json b/tests/repository_data/repository/1.root.json new file mode 100644 index 0000000000..214d8db01b --- /dev/null +++ b/tests/repository_data/repository/1.root.json @@ -0,0 +1,87 @@ +{ + "signatures": [ + { + "keyid": "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb", + "sig": "a337d6375fedd2eabfcd6c2ef6c8a9c3bb85dc5a857715f6a6bd41123e7670c4972d8548bcd7248154f3d864bf25f1823af59d74c459f41ea09a02db057ca1245612ebbdb97e782c501dc3e094f7fa8aa1402b03c6ed0635f565e2a26f9f543a89237e15a2faf0c267e2b34c3c38f2a43a28ddcdaf8308a12ead8c6dc47d1b762de313e9ddda8cc5bc25aea1b69d0e5b9199ca02f5dda48c3bff615fd12a7136d00634b9abc6e75c3256106c4d6f12e6c43f6195071355b2857bbe377ce028619b58837696b805040ce144b393d50a472531f430fadfb68d3081b6a8b5e49337e328c9a0a3f11e80b0bc8eb2dc6e78d1451dd857e6e6e6363c3fd14c590aa95e083c9bfc77724d78af86eb7a7ef635eeddaa353030c79f66b3ba9ea11fab456cfe896a826fdfb50a43cd444f762821aada9bcd7b022c0ee85b8768f960343d5a1d3d76374cc0ac9e12a500de0bf5d48569e5398cadadadab045931c398e3bcb6cec88af2437ba91959f956079cbed159fed3938016e6c3b5e446131f81cc5981" + } + ], + "signed": { + "_type": "root", + "consistent_snapshot": false, + "expires": "2030-01-01T00:00:00Z", + "keys": { + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "rsa", + "keyval": { + "public": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0GjPoVrjS9eCqzoQ8VRe\nPkC0cI6ktiEgqPfHESFzyxyjC490Cuy19nuxPcJuZfN64MC48oOkR+W2mq4pM51i\nxmdG5xjvNOBRkJ5wUCc8fDCltMUTBlqt9y5eLsf/4/EoBU+zC4SW1iPU++mCsity\nfQQ7U6LOn3EYCyrkH51hZ/dvKC4o9TPYMVxNecJ3CL1q02Q145JlyjBTuM3Xdqsa\nndTHoXSRPmmzgB/1dL/c4QjMnCowrKW06mFLq9RAYGIaJWfM/0CbrOJpVDkATmEc\nMdpGJYDfW/sRQvRdlHNPo24ZW7vkQUCqdRxvnTWkK5U81y7RtjLt1yskbWXBIbOV\nz94GXsgyzANyCT9qRjHXDDz2mkLq+9I2iKtEqaEePcWRu3H6RLahpM/TxFzw684Y\nR47weXdDecPNxWyiWiyMGStRFP4Cg9trcwAGnEm1w8R2ggmWphznCd5dXGhPNjfA\na82yNFY8ubnOUVJOf0nXGg3Edw9iY3xyjJb2+nrsk5f3AgMBAAE=\n-----END PUBLIC KEY-----" + }, + "scheme": "rsassa-pss-sha256" + }, + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "edcd0a32a07dce33f7c7873aaffbff36d20ea30787574ead335eefd337e4dacd" + }, + "scheme": "ed25519" + }, + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "89f28bd4ede5ec3786ab923fd154f39588d20881903e69c7b08fb504c6750815" + }, + "scheme": "ed25519" + }, + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "82ccf6ac47298ff43bfa0cd639868894e305a99c723ff0515ae2e9856eb5bbf4" + }, + "scheme": "ed25519" + } + }, + "roles": { + "root": { + "keyids": [ + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb" + ], + "threshold": 1 + }, + "snapshot": { + "keyids": [ + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d" + ], + "threshold": 1 + }, + "targets": { + "keyids": [ + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093" + ], + "threshold": 1 + }, + "timestamp": { + "keyids": [ + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758" + ], + "threshold": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/repository/role1.json b/tests/repository_data/repository/role1.json new file mode 100644 index 0000000000..66ec049d73 --- /dev/null +++ b/tests/repository_data/repository/role1.json @@ -0,0 +1,49 @@ +{ + "signatures": [ + { + "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", + "sig": "9408b46569e622a46f1d35d9fa3c10e17a9285631ced4f2c9c2bba2c2842413fcb796db4e81d6f988fc056c21c407fdc3c10441592cf1e837e088f2e2dfd5403" + } + ], + "signed": { + "_type": "targets", + "delegations": { + "keys": { + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "fcf224e55fa226056adf113ef1eb3d55e308b75b321c8c8316999d8c4fd9e0d9" + }, + "scheme": "ed25519" + } + }, + "roles": [ + { + "keyids": [ + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a" + ], + "name": "role2", + "paths": [], + "terminating": false, + "threshold": 1 + } + ] + }, + "expires": "2030-01-01T00:00:00Z", + "spec_version": "2.0.0", + "targets": { + "file3.txt": { + "hashes": { + "sha256": "141f740f53781d1ca54b8a50af22cbf74e44c21a998fa2a8a05aaac2c002886b", + "sha512": "ef5beafa16041bcdd2937140afebd485296cd54f7348ecd5a4d035c09759608de467a7ac0eb58753d0242df873c305e8bffad2454aa48f44480f15efae1cacd0" + }, + "length": 28 + } + }, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/repository/role2.json b/tests/repository_data/repository/role2.json new file mode 100644 index 0000000000..252f2aa88d --- /dev/null +++ b/tests/repository_data/repository/role2.json @@ -0,0 +1,15 @@ +{ + "signatures": [ + { + "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", + "sig": "75b196a224fd200e46e738b1216b3316c5384f61083872f8d14b8b0a378b2344e64b1a6f1a89a711206a66a0b199d65ac0e30fe15ddbc4de89fa8ff645f99403" + } + ], + "signed": { + "_type": "targets", + "expires": "2030-01-01T00:00:00Z", + "spec_version": "2.0.0", + "targets": {}, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/repository/root.json b/tests/repository_data/repository/root.json new file mode 100644 index 0000000000..214d8db01b --- /dev/null +++ b/tests/repository_data/repository/root.json @@ -0,0 +1,87 @@ +{ + "signatures": [ + { + "keyid": "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb", + "sig": "a337d6375fedd2eabfcd6c2ef6c8a9c3bb85dc5a857715f6a6bd41123e7670c4972d8548bcd7248154f3d864bf25f1823af59d74c459f41ea09a02db057ca1245612ebbdb97e782c501dc3e094f7fa8aa1402b03c6ed0635f565e2a26f9f543a89237e15a2faf0c267e2b34c3c38f2a43a28ddcdaf8308a12ead8c6dc47d1b762de313e9ddda8cc5bc25aea1b69d0e5b9199ca02f5dda48c3bff615fd12a7136d00634b9abc6e75c3256106c4d6f12e6c43f6195071355b2857bbe377ce028619b58837696b805040ce144b393d50a472531f430fadfb68d3081b6a8b5e49337e328c9a0a3f11e80b0bc8eb2dc6e78d1451dd857e6e6e6363c3fd14c590aa95e083c9bfc77724d78af86eb7a7ef635eeddaa353030c79f66b3ba9ea11fab456cfe896a826fdfb50a43cd444f762821aada9bcd7b022c0ee85b8768f960343d5a1d3d76374cc0ac9e12a500de0bf5d48569e5398cadadadab045931c398e3bcb6cec88af2437ba91959f956079cbed159fed3938016e6c3b5e446131f81cc5981" + } + ], + "signed": { + "_type": "root", + "consistent_snapshot": false, + "expires": "2030-01-01T00:00:00Z", + "keys": { + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "rsa", + "keyval": { + "public": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0GjPoVrjS9eCqzoQ8VRe\nPkC0cI6ktiEgqPfHESFzyxyjC490Cuy19nuxPcJuZfN64MC48oOkR+W2mq4pM51i\nxmdG5xjvNOBRkJ5wUCc8fDCltMUTBlqt9y5eLsf/4/EoBU+zC4SW1iPU++mCsity\nfQQ7U6LOn3EYCyrkH51hZ/dvKC4o9TPYMVxNecJ3CL1q02Q145JlyjBTuM3Xdqsa\nndTHoXSRPmmzgB/1dL/c4QjMnCowrKW06mFLq9RAYGIaJWfM/0CbrOJpVDkATmEc\nMdpGJYDfW/sRQvRdlHNPo24ZW7vkQUCqdRxvnTWkK5U81y7RtjLt1yskbWXBIbOV\nz94GXsgyzANyCT9qRjHXDDz2mkLq+9I2iKtEqaEePcWRu3H6RLahpM/TxFzw684Y\nR47weXdDecPNxWyiWiyMGStRFP4Cg9trcwAGnEm1w8R2ggmWphznCd5dXGhPNjfA\na82yNFY8ubnOUVJOf0nXGg3Edw9iY3xyjJb2+nrsk5f3AgMBAAE=\n-----END PUBLIC KEY-----" + }, + "scheme": "rsassa-pss-sha256" + }, + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "edcd0a32a07dce33f7c7873aaffbff36d20ea30787574ead335eefd337e4dacd" + }, + "scheme": "ed25519" + }, + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "89f28bd4ede5ec3786ab923fd154f39588d20881903e69c7b08fb504c6750815" + }, + "scheme": "ed25519" + }, + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "82ccf6ac47298ff43bfa0cd639868894e305a99c723ff0515ae2e9856eb5bbf4" + }, + "scheme": "ed25519" + } + }, + "roles": { + "root": { + "keyids": [ + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb" + ], + "threshold": 1 + }, + "snapshot": { + "keyids": [ + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d" + ], + "threshold": 1 + }, + "targets": { + "keyids": [ + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093" + ], + "threshold": 1 + }, + "timestamp": { + "keyids": [ + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758" + ], + "threshold": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/repository/snapshot.json b/tests/repository_data/repository/snapshot.json new file mode 100644 index 0000000000..7c8c091a2e --- /dev/null +++ b/tests/repository_data/repository/snapshot.json @@ -0,0 +1,25 @@ +{ + "signatures": [ + { + "keyid": "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d", + "sig": "085672c70dffe26610e58542ee552843633cfed973abdad94c56138dbf0cd991644f2d3f27e4dda3098e08ab676e7f52627b587947ae69db1012d59a6da18e0c" + } + ], + "signed": { + "_type": "snapshot", + "expires": "2030-01-01T00:00:00Z", + "meta": { + "role1.json": { + "version": 1 + }, + "role2.json": { + "version": 1 + }, + "targets.json": { + "version": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/repository/targets.json b/tests/repository_data/repository/targets.json new file mode 100644 index 0000000000..8e21c269b4 --- /dev/null +++ b/tests/repository_data/repository/targets.json @@ -0,0 +1,61 @@ +{ + "signatures": [ + { + "keyid": "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093", + "sig": "d65f8db0c1a8f0976552b9742bbb393f24a5fa5eaf145c37aee047236c79dd0b83cfbb8b49fa7803689dfe0031dcf22c4d006b593acac07d69093b9b81722c08" + } + ], + "signed": { + "_type": "targets", + "delegations": { + "keys": { + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "fcf224e55fa226056adf113ef1eb3d55e308b75b321c8c8316999d8c4fd9e0d9" + }, + "scheme": "ed25519" + } + }, + "roles": [ + { + "keyids": [ + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a" + ], + "name": "role1", + "paths": [ + "file3.txt" + ], + "terminating": false, + "threshold": 1 + } + ] + }, + "expires": "2030-01-01T00:00:00Z", + "spec_version": "1.0.0", + "targets": { + "file1.txt": { + "custom": { + "file_permissions": "0644" + }, + "hashes": { + "sha256": "65b8c67f51c993d898250f40aa57a317d854900b3a04895464313e48785440da", + "sha512": "467430a68afae8e9f9c0771ea5d78bf0b3a0d79a2d3d3b40c69fde4dd42c461448aef76fcef4f5284931a1ffd0ac096d138ba3a0d6ca83fa8d7285a47a296f77" + }, + "length": 31 + }, + "file2.txt": { + "hashes": { + "sha256": "452ce8308500d83ef44248d8e6062359211992fd837ea9e370e561efb1a4ca99", + "sha512": "052b49a21e03606b28942db69aa597530fe52d47ee3d748ba65afcd14b857738e36bc1714c4f4adde46c3e683548552fe5c96722e0e0da3acd9050c2524902d8" + }, + "length": 39 + } + }, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/repository/timestamp.json b/tests/repository_data/repository/timestamp.json new file mode 100644 index 0000000000..9a0daf078b --- /dev/null +++ b/tests/repository_data/repository/timestamp.json @@ -0,0 +1,23 @@ +{ + "signatures": [ + { + "keyid": "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758", + "sig": "de0e16920f87bf5500cc65736488ac17e09788cce808f6a4e85eb9e4e478a312b4c1a2d7723af56f7bfb1df533c67d8c93b6f49d39eabe7fae391a08e1f72f01" + } + ], + "signed": { + "_type": "timestamp", + "expires": "2030-01-01T00:00:00Z", + "meta": { + "snapshot.json": { + "hashes": { + "sha256": "8f88e2ba48b412c3843e9bb26e1b6f8fc9e98aceb0fbaa97ba37b4c98717d7ab" + }, + "length": 515, + "version": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file From 774a03951dfa35a4fa08aab15ac6939c72648e4a Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Thu, 23 Jun 2022 20:21:36 +0530 Subject: [PATCH 04/14] Reverted to 6e20c31 Reverted the directory structure to keep all metadata inside "metadata.staged" and "metadata" folders Signed-off-by: Abhisman Sarkar --- .../repository/1.0.0/role2.json | 15 ---- .../repository/2.0.0/1.root.json | 87 ------------------- .../repository/2.0.0/role1.json | 49 ----------- .../repository/2.0.0/root.json | 87 ------------------- .../repository/2.0.0/snapshot.json | 25 ------ .../repository/2.0.0/targets.json | 61 ------------- .../repository/2.0.0/timestamp.json | 23 ----- .../{1.0.0 => metadata.staged}/1.root.json | 0 .../{1.0.0 => metadata.staged}/role1.json | 2 +- .../repository/metadata.staged/role2.json | 19 ++++ .../{1.0.0 => metadata.staged}/root.json | 0 .../{1.0.0 => metadata.staged}/snapshot.json | 0 .../{1.0.0 => metadata.staged}/targets.json | 0 .../{1.0.0 => metadata.staged}/timestamp.json | 0 .../repository/{ => metadata}/1.root.json | 0 .../repository/{ => metadata}/role1.json | 2 +- .../repository/{2.0.0 => metadata}/role2.json | 0 .../repository/{ => metadata}/root.json | 0 .../repository/{ => metadata}/snapshot.json | 0 .../repository/{ => metadata}/targets.json | 0 .../repository/{ => metadata}/timestamp.json | 0 tests/repository_data/repository/role2.json | 15 ---- 22 files changed, 21 insertions(+), 364 deletions(-) delete mode 100644 tests/repository_data/repository/1.0.0/role2.json delete mode 100644 tests/repository_data/repository/2.0.0/1.root.json delete mode 100644 tests/repository_data/repository/2.0.0/role1.json delete mode 100644 tests/repository_data/repository/2.0.0/root.json delete mode 100644 tests/repository_data/repository/2.0.0/snapshot.json delete mode 100644 tests/repository_data/repository/2.0.0/targets.json delete mode 100644 tests/repository_data/repository/2.0.0/timestamp.json rename tests/repository_data/repository/{1.0.0 => metadata.staged}/1.root.json (100%) rename tests/repository_data/repository/{1.0.0 => metadata.staged}/role1.json (97%) create mode 100644 tests/repository_data/repository/metadata.staged/role2.json rename tests/repository_data/repository/{1.0.0 => metadata.staged}/root.json (100%) rename tests/repository_data/repository/{1.0.0 => metadata.staged}/snapshot.json (100%) rename tests/repository_data/repository/{1.0.0 => metadata.staged}/targets.json (100%) rename tests/repository_data/repository/{1.0.0 => metadata.staged}/timestamp.json (100%) rename tests/repository_data/repository/{ => metadata}/1.root.json (100%) rename tests/repository_data/repository/{ => metadata}/role1.json (97%) rename tests/repository_data/repository/{2.0.0 => metadata}/role2.json (100%) rename tests/repository_data/repository/{ => metadata}/root.json (100%) rename tests/repository_data/repository/{ => metadata}/snapshot.json (100%) rename tests/repository_data/repository/{ => metadata}/targets.json (100%) rename tests/repository_data/repository/{ => metadata}/timestamp.json (100%) delete mode 100644 tests/repository_data/repository/role2.json diff --git a/tests/repository_data/repository/1.0.0/role2.json b/tests/repository_data/repository/1.0.0/role2.json deleted file mode 100644 index 252f2aa88d..0000000000 --- a/tests/repository_data/repository/1.0.0/role2.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "signatures": [ - { - "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", - "sig": "75b196a224fd200e46e738b1216b3316c5384f61083872f8d14b8b0a378b2344e64b1a6f1a89a711206a66a0b199d65ac0e30fe15ddbc4de89fa8ff645f99403" - } - ], - "signed": { - "_type": "targets", - "expires": "2030-01-01T00:00:00Z", - "spec_version": "2.0.0", - "targets": {}, - "version": 1 - } -} \ No newline at end of file diff --git a/tests/repository_data/repository/2.0.0/1.root.json b/tests/repository_data/repository/2.0.0/1.root.json deleted file mode 100644 index 25595b3f38..0000000000 --- a/tests/repository_data/repository/2.0.0/1.root.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "signatures": [ - { - "keyid": "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb", - "sig": "a337d6375fedd2eabfcd6c2ef6c8a9c3bb85dc5a857715f6a6bd41123e7670c4972d8548bcd7248154f3d864bf25f1823af59d74c459f41ea09a02db057ca1245612ebbdb97e782c501dc3e094f7fa8aa1402b03c6ed0635f565e2a26f9f543a89237e15a2faf0c267e2b34c3c38f2a43a28ddcdaf8308a12ead8c6dc47d1b762de313e9ddda8cc5bc25aea1b69d0e5b9199ca02f5dda48c3bff615fd12a7136d00634b9abc6e75c3256106c4d6f12e6c43f6195071355b2857bbe377ce028619b58837696b805040ce144b393d50a472531f430fadfb68d3081b6a8b5e49337e328c9a0a3f11e80b0bc8eb2dc6e78d1451dd857e6e6e6363c3fd14c590aa95e083c9bfc77724d78af86eb7a7ef635eeddaa353030c79f66b3ba9ea11fab456cfe896a826fdfb50a43cd444f762821aada9bcd7b022c0ee85b8768f960343d5a1d3d76374cc0ac9e12a500de0bf5d48569e5398cadadadab045931c398e3bcb6cec88af2437ba91959f956079cbed159fed3938016e6c3b5e446131f81cc5981" - } - ], - "signed": { - "_type": "root", - "consistent_snapshot": false, - "expires": "2030-01-01T00:00:00Z", - "keys": { - "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb": { - "keyid_hash_algorithms": [ - "sha256", - "sha512" - ], - "keytype": "rsa", - "keyval": { - "public": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0GjPoVrjS9eCqzoQ8VRe\nPkC0cI6ktiEgqPfHESFzyxyjC490Cuy19nuxPcJuZfN64MC48oOkR+W2mq4pM51i\nxmdG5xjvNOBRkJ5wUCc8fDCltMUTBlqt9y5eLsf/4/EoBU+zC4SW1iPU++mCsity\nfQQ7U6LOn3EYCyrkH51hZ/dvKC4o9TPYMVxNecJ3CL1q02Q145JlyjBTuM3Xdqsa\nndTHoXSRPmmzgB/1dL/c4QjMnCowrKW06mFLq9RAYGIaJWfM/0CbrOJpVDkATmEc\nMdpGJYDfW/sRQvRdlHNPo24ZW7vkQUCqdRxvnTWkK5U81y7RtjLt1yskbWXBIbOV\nz94GXsgyzANyCT9qRjHXDDz2mkLq+9I2iKtEqaEePcWRu3H6RLahpM/TxFzw684Y\nR47weXdDecPNxWyiWiyMGStRFP4Cg9trcwAGnEm1w8R2ggmWphznCd5dXGhPNjfA\na82yNFY8ubnOUVJOf0nXGg3Edw9iY3xyjJb2+nrsk5f3AgMBAAE=\n-----END PUBLIC KEY-----" - }, - "scheme": "rsassa-pss-sha256" - }, - "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d": { - "keyid_hash_algorithms": [ - "sha256", - "sha512" - ], - "keytype": "ed25519", - "keyval": { - "public": "edcd0a32a07dce33f7c7873aaffbff36d20ea30787574ead335eefd337e4dacd" - }, - "scheme": "ed25519" - }, - "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093": { - "keyid_hash_algorithms": [ - "sha256", - "sha512" - ], - "keytype": "ed25519", - "keyval": { - "public": "89f28bd4ede5ec3786ab923fd154f39588d20881903e69c7b08fb504c6750815" - }, - "scheme": "ed25519" - }, - "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758": { - "keyid_hash_algorithms": [ - "sha256", - "sha512" - ], - "keytype": "ed25519", - "keyval": { - "public": "82ccf6ac47298ff43bfa0cd639868894e305a99c723ff0515ae2e9856eb5bbf4" - }, - "scheme": "ed25519" - } - }, - "roles": { - "root": { - "keyids": [ - "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb" - ], - "threshold": 1 - }, - "snapshot": { - "keyids": [ - "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d" - ], - "threshold": 1 - }, - "targets": { - "keyids": [ - "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093" - ], - "threshold": 1 - }, - "timestamp": { - "keyids": [ - "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758" - ], - "threshold": 1 - } - }, - "spec_version": "2.0.0", - "version": 1 - } -} \ No newline at end of file diff --git a/tests/repository_data/repository/2.0.0/role1.json b/tests/repository_data/repository/2.0.0/role1.json deleted file mode 100644 index 66ec049d73..0000000000 --- a/tests/repository_data/repository/2.0.0/role1.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "signatures": [ - { - "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", - "sig": "9408b46569e622a46f1d35d9fa3c10e17a9285631ced4f2c9c2bba2c2842413fcb796db4e81d6f988fc056c21c407fdc3c10441592cf1e837e088f2e2dfd5403" - } - ], - "signed": { - "_type": "targets", - "delegations": { - "keys": { - "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a": { - "keyid_hash_algorithms": [ - "sha256", - "sha512" - ], - "keytype": "ed25519", - "keyval": { - "public": "fcf224e55fa226056adf113ef1eb3d55e308b75b321c8c8316999d8c4fd9e0d9" - }, - "scheme": "ed25519" - } - }, - "roles": [ - { - "keyids": [ - "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a" - ], - "name": "role2", - "paths": [], - "terminating": false, - "threshold": 1 - } - ] - }, - "expires": "2030-01-01T00:00:00Z", - "spec_version": "2.0.0", - "targets": { - "file3.txt": { - "hashes": { - "sha256": "141f740f53781d1ca54b8a50af22cbf74e44c21a998fa2a8a05aaac2c002886b", - "sha512": "ef5beafa16041bcdd2937140afebd485296cd54f7348ecd5a4d035c09759608de467a7ac0eb58753d0242df873c305e8bffad2454aa48f44480f15efae1cacd0" - }, - "length": 28 - } - }, - "version": 1 - } -} \ No newline at end of file diff --git a/tests/repository_data/repository/2.0.0/root.json b/tests/repository_data/repository/2.0.0/root.json deleted file mode 100644 index 25595b3f38..0000000000 --- a/tests/repository_data/repository/2.0.0/root.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "signatures": [ - { - "keyid": "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb", - "sig": "a337d6375fedd2eabfcd6c2ef6c8a9c3bb85dc5a857715f6a6bd41123e7670c4972d8548bcd7248154f3d864bf25f1823af59d74c459f41ea09a02db057ca1245612ebbdb97e782c501dc3e094f7fa8aa1402b03c6ed0635f565e2a26f9f543a89237e15a2faf0c267e2b34c3c38f2a43a28ddcdaf8308a12ead8c6dc47d1b762de313e9ddda8cc5bc25aea1b69d0e5b9199ca02f5dda48c3bff615fd12a7136d00634b9abc6e75c3256106c4d6f12e6c43f6195071355b2857bbe377ce028619b58837696b805040ce144b393d50a472531f430fadfb68d3081b6a8b5e49337e328c9a0a3f11e80b0bc8eb2dc6e78d1451dd857e6e6e6363c3fd14c590aa95e083c9bfc77724d78af86eb7a7ef635eeddaa353030c79f66b3ba9ea11fab456cfe896a826fdfb50a43cd444f762821aada9bcd7b022c0ee85b8768f960343d5a1d3d76374cc0ac9e12a500de0bf5d48569e5398cadadadab045931c398e3bcb6cec88af2437ba91959f956079cbed159fed3938016e6c3b5e446131f81cc5981" - } - ], - "signed": { - "_type": "root", - "consistent_snapshot": false, - "expires": "2030-01-01T00:00:00Z", - "keys": { - "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb": { - "keyid_hash_algorithms": [ - "sha256", - "sha512" - ], - "keytype": "rsa", - "keyval": { - "public": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0GjPoVrjS9eCqzoQ8VRe\nPkC0cI6ktiEgqPfHESFzyxyjC490Cuy19nuxPcJuZfN64MC48oOkR+W2mq4pM51i\nxmdG5xjvNOBRkJ5wUCc8fDCltMUTBlqt9y5eLsf/4/EoBU+zC4SW1iPU++mCsity\nfQQ7U6LOn3EYCyrkH51hZ/dvKC4o9TPYMVxNecJ3CL1q02Q145JlyjBTuM3Xdqsa\nndTHoXSRPmmzgB/1dL/c4QjMnCowrKW06mFLq9RAYGIaJWfM/0CbrOJpVDkATmEc\nMdpGJYDfW/sRQvRdlHNPo24ZW7vkQUCqdRxvnTWkK5U81y7RtjLt1yskbWXBIbOV\nz94GXsgyzANyCT9qRjHXDDz2mkLq+9I2iKtEqaEePcWRu3H6RLahpM/TxFzw684Y\nR47weXdDecPNxWyiWiyMGStRFP4Cg9trcwAGnEm1w8R2ggmWphznCd5dXGhPNjfA\na82yNFY8ubnOUVJOf0nXGg3Edw9iY3xyjJb2+nrsk5f3AgMBAAE=\n-----END PUBLIC KEY-----" - }, - "scheme": "rsassa-pss-sha256" - }, - "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d": { - "keyid_hash_algorithms": [ - "sha256", - "sha512" - ], - "keytype": "ed25519", - "keyval": { - "public": "edcd0a32a07dce33f7c7873aaffbff36d20ea30787574ead335eefd337e4dacd" - }, - "scheme": "ed25519" - }, - "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093": { - "keyid_hash_algorithms": [ - "sha256", - "sha512" - ], - "keytype": "ed25519", - "keyval": { - "public": "89f28bd4ede5ec3786ab923fd154f39588d20881903e69c7b08fb504c6750815" - }, - "scheme": "ed25519" - }, - "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758": { - "keyid_hash_algorithms": [ - "sha256", - "sha512" - ], - "keytype": "ed25519", - "keyval": { - "public": "82ccf6ac47298ff43bfa0cd639868894e305a99c723ff0515ae2e9856eb5bbf4" - }, - "scheme": "ed25519" - } - }, - "roles": { - "root": { - "keyids": [ - "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb" - ], - "threshold": 1 - }, - "snapshot": { - "keyids": [ - "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d" - ], - "threshold": 1 - }, - "targets": { - "keyids": [ - "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093" - ], - "threshold": 1 - }, - "timestamp": { - "keyids": [ - "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758" - ], - "threshold": 1 - } - }, - "spec_version": "2.0.0", - "version": 1 - } -} \ No newline at end of file diff --git a/tests/repository_data/repository/2.0.0/snapshot.json b/tests/repository_data/repository/2.0.0/snapshot.json deleted file mode 100644 index 51aa78a5a6..0000000000 --- a/tests/repository_data/repository/2.0.0/snapshot.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "signatures": [ - { - "keyid": "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d", - "sig": "085672c70dffe26610e58542ee552843633cfed973abdad94c56138dbf0cd991644f2d3f27e4dda3098e08ab676e7f52627b587947ae69db1012d59a6da18e0c" - } - ], - "signed": { - "_type": "snapshot", - "expires": "2030-01-01T00:00:00Z", - "meta": { - "role1.json": { - "version": 1 - }, - "role2.json": { - "version": 1 - }, - "targets.json": { - "version": 1 - } - }, - "spec_version": "2.0.0", - "version": 1 - } -} \ No newline at end of file diff --git a/tests/repository_data/repository/2.0.0/targets.json b/tests/repository_data/repository/2.0.0/targets.json deleted file mode 100644 index 9517c048d0..0000000000 --- a/tests/repository_data/repository/2.0.0/targets.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "signatures": [ - { - "keyid": "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093", - "sig": "d65f8db0c1a8f0976552b9742bbb393f24a5fa5eaf145c37aee047236c79dd0b83cfbb8b49fa7803689dfe0031dcf22c4d006b593acac07d69093b9b81722c08" - } - ], - "signed": { - "_type": "targets", - "delegations": { - "keys": { - "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a": { - "keyid_hash_algorithms": [ - "sha256", - "sha512" - ], - "keytype": "ed25519", - "keyval": { - "public": "fcf224e55fa226056adf113ef1eb3d55e308b75b321c8c8316999d8c4fd9e0d9" - }, - "scheme": "ed25519" - } - }, - "roles": [ - { - "keyids": [ - "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a" - ], - "name": "role1", - "paths": [ - "file3.txt" - ], - "terminating": false, - "threshold": 1 - } - ] - }, - "expires": "2030-01-01T00:00:00Z", - "spec_version": "2.0.0", - "targets": { - "file1.txt": { - "custom": { - "file_permissions": "0644" - }, - "hashes": { - "sha256": "65b8c67f51c993d898250f40aa57a317d854900b3a04895464313e48785440da", - "sha512": "467430a68afae8e9f9c0771ea5d78bf0b3a0d79a2d3d3b40c69fde4dd42c461448aef76fcef4f5284931a1ffd0ac096d138ba3a0d6ca83fa8d7285a47a296f77" - }, - "length": 31 - }, - "file2.txt": { - "hashes": { - "sha256": "452ce8308500d83ef44248d8e6062359211992fd837ea9e370e561efb1a4ca99", - "sha512": "052b49a21e03606b28942db69aa597530fe52d47ee3d748ba65afcd14b857738e36bc1714c4f4adde46c3e683548552fe5c96722e0e0da3acd9050c2524902d8" - }, - "length": 39 - } - }, - "version": 1 - } -} \ No newline at end of file diff --git a/tests/repository_data/repository/2.0.0/timestamp.json b/tests/repository_data/repository/2.0.0/timestamp.json deleted file mode 100644 index 9d38e7c7ed..0000000000 --- a/tests/repository_data/repository/2.0.0/timestamp.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "signatures": [ - { - "keyid": "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758", - "sig": "de0e16920f87bf5500cc65736488ac17e09788cce808f6a4e85eb9e4e478a312b4c1a2d7723af56f7bfb1df533c67d8c93b6f49d39eabe7fae391a08e1f72f01" - } - ], - "signed": { - "_type": "timestamp", - "expires": "2030-01-01T00:00:00Z", - "meta": { - "snapshot.json": { - "hashes": { - "sha256": "8f88e2ba48b412c3843e9bb26e1b6f8fc9e98aceb0fbaa97ba37b4c98717d7ab" - }, - "length": 515, - "version": 1 - } - }, - "spec_version": "2.0.0", - "version": 1 - } -} \ No newline at end of file diff --git a/tests/repository_data/repository/1.0.0/1.root.json b/tests/repository_data/repository/metadata.staged/1.root.json similarity index 100% rename from tests/repository_data/repository/1.0.0/1.root.json rename to tests/repository_data/repository/metadata.staged/1.root.json diff --git a/tests/repository_data/repository/1.0.0/role1.json b/tests/repository_data/repository/metadata.staged/role1.json similarity index 97% rename from tests/repository_data/repository/1.0.0/role1.json rename to tests/repository_data/repository/metadata.staged/role1.json index 66ec049d73..0ac4687e77 100644 --- a/tests/repository_data/repository/1.0.0/role1.json +++ b/tests/repository_data/repository/metadata.staged/role1.json @@ -34,7 +34,7 @@ ] }, "expires": "2030-01-01T00:00:00Z", - "spec_version": "2.0.0", + "spec_version": "1.0.0", "targets": { "file3.txt": { "hashes": { diff --git a/tests/repository_data/repository/metadata.staged/role2.json b/tests/repository_data/repository/metadata.staged/role2.json new file mode 100644 index 0000000000..93f378a758 --- /dev/null +++ b/tests/repository_data/repository/metadata.staged/role2.json @@ -0,0 +1,19 @@ +{ + "signatures": [ + { + "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", + "sig": "6c32f8cc2c642803a7b3b022ede0cf727e82964c1aa934571ef366bd5050ed02cfe3fdfe5477c08d0cbcc2dd17bb786d37ab1ce2b27e01ad79faf087594e0300" + } + ], + "signed": { + "_type": "targets", + "delegations": { + "keys": {}, + "roles": [] + }, + "expires": "2030-01-01T00:00:00Z", + "spec_version": "1.0.0", + "targets": {}, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/repository/1.0.0/root.json b/tests/repository_data/repository/metadata.staged/root.json similarity index 100% rename from tests/repository_data/repository/1.0.0/root.json rename to tests/repository_data/repository/metadata.staged/root.json diff --git a/tests/repository_data/repository/1.0.0/snapshot.json b/tests/repository_data/repository/metadata.staged/snapshot.json similarity index 100% rename from tests/repository_data/repository/1.0.0/snapshot.json rename to tests/repository_data/repository/metadata.staged/snapshot.json diff --git a/tests/repository_data/repository/1.0.0/targets.json b/tests/repository_data/repository/metadata.staged/targets.json similarity index 100% rename from tests/repository_data/repository/1.0.0/targets.json rename to tests/repository_data/repository/metadata.staged/targets.json diff --git a/tests/repository_data/repository/1.0.0/timestamp.json b/tests/repository_data/repository/metadata.staged/timestamp.json similarity index 100% rename from tests/repository_data/repository/1.0.0/timestamp.json rename to tests/repository_data/repository/metadata.staged/timestamp.json diff --git a/tests/repository_data/repository/1.root.json b/tests/repository_data/repository/metadata/1.root.json similarity index 100% rename from tests/repository_data/repository/1.root.json rename to tests/repository_data/repository/metadata/1.root.json diff --git a/tests/repository_data/repository/role1.json b/tests/repository_data/repository/metadata/role1.json similarity index 97% rename from tests/repository_data/repository/role1.json rename to tests/repository_data/repository/metadata/role1.json index 66ec049d73..0ac4687e77 100644 --- a/tests/repository_data/repository/role1.json +++ b/tests/repository_data/repository/metadata/role1.json @@ -34,7 +34,7 @@ ] }, "expires": "2030-01-01T00:00:00Z", - "spec_version": "2.0.0", + "spec_version": "1.0.0", "targets": { "file3.txt": { "hashes": { diff --git a/tests/repository_data/repository/2.0.0/role2.json b/tests/repository_data/repository/metadata/role2.json similarity index 100% rename from tests/repository_data/repository/2.0.0/role2.json rename to tests/repository_data/repository/metadata/role2.json diff --git a/tests/repository_data/repository/root.json b/tests/repository_data/repository/metadata/root.json similarity index 100% rename from tests/repository_data/repository/root.json rename to tests/repository_data/repository/metadata/root.json diff --git a/tests/repository_data/repository/snapshot.json b/tests/repository_data/repository/metadata/snapshot.json similarity index 100% rename from tests/repository_data/repository/snapshot.json rename to tests/repository_data/repository/metadata/snapshot.json diff --git a/tests/repository_data/repository/targets.json b/tests/repository_data/repository/metadata/targets.json similarity index 100% rename from tests/repository_data/repository/targets.json rename to tests/repository_data/repository/metadata/targets.json diff --git a/tests/repository_data/repository/timestamp.json b/tests/repository_data/repository/metadata/timestamp.json similarity index 100% rename from tests/repository_data/repository/timestamp.json rename to tests/repository_data/repository/metadata/timestamp.json diff --git a/tests/repository_data/repository/role2.json b/tests/repository_data/repository/role2.json deleted file mode 100644 index 252f2aa88d..0000000000 --- a/tests/repository_data/repository/role2.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "signatures": [ - { - "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", - "sig": "75b196a224fd200e46e738b1216b3316c5384f61083872f8d14b8b0a378b2344e64b1a6f1a89a711206a66a0b199d65ac0e30fe15ddbc4de89fa8ff645f99403" - } - ], - "signed": { - "_type": "targets", - "expires": "2030-01-01T00:00:00Z", - "spec_version": "2.0.0", - "targets": {}, - "version": 1 - } -} \ No newline at end of file From 8845ebdaf037baab0a4886fd02c00223463b6743 Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Thu, 23 Jun 2022 20:23:23 +0530 Subject: [PATCH 05/14] Added the metadata under the newly created TAP 14 folder Created a new "TAP 14" folder wherein I added all the metadata inside the "1.0.0" and "2.0.0" folders and added the "targets" folder Signed-off-by: Abhisman Sarkar --- .../repository_data/TAP 14/1.0.0/1.root.json | 87 +++++++++++++++++++ tests/repository_data/TAP 14/1.0.0/role1.json | 49 +++++++++++ tests/repository_data/TAP 14/1.0.0/role2.json | 15 ++++ tests/repository_data/TAP 14/1.0.0/root.json | 87 +++++++++++++++++++ .../TAP 14/1.0.0/snapshot.json | 25 ++++++ .../repository_data/TAP 14/1.0.0/targets.json | 61 +++++++++++++ .../TAP 14/1.0.0/timestamp.json | 23 +++++ tests/repository_data/TAP 14/1.root.json | 87 +++++++++++++++++++ .../repository_data/TAP 14/2.0.0/1.root.json | 87 +++++++++++++++++++ tests/repository_data/TAP 14/2.0.0/role1.json | 49 +++++++++++ tests/repository_data/TAP 14/2.0.0/role2.json | 15 ++++ tests/repository_data/TAP 14/2.0.0/root.json | 87 +++++++++++++++++++ .../TAP 14/2.0.0/snapshot.json | 25 ++++++ .../repository_data/TAP 14/2.0.0/targets.json | 61 +++++++++++++ .../TAP 14/2.0.0/timestamp.json | 23 +++++ tests/repository_data/TAP 14/role1.json | 49 +++++++++++ tests/repository_data/TAP 14/role2.json | 15 ++++ tests/repository_data/TAP 14/root.json | 87 +++++++++++++++++++ tests/repository_data/TAP 14/snapshot.json | 25 ++++++ tests/repository_data/TAP 14/targets.json | 61 +++++++++++++ .../repository_data/TAP 14/targets/file1.txt | 1 + .../repository_data/TAP 14/targets/file2.txt | 1 + .../repository_data/TAP 14/targets/file3.txt | 1 + tests/repository_data/TAP 14/timestamp.json | 23 +++++ 24 files changed, 1044 insertions(+) create mode 100644 tests/repository_data/TAP 14/1.0.0/1.root.json create mode 100644 tests/repository_data/TAP 14/1.0.0/role1.json create mode 100644 tests/repository_data/TAP 14/1.0.0/role2.json create mode 100644 tests/repository_data/TAP 14/1.0.0/root.json create mode 100644 tests/repository_data/TAP 14/1.0.0/snapshot.json create mode 100644 tests/repository_data/TAP 14/1.0.0/targets.json create mode 100644 tests/repository_data/TAP 14/1.0.0/timestamp.json create mode 100644 tests/repository_data/TAP 14/1.root.json create mode 100644 tests/repository_data/TAP 14/2.0.0/1.root.json create mode 100644 tests/repository_data/TAP 14/2.0.0/role1.json create mode 100644 tests/repository_data/TAP 14/2.0.0/role2.json create mode 100644 tests/repository_data/TAP 14/2.0.0/root.json create mode 100644 tests/repository_data/TAP 14/2.0.0/snapshot.json create mode 100644 tests/repository_data/TAP 14/2.0.0/targets.json create mode 100644 tests/repository_data/TAP 14/2.0.0/timestamp.json create mode 100644 tests/repository_data/TAP 14/role1.json create mode 100644 tests/repository_data/TAP 14/role2.json create mode 100644 tests/repository_data/TAP 14/root.json create mode 100644 tests/repository_data/TAP 14/snapshot.json create mode 100644 tests/repository_data/TAP 14/targets.json create mode 100644 tests/repository_data/TAP 14/targets/file1.txt create mode 100644 tests/repository_data/TAP 14/targets/file2.txt create mode 100644 tests/repository_data/TAP 14/targets/file3.txt create mode 100644 tests/repository_data/TAP 14/timestamp.json diff --git a/tests/repository_data/TAP 14/1.0.0/1.root.json b/tests/repository_data/TAP 14/1.0.0/1.root.json new file mode 100644 index 0000000000..214d8db01b --- /dev/null +++ b/tests/repository_data/TAP 14/1.0.0/1.root.json @@ -0,0 +1,87 @@ +{ + "signatures": [ + { + "keyid": "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb", + "sig": "a337d6375fedd2eabfcd6c2ef6c8a9c3bb85dc5a857715f6a6bd41123e7670c4972d8548bcd7248154f3d864bf25f1823af59d74c459f41ea09a02db057ca1245612ebbdb97e782c501dc3e094f7fa8aa1402b03c6ed0635f565e2a26f9f543a89237e15a2faf0c267e2b34c3c38f2a43a28ddcdaf8308a12ead8c6dc47d1b762de313e9ddda8cc5bc25aea1b69d0e5b9199ca02f5dda48c3bff615fd12a7136d00634b9abc6e75c3256106c4d6f12e6c43f6195071355b2857bbe377ce028619b58837696b805040ce144b393d50a472531f430fadfb68d3081b6a8b5e49337e328c9a0a3f11e80b0bc8eb2dc6e78d1451dd857e6e6e6363c3fd14c590aa95e083c9bfc77724d78af86eb7a7ef635eeddaa353030c79f66b3ba9ea11fab456cfe896a826fdfb50a43cd444f762821aada9bcd7b022c0ee85b8768f960343d5a1d3d76374cc0ac9e12a500de0bf5d48569e5398cadadadab045931c398e3bcb6cec88af2437ba91959f956079cbed159fed3938016e6c3b5e446131f81cc5981" + } + ], + "signed": { + "_type": "root", + "consistent_snapshot": false, + "expires": "2030-01-01T00:00:00Z", + "keys": { + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "rsa", + "keyval": { + "public": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0GjPoVrjS9eCqzoQ8VRe\nPkC0cI6ktiEgqPfHESFzyxyjC490Cuy19nuxPcJuZfN64MC48oOkR+W2mq4pM51i\nxmdG5xjvNOBRkJ5wUCc8fDCltMUTBlqt9y5eLsf/4/EoBU+zC4SW1iPU++mCsity\nfQQ7U6LOn3EYCyrkH51hZ/dvKC4o9TPYMVxNecJ3CL1q02Q145JlyjBTuM3Xdqsa\nndTHoXSRPmmzgB/1dL/c4QjMnCowrKW06mFLq9RAYGIaJWfM/0CbrOJpVDkATmEc\nMdpGJYDfW/sRQvRdlHNPo24ZW7vkQUCqdRxvnTWkK5U81y7RtjLt1yskbWXBIbOV\nz94GXsgyzANyCT9qRjHXDDz2mkLq+9I2iKtEqaEePcWRu3H6RLahpM/TxFzw684Y\nR47weXdDecPNxWyiWiyMGStRFP4Cg9trcwAGnEm1w8R2ggmWphznCd5dXGhPNjfA\na82yNFY8ubnOUVJOf0nXGg3Edw9iY3xyjJb2+nrsk5f3AgMBAAE=\n-----END PUBLIC KEY-----" + }, + "scheme": "rsassa-pss-sha256" + }, + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "edcd0a32a07dce33f7c7873aaffbff36d20ea30787574ead335eefd337e4dacd" + }, + "scheme": "ed25519" + }, + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "89f28bd4ede5ec3786ab923fd154f39588d20881903e69c7b08fb504c6750815" + }, + "scheme": "ed25519" + }, + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "82ccf6ac47298ff43bfa0cd639868894e305a99c723ff0515ae2e9856eb5bbf4" + }, + "scheme": "ed25519" + } + }, + "roles": { + "root": { + "keyids": [ + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb" + ], + "threshold": 1 + }, + "snapshot": { + "keyids": [ + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d" + ], + "threshold": 1 + }, + "targets": { + "keyids": [ + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093" + ], + "threshold": 1 + }, + "timestamp": { + "keyids": [ + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758" + ], + "threshold": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/1.0.0/role1.json b/tests/repository_data/TAP 14/1.0.0/role1.json new file mode 100644 index 0000000000..66ec049d73 --- /dev/null +++ b/tests/repository_data/TAP 14/1.0.0/role1.json @@ -0,0 +1,49 @@ +{ + "signatures": [ + { + "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", + "sig": "9408b46569e622a46f1d35d9fa3c10e17a9285631ced4f2c9c2bba2c2842413fcb796db4e81d6f988fc056c21c407fdc3c10441592cf1e837e088f2e2dfd5403" + } + ], + "signed": { + "_type": "targets", + "delegations": { + "keys": { + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "fcf224e55fa226056adf113ef1eb3d55e308b75b321c8c8316999d8c4fd9e0d9" + }, + "scheme": "ed25519" + } + }, + "roles": [ + { + "keyids": [ + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a" + ], + "name": "role2", + "paths": [], + "terminating": false, + "threshold": 1 + } + ] + }, + "expires": "2030-01-01T00:00:00Z", + "spec_version": "2.0.0", + "targets": { + "file3.txt": { + "hashes": { + "sha256": "141f740f53781d1ca54b8a50af22cbf74e44c21a998fa2a8a05aaac2c002886b", + "sha512": "ef5beafa16041bcdd2937140afebd485296cd54f7348ecd5a4d035c09759608de467a7ac0eb58753d0242df873c305e8bffad2454aa48f44480f15efae1cacd0" + }, + "length": 28 + } + }, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/1.0.0/role2.json b/tests/repository_data/TAP 14/1.0.0/role2.json new file mode 100644 index 0000000000..252f2aa88d --- /dev/null +++ b/tests/repository_data/TAP 14/1.0.0/role2.json @@ -0,0 +1,15 @@ +{ + "signatures": [ + { + "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", + "sig": "75b196a224fd200e46e738b1216b3316c5384f61083872f8d14b8b0a378b2344e64b1a6f1a89a711206a66a0b199d65ac0e30fe15ddbc4de89fa8ff645f99403" + } + ], + "signed": { + "_type": "targets", + "expires": "2030-01-01T00:00:00Z", + "spec_version": "2.0.0", + "targets": {}, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/1.0.0/root.json b/tests/repository_data/TAP 14/1.0.0/root.json new file mode 100644 index 0000000000..214d8db01b --- /dev/null +++ b/tests/repository_data/TAP 14/1.0.0/root.json @@ -0,0 +1,87 @@ +{ + "signatures": [ + { + "keyid": "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb", + "sig": "a337d6375fedd2eabfcd6c2ef6c8a9c3bb85dc5a857715f6a6bd41123e7670c4972d8548bcd7248154f3d864bf25f1823af59d74c459f41ea09a02db057ca1245612ebbdb97e782c501dc3e094f7fa8aa1402b03c6ed0635f565e2a26f9f543a89237e15a2faf0c267e2b34c3c38f2a43a28ddcdaf8308a12ead8c6dc47d1b762de313e9ddda8cc5bc25aea1b69d0e5b9199ca02f5dda48c3bff615fd12a7136d00634b9abc6e75c3256106c4d6f12e6c43f6195071355b2857bbe377ce028619b58837696b805040ce144b393d50a472531f430fadfb68d3081b6a8b5e49337e328c9a0a3f11e80b0bc8eb2dc6e78d1451dd857e6e6e6363c3fd14c590aa95e083c9bfc77724d78af86eb7a7ef635eeddaa353030c79f66b3ba9ea11fab456cfe896a826fdfb50a43cd444f762821aada9bcd7b022c0ee85b8768f960343d5a1d3d76374cc0ac9e12a500de0bf5d48569e5398cadadadab045931c398e3bcb6cec88af2437ba91959f956079cbed159fed3938016e6c3b5e446131f81cc5981" + } + ], + "signed": { + "_type": "root", + "consistent_snapshot": false, + "expires": "2030-01-01T00:00:00Z", + "keys": { + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "rsa", + "keyval": { + "public": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0GjPoVrjS9eCqzoQ8VRe\nPkC0cI6ktiEgqPfHESFzyxyjC490Cuy19nuxPcJuZfN64MC48oOkR+W2mq4pM51i\nxmdG5xjvNOBRkJ5wUCc8fDCltMUTBlqt9y5eLsf/4/EoBU+zC4SW1iPU++mCsity\nfQQ7U6LOn3EYCyrkH51hZ/dvKC4o9TPYMVxNecJ3CL1q02Q145JlyjBTuM3Xdqsa\nndTHoXSRPmmzgB/1dL/c4QjMnCowrKW06mFLq9RAYGIaJWfM/0CbrOJpVDkATmEc\nMdpGJYDfW/sRQvRdlHNPo24ZW7vkQUCqdRxvnTWkK5U81y7RtjLt1yskbWXBIbOV\nz94GXsgyzANyCT9qRjHXDDz2mkLq+9I2iKtEqaEePcWRu3H6RLahpM/TxFzw684Y\nR47weXdDecPNxWyiWiyMGStRFP4Cg9trcwAGnEm1w8R2ggmWphznCd5dXGhPNjfA\na82yNFY8ubnOUVJOf0nXGg3Edw9iY3xyjJb2+nrsk5f3AgMBAAE=\n-----END PUBLIC KEY-----" + }, + "scheme": "rsassa-pss-sha256" + }, + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "edcd0a32a07dce33f7c7873aaffbff36d20ea30787574ead335eefd337e4dacd" + }, + "scheme": "ed25519" + }, + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "89f28bd4ede5ec3786ab923fd154f39588d20881903e69c7b08fb504c6750815" + }, + "scheme": "ed25519" + }, + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "82ccf6ac47298ff43bfa0cd639868894e305a99c723ff0515ae2e9856eb5bbf4" + }, + "scheme": "ed25519" + } + }, + "roles": { + "root": { + "keyids": [ + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb" + ], + "threshold": 1 + }, + "snapshot": { + "keyids": [ + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d" + ], + "threshold": 1 + }, + "targets": { + "keyids": [ + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093" + ], + "threshold": 1 + }, + "timestamp": { + "keyids": [ + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758" + ], + "threshold": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/1.0.0/snapshot.json b/tests/repository_data/TAP 14/1.0.0/snapshot.json new file mode 100644 index 0000000000..7c8c091a2e --- /dev/null +++ b/tests/repository_data/TAP 14/1.0.0/snapshot.json @@ -0,0 +1,25 @@ +{ + "signatures": [ + { + "keyid": "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d", + "sig": "085672c70dffe26610e58542ee552843633cfed973abdad94c56138dbf0cd991644f2d3f27e4dda3098e08ab676e7f52627b587947ae69db1012d59a6da18e0c" + } + ], + "signed": { + "_type": "snapshot", + "expires": "2030-01-01T00:00:00Z", + "meta": { + "role1.json": { + "version": 1 + }, + "role2.json": { + "version": 1 + }, + "targets.json": { + "version": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/1.0.0/targets.json b/tests/repository_data/TAP 14/1.0.0/targets.json new file mode 100644 index 0000000000..8e21c269b4 --- /dev/null +++ b/tests/repository_data/TAP 14/1.0.0/targets.json @@ -0,0 +1,61 @@ +{ + "signatures": [ + { + "keyid": "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093", + "sig": "d65f8db0c1a8f0976552b9742bbb393f24a5fa5eaf145c37aee047236c79dd0b83cfbb8b49fa7803689dfe0031dcf22c4d006b593acac07d69093b9b81722c08" + } + ], + "signed": { + "_type": "targets", + "delegations": { + "keys": { + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "fcf224e55fa226056adf113ef1eb3d55e308b75b321c8c8316999d8c4fd9e0d9" + }, + "scheme": "ed25519" + } + }, + "roles": [ + { + "keyids": [ + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a" + ], + "name": "role1", + "paths": [ + "file3.txt" + ], + "terminating": false, + "threshold": 1 + } + ] + }, + "expires": "2030-01-01T00:00:00Z", + "spec_version": "1.0.0", + "targets": { + "file1.txt": { + "custom": { + "file_permissions": "0644" + }, + "hashes": { + "sha256": "65b8c67f51c993d898250f40aa57a317d854900b3a04895464313e48785440da", + "sha512": "467430a68afae8e9f9c0771ea5d78bf0b3a0d79a2d3d3b40c69fde4dd42c461448aef76fcef4f5284931a1ffd0ac096d138ba3a0d6ca83fa8d7285a47a296f77" + }, + "length": 31 + }, + "file2.txt": { + "hashes": { + "sha256": "452ce8308500d83ef44248d8e6062359211992fd837ea9e370e561efb1a4ca99", + "sha512": "052b49a21e03606b28942db69aa597530fe52d47ee3d748ba65afcd14b857738e36bc1714c4f4adde46c3e683548552fe5c96722e0e0da3acd9050c2524902d8" + }, + "length": 39 + } + }, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/1.0.0/timestamp.json b/tests/repository_data/TAP 14/1.0.0/timestamp.json new file mode 100644 index 0000000000..9a0daf078b --- /dev/null +++ b/tests/repository_data/TAP 14/1.0.0/timestamp.json @@ -0,0 +1,23 @@ +{ + "signatures": [ + { + "keyid": "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758", + "sig": "de0e16920f87bf5500cc65736488ac17e09788cce808f6a4e85eb9e4e478a312b4c1a2d7723af56f7bfb1df533c67d8c93b6f49d39eabe7fae391a08e1f72f01" + } + ], + "signed": { + "_type": "timestamp", + "expires": "2030-01-01T00:00:00Z", + "meta": { + "snapshot.json": { + "hashes": { + "sha256": "8f88e2ba48b412c3843e9bb26e1b6f8fc9e98aceb0fbaa97ba37b4c98717d7ab" + }, + "length": 515, + "version": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/1.root.json b/tests/repository_data/TAP 14/1.root.json new file mode 100644 index 0000000000..214d8db01b --- /dev/null +++ b/tests/repository_data/TAP 14/1.root.json @@ -0,0 +1,87 @@ +{ + "signatures": [ + { + "keyid": "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb", + "sig": "a337d6375fedd2eabfcd6c2ef6c8a9c3bb85dc5a857715f6a6bd41123e7670c4972d8548bcd7248154f3d864bf25f1823af59d74c459f41ea09a02db057ca1245612ebbdb97e782c501dc3e094f7fa8aa1402b03c6ed0635f565e2a26f9f543a89237e15a2faf0c267e2b34c3c38f2a43a28ddcdaf8308a12ead8c6dc47d1b762de313e9ddda8cc5bc25aea1b69d0e5b9199ca02f5dda48c3bff615fd12a7136d00634b9abc6e75c3256106c4d6f12e6c43f6195071355b2857bbe377ce028619b58837696b805040ce144b393d50a472531f430fadfb68d3081b6a8b5e49337e328c9a0a3f11e80b0bc8eb2dc6e78d1451dd857e6e6e6363c3fd14c590aa95e083c9bfc77724d78af86eb7a7ef635eeddaa353030c79f66b3ba9ea11fab456cfe896a826fdfb50a43cd444f762821aada9bcd7b022c0ee85b8768f960343d5a1d3d76374cc0ac9e12a500de0bf5d48569e5398cadadadab045931c398e3bcb6cec88af2437ba91959f956079cbed159fed3938016e6c3b5e446131f81cc5981" + } + ], + "signed": { + "_type": "root", + "consistent_snapshot": false, + "expires": "2030-01-01T00:00:00Z", + "keys": { + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "rsa", + "keyval": { + "public": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0GjPoVrjS9eCqzoQ8VRe\nPkC0cI6ktiEgqPfHESFzyxyjC490Cuy19nuxPcJuZfN64MC48oOkR+W2mq4pM51i\nxmdG5xjvNOBRkJ5wUCc8fDCltMUTBlqt9y5eLsf/4/EoBU+zC4SW1iPU++mCsity\nfQQ7U6LOn3EYCyrkH51hZ/dvKC4o9TPYMVxNecJ3CL1q02Q145JlyjBTuM3Xdqsa\nndTHoXSRPmmzgB/1dL/c4QjMnCowrKW06mFLq9RAYGIaJWfM/0CbrOJpVDkATmEc\nMdpGJYDfW/sRQvRdlHNPo24ZW7vkQUCqdRxvnTWkK5U81y7RtjLt1yskbWXBIbOV\nz94GXsgyzANyCT9qRjHXDDz2mkLq+9I2iKtEqaEePcWRu3H6RLahpM/TxFzw684Y\nR47weXdDecPNxWyiWiyMGStRFP4Cg9trcwAGnEm1w8R2ggmWphznCd5dXGhPNjfA\na82yNFY8ubnOUVJOf0nXGg3Edw9iY3xyjJb2+nrsk5f3AgMBAAE=\n-----END PUBLIC KEY-----" + }, + "scheme": "rsassa-pss-sha256" + }, + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "edcd0a32a07dce33f7c7873aaffbff36d20ea30787574ead335eefd337e4dacd" + }, + "scheme": "ed25519" + }, + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "89f28bd4ede5ec3786ab923fd154f39588d20881903e69c7b08fb504c6750815" + }, + "scheme": "ed25519" + }, + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "82ccf6ac47298ff43bfa0cd639868894e305a99c723ff0515ae2e9856eb5bbf4" + }, + "scheme": "ed25519" + } + }, + "roles": { + "root": { + "keyids": [ + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb" + ], + "threshold": 1 + }, + "snapshot": { + "keyids": [ + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d" + ], + "threshold": 1 + }, + "targets": { + "keyids": [ + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093" + ], + "threshold": 1 + }, + "timestamp": { + "keyids": [ + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758" + ], + "threshold": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/2.0.0/1.root.json b/tests/repository_data/TAP 14/2.0.0/1.root.json new file mode 100644 index 0000000000..25595b3f38 --- /dev/null +++ b/tests/repository_data/TAP 14/2.0.0/1.root.json @@ -0,0 +1,87 @@ +{ + "signatures": [ + { + "keyid": "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb", + "sig": "a337d6375fedd2eabfcd6c2ef6c8a9c3bb85dc5a857715f6a6bd41123e7670c4972d8548bcd7248154f3d864bf25f1823af59d74c459f41ea09a02db057ca1245612ebbdb97e782c501dc3e094f7fa8aa1402b03c6ed0635f565e2a26f9f543a89237e15a2faf0c267e2b34c3c38f2a43a28ddcdaf8308a12ead8c6dc47d1b762de313e9ddda8cc5bc25aea1b69d0e5b9199ca02f5dda48c3bff615fd12a7136d00634b9abc6e75c3256106c4d6f12e6c43f6195071355b2857bbe377ce028619b58837696b805040ce144b393d50a472531f430fadfb68d3081b6a8b5e49337e328c9a0a3f11e80b0bc8eb2dc6e78d1451dd857e6e6e6363c3fd14c590aa95e083c9bfc77724d78af86eb7a7ef635eeddaa353030c79f66b3ba9ea11fab456cfe896a826fdfb50a43cd444f762821aada9bcd7b022c0ee85b8768f960343d5a1d3d76374cc0ac9e12a500de0bf5d48569e5398cadadadab045931c398e3bcb6cec88af2437ba91959f956079cbed159fed3938016e6c3b5e446131f81cc5981" + } + ], + "signed": { + "_type": "root", + "consistent_snapshot": false, + "expires": "2030-01-01T00:00:00Z", + "keys": { + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "rsa", + "keyval": { + "public": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0GjPoVrjS9eCqzoQ8VRe\nPkC0cI6ktiEgqPfHESFzyxyjC490Cuy19nuxPcJuZfN64MC48oOkR+W2mq4pM51i\nxmdG5xjvNOBRkJ5wUCc8fDCltMUTBlqt9y5eLsf/4/EoBU+zC4SW1iPU++mCsity\nfQQ7U6LOn3EYCyrkH51hZ/dvKC4o9TPYMVxNecJ3CL1q02Q145JlyjBTuM3Xdqsa\nndTHoXSRPmmzgB/1dL/c4QjMnCowrKW06mFLq9RAYGIaJWfM/0CbrOJpVDkATmEc\nMdpGJYDfW/sRQvRdlHNPo24ZW7vkQUCqdRxvnTWkK5U81y7RtjLt1yskbWXBIbOV\nz94GXsgyzANyCT9qRjHXDDz2mkLq+9I2iKtEqaEePcWRu3H6RLahpM/TxFzw684Y\nR47weXdDecPNxWyiWiyMGStRFP4Cg9trcwAGnEm1w8R2ggmWphznCd5dXGhPNjfA\na82yNFY8ubnOUVJOf0nXGg3Edw9iY3xyjJb2+nrsk5f3AgMBAAE=\n-----END PUBLIC KEY-----" + }, + "scheme": "rsassa-pss-sha256" + }, + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "edcd0a32a07dce33f7c7873aaffbff36d20ea30787574ead335eefd337e4dacd" + }, + "scheme": "ed25519" + }, + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "89f28bd4ede5ec3786ab923fd154f39588d20881903e69c7b08fb504c6750815" + }, + "scheme": "ed25519" + }, + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "82ccf6ac47298ff43bfa0cd639868894e305a99c723ff0515ae2e9856eb5bbf4" + }, + "scheme": "ed25519" + } + }, + "roles": { + "root": { + "keyids": [ + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb" + ], + "threshold": 1 + }, + "snapshot": { + "keyids": [ + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d" + ], + "threshold": 1 + }, + "targets": { + "keyids": [ + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093" + ], + "threshold": 1 + }, + "timestamp": { + "keyids": [ + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758" + ], + "threshold": 1 + } + }, + "spec_version": "2.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/2.0.0/role1.json b/tests/repository_data/TAP 14/2.0.0/role1.json new file mode 100644 index 0000000000..66ec049d73 --- /dev/null +++ b/tests/repository_data/TAP 14/2.0.0/role1.json @@ -0,0 +1,49 @@ +{ + "signatures": [ + { + "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", + "sig": "9408b46569e622a46f1d35d9fa3c10e17a9285631ced4f2c9c2bba2c2842413fcb796db4e81d6f988fc056c21c407fdc3c10441592cf1e837e088f2e2dfd5403" + } + ], + "signed": { + "_type": "targets", + "delegations": { + "keys": { + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "fcf224e55fa226056adf113ef1eb3d55e308b75b321c8c8316999d8c4fd9e0d9" + }, + "scheme": "ed25519" + } + }, + "roles": [ + { + "keyids": [ + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a" + ], + "name": "role2", + "paths": [], + "terminating": false, + "threshold": 1 + } + ] + }, + "expires": "2030-01-01T00:00:00Z", + "spec_version": "2.0.0", + "targets": { + "file3.txt": { + "hashes": { + "sha256": "141f740f53781d1ca54b8a50af22cbf74e44c21a998fa2a8a05aaac2c002886b", + "sha512": "ef5beafa16041bcdd2937140afebd485296cd54f7348ecd5a4d035c09759608de467a7ac0eb58753d0242df873c305e8bffad2454aa48f44480f15efae1cacd0" + }, + "length": 28 + } + }, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/2.0.0/role2.json b/tests/repository_data/TAP 14/2.0.0/role2.json new file mode 100644 index 0000000000..9c49e16570 --- /dev/null +++ b/tests/repository_data/TAP 14/2.0.0/role2.json @@ -0,0 +1,15 @@ +{ + "signatures": [ + { + "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", + "sig": "75b196a224fd200e46e738b1216b3316c5384f61083872f8d14b8b0a378b2344e64b1a6f1a89a711206a66a0b199d65ac0e30fe15ddbc4de89fa8ff645f99403" + } + ], + "signed": { + "_type": "targets", + "expires": "2030-01-01T00:00:00Z", + "spec_version": "1.0.0", + "targets": {}, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/2.0.0/root.json b/tests/repository_data/TAP 14/2.0.0/root.json new file mode 100644 index 0000000000..25595b3f38 --- /dev/null +++ b/tests/repository_data/TAP 14/2.0.0/root.json @@ -0,0 +1,87 @@ +{ + "signatures": [ + { + "keyid": "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb", + "sig": "a337d6375fedd2eabfcd6c2ef6c8a9c3bb85dc5a857715f6a6bd41123e7670c4972d8548bcd7248154f3d864bf25f1823af59d74c459f41ea09a02db057ca1245612ebbdb97e782c501dc3e094f7fa8aa1402b03c6ed0635f565e2a26f9f543a89237e15a2faf0c267e2b34c3c38f2a43a28ddcdaf8308a12ead8c6dc47d1b762de313e9ddda8cc5bc25aea1b69d0e5b9199ca02f5dda48c3bff615fd12a7136d00634b9abc6e75c3256106c4d6f12e6c43f6195071355b2857bbe377ce028619b58837696b805040ce144b393d50a472531f430fadfb68d3081b6a8b5e49337e328c9a0a3f11e80b0bc8eb2dc6e78d1451dd857e6e6e6363c3fd14c590aa95e083c9bfc77724d78af86eb7a7ef635eeddaa353030c79f66b3ba9ea11fab456cfe896a826fdfb50a43cd444f762821aada9bcd7b022c0ee85b8768f960343d5a1d3d76374cc0ac9e12a500de0bf5d48569e5398cadadadab045931c398e3bcb6cec88af2437ba91959f956079cbed159fed3938016e6c3b5e446131f81cc5981" + } + ], + "signed": { + "_type": "root", + "consistent_snapshot": false, + "expires": "2030-01-01T00:00:00Z", + "keys": { + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "rsa", + "keyval": { + "public": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0GjPoVrjS9eCqzoQ8VRe\nPkC0cI6ktiEgqPfHESFzyxyjC490Cuy19nuxPcJuZfN64MC48oOkR+W2mq4pM51i\nxmdG5xjvNOBRkJ5wUCc8fDCltMUTBlqt9y5eLsf/4/EoBU+zC4SW1iPU++mCsity\nfQQ7U6LOn3EYCyrkH51hZ/dvKC4o9TPYMVxNecJ3CL1q02Q145JlyjBTuM3Xdqsa\nndTHoXSRPmmzgB/1dL/c4QjMnCowrKW06mFLq9RAYGIaJWfM/0CbrOJpVDkATmEc\nMdpGJYDfW/sRQvRdlHNPo24ZW7vkQUCqdRxvnTWkK5U81y7RtjLt1yskbWXBIbOV\nz94GXsgyzANyCT9qRjHXDDz2mkLq+9I2iKtEqaEePcWRu3H6RLahpM/TxFzw684Y\nR47weXdDecPNxWyiWiyMGStRFP4Cg9trcwAGnEm1w8R2ggmWphznCd5dXGhPNjfA\na82yNFY8ubnOUVJOf0nXGg3Edw9iY3xyjJb2+nrsk5f3AgMBAAE=\n-----END PUBLIC KEY-----" + }, + "scheme": "rsassa-pss-sha256" + }, + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "edcd0a32a07dce33f7c7873aaffbff36d20ea30787574ead335eefd337e4dacd" + }, + "scheme": "ed25519" + }, + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "89f28bd4ede5ec3786ab923fd154f39588d20881903e69c7b08fb504c6750815" + }, + "scheme": "ed25519" + }, + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "82ccf6ac47298ff43bfa0cd639868894e305a99c723ff0515ae2e9856eb5bbf4" + }, + "scheme": "ed25519" + } + }, + "roles": { + "root": { + "keyids": [ + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb" + ], + "threshold": 1 + }, + "snapshot": { + "keyids": [ + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d" + ], + "threshold": 1 + }, + "targets": { + "keyids": [ + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093" + ], + "threshold": 1 + }, + "timestamp": { + "keyids": [ + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758" + ], + "threshold": 1 + } + }, + "spec_version": "2.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/2.0.0/snapshot.json b/tests/repository_data/TAP 14/2.0.0/snapshot.json new file mode 100644 index 0000000000..51aa78a5a6 --- /dev/null +++ b/tests/repository_data/TAP 14/2.0.0/snapshot.json @@ -0,0 +1,25 @@ +{ + "signatures": [ + { + "keyid": "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d", + "sig": "085672c70dffe26610e58542ee552843633cfed973abdad94c56138dbf0cd991644f2d3f27e4dda3098e08ab676e7f52627b587947ae69db1012d59a6da18e0c" + } + ], + "signed": { + "_type": "snapshot", + "expires": "2030-01-01T00:00:00Z", + "meta": { + "role1.json": { + "version": 1 + }, + "role2.json": { + "version": 1 + }, + "targets.json": { + "version": 1 + } + }, + "spec_version": "2.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/2.0.0/targets.json b/tests/repository_data/TAP 14/2.0.0/targets.json new file mode 100644 index 0000000000..9517c048d0 --- /dev/null +++ b/tests/repository_data/TAP 14/2.0.0/targets.json @@ -0,0 +1,61 @@ +{ + "signatures": [ + { + "keyid": "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093", + "sig": "d65f8db0c1a8f0976552b9742bbb393f24a5fa5eaf145c37aee047236c79dd0b83cfbb8b49fa7803689dfe0031dcf22c4d006b593acac07d69093b9b81722c08" + } + ], + "signed": { + "_type": "targets", + "delegations": { + "keys": { + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "fcf224e55fa226056adf113ef1eb3d55e308b75b321c8c8316999d8c4fd9e0d9" + }, + "scheme": "ed25519" + } + }, + "roles": [ + { + "keyids": [ + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a" + ], + "name": "role1", + "paths": [ + "file3.txt" + ], + "terminating": false, + "threshold": 1 + } + ] + }, + "expires": "2030-01-01T00:00:00Z", + "spec_version": "2.0.0", + "targets": { + "file1.txt": { + "custom": { + "file_permissions": "0644" + }, + "hashes": { + "sha256": "65b8c67f51c993d898250f40aa57a317d854900b3a04895464313e48785440da", + "sha512": "467430a68afae8e9f9c0771ea5d78bf0b3a0d79a2d3d3b40c69fde4dd42c461448aef76fcef4f5284931a1ffd0ac096d138ba3a0d6ca83fa8d7285a47a296f77" + }, + "length": 31 + }, + "file2.txt": { + "hashes": { + "sha256": "452ce8308500d83ef44248d8e6062359211992fd837ea9e370e561efb1a4ca99", + "sha512": "052b49a21e03606b28942db69aa597530fe52d47ee3d748ba65afcd14b857738e36bc1714c4f4adde46c3e683548552fe5c96722e0e0da3acd9050c2524902d8" + }, + "length": 39 + } + }, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/2.0.0/timestamp.json b/tests/repository_data/TAP 14/2.0.0/timestamp.json new file mode 100644 index 0000000000..9d38e7c7ed --- /dev/null +++ b/tests/repository_data/TAP 14/2.0.0/timestamp.json @@ -0,0 +1,23 @@ +{ + "signatures": [ + { + "keyid": "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758", + "sig": "de0e16920f87bf5500cc65736488ac17e09788cce808f6a4e85eb9e4e478a312b4c1a2d7723af56f7bfb1df533c67d8c93b6f49d39eabe7fae391a08e1f72f01" + } + ], + "signed": { + "_type": "timestamp", + "expires": "2030-01-01T00:00:00Z", + "meta": { + "snapshot.json": { + "hashes": { + "sha256": "8f88e2ba48b412c3843e9bb26e1b6f8fc9e98aceb0fbaa97ba37b4c98717d7ab" + }, + "length": 515, + "version": 1 + } + }, + "spec_version": "2.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/role1.json b/tests/repository_data/TAP 14/role1.json new file mode 100644 index 0000000000..66ec049d73 --- /dev/null +++ b/tests/repository_data/TAP 14/role1.json @@ -0,0 +1,49 @@ +{ + "signatures": [ + { + "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", + "sig": "9408b46569e622a46f1d35d9fa3c10e17a9285631ced4f2c9c2bba2c2842413fcb796db4e81d6f988fc056c21c407fdc3c10441592cf1e837e088f2e2dfd5403" + } + ], + "signed": { + "_type": "targets", + "delegations": { + "keys": { + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "fcf224e55fa226056adf113ef1eb3d55e308b75b321c8c8316999d8c4fd9e0d9" + }, + "scheme": "ed25519" + } + }, + "roles": [ + { + "keyids": [ + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a" + ], + "name": "role2", + "paths": [], + "terminating": false, + "threshold": 1 + } + ] + }, + "expires": "2030-01-01T00:00:00Z", + "spec_version": "2.0.0", + "targets": { + "file3.txt": { + "hashes": { + "sha256": "141f740f53781d1ca54b8a50af22cbf74e44c21a998fa2a8a05aaac2c002886b", + "sha512": "ef5beafa16041bcdd2937140afebd485296cd54f7348ecd5a4d035c09759608de467a7ac0eb58753d0242df873c305e8bffad2454aa48f44480f15efae1cacd0" + }, + "length": 28 + } + }, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/role2.json b/tests/repository_data/TAP 14/role2.json new file mode 100644 index 0000000000..252f2aa88d --- /dev/null +++ b/tests/repository_data/TAP 14/role2.json @@ -0,0 +1,15 @@ +{ + "signatures": [ + { + "keyid": "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a", + "sig": "75b196a224fd200e46e738b1216b3316c5384f61083872f8d14b8b0a378b2344e64b1a6f1a89a711206a66a0b199d65ac0e30fe15ddbc4de89fa8ff645f99403" + } + ], + "signed": { + "_type": "targets", + "expires": "2030-01-01T00:00:00Z", + "spec_version": "2.0.0", + "targets": {}, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/root.json b/tests/repository_data/TAP 14/root.json new file mode 100644 index 0000000000..214d8db01b --- /dev/null +++ b/tests/repository_data/TAP 14/root.json @@ -0,0 +1,87 @@ +{ + "signatures": [ + { + "keyid": "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb", + "sig": "a337d6375fedd2eabfcd6c2ef6c8a9c3bb85dc5a857715f6a6bd41123e7670c4972d8548bcd7248154f3d864bf25f1823af59d74c459f41ea09a02db057ca1245612ebbdb97e782c501dc3e094f7fa8aa1402b03c6ed0635f565e2a26f9f543a89237e15a2faf0c267e2b34c3c38f2a43a28ddcdaf8308a12ead8c6dc47d1b762de313e9ddda8cc5bc25aea1b69d0e5b9199ca02f5dda48c3bff615fd12a7136d00634b9abc6e75c3256106c4d6f12e6c43f6195071355b2857bbe377ce028619b58837696b805040ce144b393d50a472531f430fadfb68d3081b6a8b5e49337e328c9a0a3f11e80b0bc8eb2dc6e78d1451dd857e6e6e6363c3fd14c590aa95e083c9bfc77724d78af86eb7a7ef635eeddaa353030c79f66b3ba9ea11fab456cfe896a826fdfb50a43cd444f762821aada9bcd7b022c0ee85b8768f960343d5a1d3d76374cc0ac9e12a500de0bf5d48569e5398cadadadab045931c398e3bcb6cec88af2437ba91959f956079cbed159fed3938016e6c3b5e446131f81cc5981" + } + ], + "signed": { + "_type": "root", + "consistent_snapshot": false, + "expires": "2030-01-01T00:00:00Z", + "keys": { + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "rsa", + "keyval": { + "public": "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0GjPoVrjS9eCqzoQ8VRe\nPkC0cI6ktiEgqPfHESFzyxyjC490Cuy19nuxPcJuZfN64MC48oOkR+W2mq4pM51i\nxmdG5xjvNOBRkJ5wUCc8fDCltMUTBlqt9y5eLsf/4/EoBU+zC4SW1iPU++mCsity\nfQQ7U6LOn3EYCyrkH51hZ/dvKC4o9TPYMVxNecJ3CL1q02Q145JlyjBTuM3Xdqsa\nndTHoXSRPmmzgB/1dL/c4QjMnCowrKW06mFLq9RAYGIaJWfM/0CbrOJpVDkATmEc\nMdpGJYDfW/sRQvRdlHNPo24ZW7vkQUCqdRxvnTWkK5U81y7RtjLt1yskbWXBIbOV\nz94GXsgyzANyCT9qRjHXDDz2mkLq+9I2iKtEqaEePcWRu3H6RLahpM/TxFzw684Y\nR47weXdDecPNxWyiWiyMGStRFP4Cg9trcwAGnEm1w8R2ggmWphznCd5dXGhPNjfA\na82yNFY8ubnOUVJOf0nXGg3Edw9iY3xyjJb2+nrsk5f3AgMBAAE=\n-----END PUBLIC KEY-----" + }, + "scheme": "rsassa-pss-sha256" + }, + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "edcd0a32a07dce33f7c7873aaffbff36d20ea30787574ead335eefd337e4dacd" + }, + "scheme": "ed25519" + }, + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "89f28bd4ede5ec3786ab923fd154f39588d20881903e69c7b08fb504c6750815" + }, + "scheme": "ed25519" + }, + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "82ccf6ac47298ff43bfa0cd639868894e305a99c723ff0515ae2e9856eb5bbf4" + }, + "scheme": "ed25519" + } + }, + "roles": { + "root": { + "keyids": [ + "4e777de0d275f9d28588dd9a1606cc748e548f9e22b6795b7cb3f63f98035fcb" + ], + "threshold": 1 + }, + "snapshot": { + "keyids": [ + "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d" + ], + "threshold": 1 + }, + "targets": { + "keyids": [ + "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093" + ], + "threshold": 1 + }, + "timestamp": { + "keyids": [ + "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758" + ], + "threshold": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/snapshot.json b/tests/repository_data/TAP 14/snapshot.json new file mode 100644 index 0000000000..7c8c091a2e --- /dev/null +++ b/tests/repository_data/TAP 14/snapshot.json @@ -0,0 +1,25 @@ +{ + "signatures": [ + { + "keyid": "59a4df8af818e9ed7abe0764c0b47b4240952aa0d179b5b78346c470ac30278d", + "sig": "085672c70dffe26610e58542ee552843633cfed973abdad94c56138dbf0cd991644f2d3f27e4dda3098e08ab676e7f52627b587947ae69db1012d59a6da18e0c" + } + ], + "signed": { + "_type": "snapshot", + "expires": "2030-01-01T00:00:00Z", + "meta": { + "role1.json": { + "version": 1 + }, + "role2.json": { + "version": 1 + }, + "targets.json": { + "version": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/targets.json b/tests/repository_data/TAP 14/targets.json new file mode 100644 index 0000000000..8e21c269b4 --- /dev/null +++ b/tests/repository_data/TAP 14/targets.json @@ -0,0 +1,61 @@ +{ + "signatures": [ + { + "keyid": "65171251a9aff5a8b3143a813481cb07f6e0de4eb197c767837fe4491b739093", + "sig": "d65f8db0c1a8f0976552b9742bbb393f24a5fa5eaf145c37aee047236c79dd0b83cfbb8b49fa7803689dfe0031dcf22c4d006b593acac07d69093b9b81722c08" + } + ], + "signed": { + "_type": "targets", + "delegations": { + "keys": { + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a": { + "keyid_hash_algorithms": [ + "sha256", + "sha512" + ], + "keytype": "ed25519", + "keyval": { + "public": "fcf224e55fa226056adf113ef1eb3d55e308b75b321c8c8316999d8c4fd9e0d9" + }, + "scheme": "ed25519" + } + }, + "roles": [ + { + "keyids": [ + "c8022fa1e9b9cb239a6b362bbdffa9649e61ad2cb699d2e4bc4fdf7930a0e64a" + ], + "name": "role1", + "paths": [ + "file3.txt" + ], + "terminating": false, + "threshold": 1 + } + ] + }, + "expires": "2030-01-01T00:00:00Z", + "spec_version": "1.0.0", + "targets": { + "file1.txt": { + "custom": { + "file_permissions": "0644" + }, + "hashes": { + "sha256": "65b8c67f51c993d898250f40aa57a317d854900b3a04895464313e48785440da", + "sha512": "467430a68afae8e9f9c0771ea5d78bf0b3a0d79a2d3d3b40c69fde4dd42c461448aef76fcef4f5284931a1ffd0ac096d138ba3a0d6ca83fa8d7285a47a296f77" + }, + "length": 31 + }, + "file2.txt": { + "hashes": { + "sha256": "452ce8308500d83ef44248d8e6062359211992fd837ea9e370e561efb1a4ca99", + "sha512": "052b49a21e03606b28942db69aa597530fe52d47ee3d748ba65afcd14b857738e36bc1714c4f4adde46c3e683548552fe5c96722e0e0da3acd9050c2524902d8" + }, + "length": 39 + } + }, + "version": 1 + } +} \ No newline at end of file diff --git a/tests/repository_data/TAP 14/targets/file1.txt b/tests/repository_data/TAP 14/targets/file1.txt new file mode 100644 index 0000000000..7bf3499f13 --- /dev/null +++ b/tests/repository_data/TAP 14/targets/file1.txt @@ -0,0 +1 @@ +This is an example target file. \ No newline at end of file diff --git a/tests/repository_data/TAP 14/targets/file2.txt b/tests/repository_data/TAP 14/targets/file2.txt new file mode 100644 index 0000000000..606f18efc8 --- /dev/null +++ b/tests/repository_data/TAP 14/targets/file2.txt @@ -0,0 +1 @@ +This is an another example target file. \ No newline at end of file diff --git a/tests/repository_data/TAP 14/targets/file3.txt b/tests/repository_data/TAP 14/targets/file3.txt new file mode 100644 index 0000000000..60464604aa --- /dev/null +++ b/tests/repository_data/TAP 14/targets/file3.txt @@ -0,0 +1 @@ +This is role1's target file. \ No newline at end of file diff --git a/tests/repository_data/TAP 14/timestamp.json b/tests/repository_data/TAP 14/timestamp.json new file mode 100644 index 0000000000..9a0daf078b --- /dev/null +++ b/tests/repository_data/TAP 14/timestamp.json @@ -0,0 +1,23 @@ +{ + "signatures": [ + { + "keyid": "8a1c4a3ac2d515dec982ba9910c5fd79b91ae57f625b9cff25d06bf0a61c1758", + "sig": "de0e16920f87bf5500cc65736488ac17e09788cce808f6a4e85eb9e4e478a312b4c1a2d7723af56f7bfb1df533c67d8c93b6f49d39eabe7fae391a08e1f72f01" + } + ], + "signed": { + "_type": "timestamp", + "expires": "2030-01-01T00:00:00Z", + "meta": { + "snapshot.json": { + "hashes": { + "sha256": "8f88e2ba48b412c3843e9bb26e1b6f8fc9e98aceb0fbaa97ba37b4c98717d7ab" + }, + "length": 515, + "version": 1 + } + }, + "spec_version": "1.0.0", + "version": 1 + } +} \ No newline at end of file From df46e3860e22391fe2d6814344f23264c4b966fb Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Sun, 26 Jun 2022 22:24:36 +0530 Subject: [PATCH 06/14] Updated test_updater_ng.py file Added the test case which checks for the TAP 14 folder Signed-off-by: Abhisman Sarkar --- tests/test_updater_ng.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_updater_ng.py b/tests/test_updater_ng.py index c87a8fdc74..db37b6a88c 100644 --- a/tests/test_updater_ng.py +++ b/tests/test_updater_ng.py @@ -326,6 +326,16 @@ def test_non_existing_target_file(self) -> None: with self.assertRaises(exceptions.DownloadHTTPError): self.updater.download_target(info) + # test case to check for the TAP 14 folder + def test_check_folder_tap14(self) -> None: + # Creating the parent folder for the TAP 14 folder + original_repository_files = os.path.join( + utils.TESTS_DIR, "repository_data" + ) + #Adding the TAP 14 folder to the file path + tap_14 = os.path.join( + original_repository_files, "TAP 14") + self.assertTrue(os.path.isdir(tap_14)) if __name__ == "__main__": utils.configure_test_logging(sys.argv) From 0f5094540c47fb72cbdd607f4a46348fb26cb15f Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Mon, 4 Jul 2022 11:37:28 +0530 Subject: [PATCH 07/14] Updated the test_updater_ng.py file Added a test function that check the contents inside the TAP 14 folder. Signed-off-by: Abhisman Sarkar --- tests/test_updater_ng.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/test_updater_ng.py b/tests/test_updater_ng.py index db37b6a88c..be085d676c 100644 --- a/tests/test_updater_ng.py +++ b/tests/test_updater_ng.py @@ -79,6 +79,8 @@ def setUp(self) -> None: "metadata", "current", ) + # Adding the TAP14 folder + original_tap14 = os.path.join(original_repository_files, "TAP 14") # Save references to the often-needed client repository directories. # Test cases need these references to access metadata and target files. @@ -87,12 +89,16 @@ def setUp(self) -> None: ) self.keystore_directory = os.path.join(self.tmp_test_dir, "keystore") self.client_directory = os.path.join(self.tmp_test_dir, "client") + # Adding the TAP14 folder + self.tap14_directory = os.path.join(self.tmp_test_dir, "TAP 14") # Copy the original 'repository', 'client', and 'keystore' directories # to the temporary repository the test cases can use. shutil.copytree(original_repository, self.repository_directory) shutil.copytree(original_client, self.client_directory) shutil.copytree(original_keystore, self.keystore_directory) + # Copying over the TAP 14 folder + shutil.copytree(original_tap14, self.tap14_directory) # 'path/to/tmp/repository' -> 'localhost:8001/tmp/repository'. repository_basepath = self.repository_directory[len(os.getcwd()) :] @@ -329,13 +335,18 @@ def test_non_existing_target_file(self) -> None: # test case to check for the TAP 14 folder def test_check_folder_tap14(self) -> None: # Creating the parent folder for the TAP 14 folder - original_repository_files = os.path.join( - utils.TESTS_DIR, "repository_data" - ) - #Adding the TAP 14 folder to the file path - tap_14 = os.path.join( - original_repository_files, "TAP 14") - self.assertTrue(os.path.isdir(tap_14)) + self.assertTrue(os.path.isdir(self.tap14_directory)) + + def test_check_tap14_contents(self) -> None: + # Checking specific files inside TAP 14 + filenames = ["targets.json","root.json"] + for file in filenames: + self.assertTrue(os.path.isfile(os.path.join(self.tap14_directory, file))) + + #Checking specific folders inside TAP 14 + foldernames = ["targets","1.0.0"] + for folder in foldernames: + self.assertTrue(os.path.isdir(os.path.join(self.tap14_directory, folder))) if __name__ == "__main__": utils.configure_test_logging(sys.argv) From 6d82835da48f4162a7deccac1ba8ac420ca3e91f Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Wed, 6 Jul 2022 11:22:22 +0530 Subject: [PATCH 08/14] Updated updater.py Added a function to select specification version folder to download metadata from Signed-off-by: Abhisman Sarkar --- tuf/ngclient/updater.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tuf/ngclient/updater.py b/tuf/ngclient/updater.py index 7a5b2c2559..d8f841a2ec 100644 --- a/tuf/ngclient/updater.py +++ b/tuf/ngclient/updater.py @@ -259,10 +259,10 @@ def download_target( def _download_metadata( self, rolename: str, length: int, version: Optional[int] = None - ) -> bytes: + ) -> bytes: # ADD ANOTHER VARIABLE FOR SPECIFICATION VERSION """Download a metadata file and return it as bytes""" - encoded_name = parse.quote(rolename, "") - if version is None: + encoded_name = parse.quote(rolename, "") + if version is None: # THIS IS SNAPSHOT VERSION !! url = f"{self._metadata_base_url}{encoded_name}.json" else: url = f"{self._metadata_base_url}{version}.{encoded_name}.json" @@ -471,6 +471,19 @@ def _preorder_depth_first_walk( # If this point is reached then target is not found, return None return None + def _tap14_implementation(self, folder:str) -> None: + # Downloading all metadata inside the specified folder + + path = f"{BASE_URL}/repository_data/TAP 14" # File path to download from + path = os.path.join(path,folder) # Add the folder to the path + + # I'll need to know exactly how the repository stores the metadata for me to know + # the file path I have to download from. + + files = next(os.walk(path))[2] # Get all the files inside the list + for file in files: + if file.endswith(".json"): + self._download_metadata(file) def _ensure_trailing_slash(url: str) -> str: """Return url guaranteed to end in a slash""" From e77d93e446dfa7ee90cace20eff22c24fcb69724 Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Sun, 7 Aug 2022 10:19:43 +0530 Subject: [PATCH 09/14] New client updation logic along with tests. Also some test file changes Added the logic for the new client update process inside tuf/ngclient/updater.py. Added test functions for the new process inside tests/test_updater_ng.py. Also made changes to some test files. Signed-off-by: Abhisman Sarkar --- tests/repository_data/TAP 14/1.0.0/role1.json | 2 +- tests/repository_data/TAP 14/1.0.0/role2.json | 2 +- tests/repository_data/TAP 14/role1.json | 2 +- tests/repository_data/TAP 14/role2.json | 2 +- tests/test_updater_ng.py | 25 +++++- tuf/ngclient/_internal/requests_fetcher.py | 14 +++ tuf/ngclient/fetcher.py | 5 ++ tuf/ngclient/updater.py | 85 ++++++++++++++++--- 8 files changed, 121 insertions(+), 16 deletions(-) diff --git a/tests/repository_data/TAP 14/1.0.0/role1.json b/tests/repository_data/TAP 14/1.0.0/role1.json index 66ec049d73..0ac4687e77 100644 --- a/tests/repository_data/TAP 14/1.0.0/role1.json +++ b/tests/repository_data/TAP 14/1.0.0/role1.json @@ -34,7 +34,7 @@ ] }, "expires": "2030-01-01T00:00:00Z", - "spec_version": "2.0.0", + "spec_version": "1.0.0", "targets": { "file3.txt": { "hashes": { diff --git a/tests/repository_data/TAP 14/1.0.0/role2.json b/tests/repository_data/TAP 14/1.0.0/role2.json index 252f2aa88d..9c49e16570 100644 --- a/tests/repository_data/TAP 14/1.0.0/role2.json +++ b/tests/repository_data/TAP 14/1.0.0/role2.json @@ -8,7 +8,7 @@ "signed": { "_type": "targets", "expires": "2030-01-01T00:00:00Z", - "spec_version": "2.0.0", + "spec_version": "1.0.0", "targets": {}, "version": 1 } diff --git a/tests/repository_data/TAP 14/role1.json b/tests/repository_data/TAP 14/role1.json index 66ec049d73..0ac4687e77 100644 --- a/tests/repository_data/TAP 14/role1.json +++ b/tests/repository_data/TAP 14/role1.json @@ -34,7 +34,7 @@ ] }, "expires": "2030-01-01T00:00:00Z", - "spec_version": "2.0.0", + "spec_version": "1.0.0", "targets": { "file3.txt": { "hashes": { diff --git a/tests/repository_data/TAP 14/role2.json b/tests/repository_data/TAP 14/role2.json index 252f2aa88d..9c49e16570 100644 --- a/tests/repository_data/TAP 14/role2.json +++ b/tests/repository_data/TAP 14/role2.json @@ -8,7 +8,7 @@ "signed": { "_type": "targets", "expires": "2030-01-01T00:00:00Z", - "spec_version": "2.0.0", + "spec_version": "1.0.0", "targets": {}, "version": 1 } diff --git a/tests/test_updater_ng.py b/tests/test_updater_ng.py index be085d676c..97d81af012 100644 --- a/tests/test_updater_ng.py +++ b/tests/test_updater_ng.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: MIT OR Apache-2.0 """Test Updater class -""" +""" import logging import os @@ -348,6 +348,29 @@ def test_check_tap14_contents(self) -> None: for folder in foldernames: self.assertTrue(os.path.isdir(os.path.join(self.tap14_directory, folder))) + def test_get_spec_version1(self) -> None: + #This uses the default SUPPORTED_VERSIONS variable from updater.py + with self.assertRaises(exceptions.DownloadError): + self.updater._get_spec_version(["1","2","3"],"4",ngclient.updater.SUPPORTED_VERSIONS) + + self.assertEqual(self.updater._get_spec_version(["1","2","3"],"3",ngclient.updater.SUPPORTED_VERSIONS), "3") + + def test_get_spec_version2(self) -> None: + #Checks with different values + with self.assertRaises(exceptions.DownloadError): #Checks under point 2 + self.updater._get_spec_version(["3","5","6"],"7",["1","2","3","4"]) + + self.assertEqual(self.updater._get_spec_version(["3","5","6"],"3",["1","2","3","4"]), "3") + self.assertEqual(self.updater._get_spec_version(["1","2","3"],"3",["3","5","6"]), "3") + + with self.assertRaises(exceptions.DownloadError): #Checks under point 3 + self.updater._get_spec_version(["3","5","6"],"3",["1","2","4"]) + + # TODO Testing logging functionality. + #with self.assertLogs(ngclient.updater.__name__) as cm: + # logging.getLogger('foo').info('first message') + # self.updater._get_spec_version(["3","5","6"],"3",["1","2","3","4"]) + if __name__ == "__main__": utils.configure_test_logging(sys.argv) unittest.main() diff --git a/tuf/ngclient/_internal/requests_fetcher.py b/tuf/ngclient/_internal/requests_fetcher.py index 07562791f3..b485d85962 100644 --- a/tuf/ngclient/_internal/requests_fetcher.py +++ b/tuf/ngclient/_internal/requests_fetcher.py @@ -48,6 +48,20 @@ def __init__(self) -> None: # Default settings self.socket_timeout: int = 4 # seconds self.chunk_size: int = 400000 # bytes + + def _look(self, url: str) -> str: + """Function used for checking if a certain file exists""" + + response = requests.head(url) + + try: + response.raise_for_status() + except requests.HTTPError as e: + response.close() + status = e.response.status_code + raise exceptions.DownloadHTTPError(str(e), status) + + return response def _fetch(self, url: str) -> Iterator[bytes]: """Fetches the contents of HTTP/HTTPS url from a remote server diff --git a/tuf/ngclient/fetcher.py b/tuf/ngclient/fetcher.py index f13c893420..ed0db8194b 100644 --- a/tuf/ngclient/fetcher.py +++ b/tuf/ngclient/fetcher.py @@ -30,6 +30,11 @@ class FetcherInterface: __metaclass__ = abc.ABCMeta + @abc.abstractmethod + def _look(self, url: str) -> str: + """Function used for checking if a certain file exists""" + raise NotImplementedError # pragma: no cover + @abc.abstractmethod def _fetch(self, url: str) -> Iterator[bytes]: """Fetches the contents of HTTP/HTTPS ``url`` from a remote server. diff --git a/tuf/ngclient/updater.py b/tuf/ngclient/updater.py index d8f841a2ec..1c56f5bfaa 100644 --- a/tuf/ngclient/updater.py +++ b/tuf/ngclient/updater.py @@ -37,11 +37,12 @@ import os import shutil import tempfile -from typing import Optional, Set +from typing import Optional, Set, List from urllib import parse from tuf.api import exceptions from tuf.api.metadata import ( + SPECIFICATION_VERSION, Metadata, Root, Snapshot, @@ -54,7 +55,7 @@ from tuf.ngclient.fetcher import FetcherInterface logger = logging.getLogger(__name__) - +SUPPORTED_VERSIONS = ["1","2","3"] class Updater: """Creates a new ``Updater`` instance and loads trusted root metadata. @@ -76,15 +77,16 @@ class Updater: RepositoryError: Local root.json is invalid """ - def __init__( - self, - metadata_dir: str, + def __init__( + self, + metadata_dir: str, metadata_base_url: str, target_dir: Optional[str] = None, target_base_url: Optional[str] = None, fetcher: Optional[FetcherInterface] = None, config: Optional[UpdaterConfig] = None, ): + self.spec_version = None #spec_version is the last used version by the client to get metadata self._dir = metadata_dir self._metadata_base_url = _ensure_trailing_slash(metadata_base_url) self.target_dir = target_dir @@ -123,11 +125,71 @@ def refresh(self) -> None: DownloadError: Download of a metadata file failed in some way """ + repository_versions = self._get_repository_versions() + + #Updating self.spec_version + self.spec_version = self._get_spec_version(repository_versions, self.spec_version, SUPPORTED_VERSIONS) + self._load_root() self._load_timestamp() self._load_snapshot() self._load_targets(Targets.type, Root.type) + def _get_repository_versions(self) -> List[str]: + """Returns a list of all the repository versions.""" + + encoded_name = parse.quote("root", "") + url = f"{self._metadata_base_url}{self.spec_version}{encoded_name}.json" + repository_versions = [] + + # Here we manually enter the list of all possible versions that might exist on the + # repository side and then we check for each. Not an optimal solution. + for i in ["1", "2", "3"]: + try: + response = self._fetcher._look(url.replace(self.spec_version, i)) #Can I call _look()? + if response.status_code == 200: + repository_versions.append(i) + except Exception as e: + #logger.debug(f"Could not get root metadata from {url.replace(self.spec_version, i)}") + continue + + # Acc to the TAP, repository metadata is supposed to be kept under a folder strucutre + # but that isn't being used here. So, that might be a way to go + + #repository_versions = ["3.0.0","4.0.0","5.0.0"] + + #repository_versions = [i[0] for i in repository_versions] + + #return repository_versions + return ["1","2","3"] + + def _get_spec_version(self, repository_versions: List[str], spec_version: str, supported_versions: List[str]) -> str: + """Returns the specification version to be used.""" + + # point 1 + latestrep_ver = max(repository_versions) # To be used for a later warning + + # point 2 + if spec_version: + if latestrep_ver < spec_version: + raise exceptions.DownloadError("The repository version is lower than the last used spec version") + + # point 3 + try: + spec_version = max(set(supported_versions) & set(repository_versions)) + except ValueError: + raise exceptions.DownloadError(f"""No matching specification version found. Found {repository_versions} in + repository and {supported_versions} in client.""") + # Common error case for point 4 and point 3 + + # point 5 + # Warning for client + if latestrep_ver > spec_version: + logger.warning("Not using the latest specification version available on the repository") + + # TODO use logger.warning or store and return the warning message in a variable? + return spec_version + def _generate_target_file_path(self, targetinfo: TargetFile) -> str: if self.target_dir is None: raise ValueError("target_dir must be set if filepath is not given") @@ -259,13 +321,15 @@ def download_target( def _download_metadata( self, rolename: str, length: int, version: Optional[int] = None - ) -> bytes: # ADD ANOTHER VARIABLE FOR SPECIFICATION VERSION + ) -> bytes: """Download a metadata file and return it as bytes""" encoded_name = parse.quote(rolename, "") + + self.spec_version += ".0.0" if version is None: # THIS IS SNAPSHOT VERSION !! - url = f"{self._metadata_base_url}{encoded_name}.json" + url = f"{self._metadata_base_url}{self.spec_version}{encoded_name}.json" else: - url = f"{self._metadata_base_url}{version}.{encoded_name}.json" + url = f"{self._metadata_base_url}{self.spec_version}{version}.{encoded_name}.json" return self._fetcher.download_bytes(url, length) def _load_local_metadata(self, rolename: str) -> bytes: @@ -471,14 +535,13 @@ def _preorder_depth_first_walk( # If this point is reached then target is not found, return None return None - def _tap14_implementation(self, folder:str) -> None: + def _download_directory(self, folder:str) -> None: # Downloading all metadata inside the specified folder path = f"{BASE_URL}/repository_data/TAP 14" # File path to download from path = os.path.join(path,folder) # Add the folder to the path - # I'll need to know exactly how the repository stores the metadata for me to know - # the file path I have to download from. + # Repository might be storing data in different formats. files = next(os.walk(path))[2] # Get all the files inside the list for file in files: From 47fbc2b91196f2be31afb845ce12699ee138a8fc Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Thu, 25 Aug 2022 00:38:09 +0530 Subject: [PATCH 10/14] Updated test functionality and code structure Worked upon adding better tests in test_updater_ng.py and worked on the code structure for updater.py Signed-off-by: Abhisman Sarkar --- tests/test_updater_ng.py | 76 ++++++++++++++------- tuf/ngclient/updater.py | 142 ++++++++++++++++++++++++--------------- 2 files changed, 138 insertions(+), 80 deletions(-) diff --git a/tests/test_updater_ng.py b/tests/test_updater_ng.py index 97d81af012..f8096fce0b 100644 --- a/tests/test_updater_ng.py +++ b/tests/test_updater_ng.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: MIT OR Apache-2.0 """Test Updater class -""" +""" import logging import os @@ -29,6 +29,7 @@ Targets, Timestamp, ) +from tuf.ngclient.updater import _get_spec_version logger = logging.getLogger(__name__) @@ -332,45 +333,70 @@ def test_non_existing_target_file(self) -> None: with self.assertRaises(exceptions.DownloadHTTPError): self.updater.download_target(info) + # TAP 14 tests ~ REMOVE COMMENT BEFORE THE NEXT COMMIT!! + # test case to check for the TAP 14 folder def test_check_folder_tap14(self) -> None: - # Creating the parent folder for the TAP 14 folder + # Creating the parent folder for the TAP 14 folder self.assertTrue(os.path.isdir(self.tap14_directory)) - def test_check_tap14_contents(self) -> None: + def test_check_tap14_contents(self) -> None: # Checking specific files inside TAP 14 - filenames = ["targets.json","root.json"] + filenames = ["targets.json", "root.json"] for file in filenames: - self.assertTrue(os.path.isfile(os.path.join(self.tap14_directory, file))) + self.assertTrue( + os.path.isfile(os.path.join(self.tap14_directory, file)) + ) - #Checking specific folders inside TAP 14 - foldernames = ["targets","1.0.0"] + # Checking specific folders inside TAP 14 + foldernames = ["targets", "1.0.0"] for folder in foldernames: - self.assertTrue(os.path.isdir(os.path.join(self.tap14_directory, folder))) + self.assertTrue( + os.path.isdir(os.path.join(self.tap14_directory, folder)) + ) def test_get_spec_version1(self) -> None: - #This uses the default SUPPORTED_VERSIONS variable from updater.py + # This uses the default SUPPORTED_VERSIONS variable from updater.py with self.assertRaises(exceptions.DownloadError): - self.updater._get_spec_version(["1","2","3"],"4",ngclient.updater.SUPPORTED_VERSIONS) - - self.assertEqual(self.updater._get_spec_version(["1","2","3"],"3",ngclient.updater.SUPPORTED_VERSIONS), "3") - + _get_spec_version( + ["1", "2", "3"], "4", ngclient.updater.SUPPORTED_VERSIONS + ) + + self.assertEqual( + _get_spec_version( + ["1", "2", "3"], "3", ngclient.updater.SUPPORTED_VERSIONS + ), + ("3", None), + ) + def test_get_spec_version2(self) -> None: - #Checks with different values - with self.assertRaises(exceptions.DownloadError): #Checks under point 2 - self.updater._get_spec_version(["3","5","6"],"7",["1","2","3","4"]) - - self.assertEqual(self.updater._get_spec_version(["3","5","6"],"3",["1","2","3","4"]), "3") - self.assertEqual(self.updater._get_spec_version(["1","2","3"],"3",["3","5","6"]), "3") - - with self.assertRaises(exceptions.DownloadError): #Checks under point 3 - self.updater._get_spec_version(["3","5","6"],"3",["1","2","4"]) - - # TODO Testing logging functionality. - #with self.assertLogs(ngclient.updater.__name__) as cm: + warningchecker = "Not using the latest specification version available on the repository" + # Checks with different values + with self.assertRaises(exceptions.DownloadError): + _get_spec_version(["3", "5", "6"], "7", ["1", "2", "3", "4"]) + + self.assertEqual( + _get_spec_version(["3", "5", "6"], "3", ["1", "2", "3", "4"]), + ("3", warningchecker), + ) + self.assertEqual( + _get_spec_version(["1", "2", "3"], "3", ["3", "5", "6"]), + ("3", None), + ) + self.assertEqual( + _get_spec_version(["8", "11", "13"], "12", ["8", "11", "12"]), + ("11", warningchecker), + ) + + with self.assertRaises(exceptions.DownloadError): + _get_spec_version(["3", "5", "6"], "3", ["1", "2", "4"]) + + # TODO Testing logging functionality. + # with self.assertLogs(ngclient.updater.__name__) as cm: # logging.getLogger('foo').info('first message') # self.updater._get_spec_version(["3","5","6"],"3",["1","2","3","4"]) + if __name__ == "__main__": utils.configure_test_logging(sys.argv) unittest.main() diff --git a/tuf/ngclient/updater.py b/tuf/ngclient/updater.py index 1c56f5bfaa..e2fc4c972f 100644 --- a/tuf/ngclient/updater.py +++ b/tuf/ngclient/updater.py @@ -55,7 +55,8 @@ from tuf.ngclient.fetcher import FetcherInterface logger = logging.getLogger(__name__) -SUPPORTED_VERSIONS = ["1","2","3"] +SUPPORTED_VERSIONS = ["1", "2", "3"] + class Updater: """Creates a new ``Updater`` instance and loads trusted root metadata. @@ -77,16 +78,16 @@ class Updater: RepositoryError: Local root.json is invalid """ - def __init__( - self, - metadata_dir: str, + def __init__( + self, + metadata_dir: str, metadata_base_url: str, target_dir: Optional[str] = None, target_base_url: Optional[str] = None, fetcher: Optional[FetcherInterface] = None, config: Optional[UpdaterConfig] = None, ): - self.spec_version = None #spec_version is the last used version by the client to get metadata + self.spec_version = None # spec_version is the last used version by the client to get metadata self._dir = metadata_dir self._metadata_base_url = _ensure_trailing_slash(metadata_base_url) self.target_dir = target_dir @@ -124,12 +125,20 @@ def refresh(self) -> None: RepositoryError: Metadata failed to verify in some way DownloadError: Download of a metadata file failed in some way """ - + # json.load() + # Load self.spec_version using self._load_local_metadata() here from disk + # Exception would be raised if spec_version is not found locally. Set to "1" in that case repository_versions = self._get_repository_versions() - - #Updating self.spec_version - self.spec_version = self._get_spec_version(repository_versions, self.spec_version, SUPPORTED_VERSIONS) + # Updating self.spec_version + specver_message = _get_spec_version( + repository_versions, self.spec_version, SUPPORTED_VERSIONS + ) + + if specver_message(1): + logger.warning(specver_message(1)) + self.spec_version = specver_message(0) + self._persist_metadata("spec_version", json.dumps(self.spec_version)) self._load_root() self._load_timestamp() self._load_snapshot() @@ -137,58 +146,33 @@ def refresh(self) -> None: def _get_repository_versions(self) -> List[str]: """Returns a list of all the repository versions.""" - + encoded_name = parse.quote("root", "") url = f"{self._metadata_base_url}{self.spec_version}{encoded_name}.json" repository_versions = [] - # Here we manually enter the list of all possible versions that might exist on the + # Here we manually enter the list of all possible versions that might exist on the # repository side and then we check for each. Not an optimal solution. for i in ["1", "2", "3"]: try: - response = self._fetcher._look(url.replace(self.spec_version, i)) #Can I call _look()? + response = self._fetcher._look( + url.replace(self.spec_version, i) + ) # Can I call _look()? if response.status_code == 200: repository_versions.append(i) except Exception as e: - #logger.debug(f"Could not get root metadata from {url.replace(self.spec_version, i)}") + # logger.debug(f"Could not get root metadata from {url.replace(self.spec_version, i)}") continue - + # Acc to the TAP, repository metadata is supposed to be kept under a folder strucutre # but that isn't being used here. So, that might be a way to go - #repository_versions = ["3.0.0","4.0.0","5.0.0"] - - #repository_versions = [i[0] for i in repository_versions] - - #return repository_versions - return ["1","2","3"] - - def _get_spec_version(self, repository_versions: List[str], spec_version: str, supported_versions: List[str]) -> str: - """Returns the specification version to be used.""" - - # point 1 - latestrep_ver = max(repository_versions) # To be used for a later warning - - # point 2 - if spec_version: - if latestrep_ver < spec_version: - raise exceptions.DownloadError("The repository version is lower than the last used spec version") - - # point 3 - try: - spec_version = max(set(supported_versions) & set(repository_versions)) - except ValueError: - raise exceptions.DownloadError(f"""No matching specification version found. Found {repository_versions} in - repository and {supported_versions} in client.""") - # Common error case for point 4 and point 3 - - # point 5 - # Warning for client - if latestrep_ver > spec_version: - logger.warning("Not using the latest specification version available on the repository") - - # TODO use logger.warning or store and return the warning message in a variable? - return spec_version + # repository_versions = ["3.0.0","4.0.0","5.0.0"] + + # repository_versions = [i[0] for i in repository_versions] + + # return repository_versions + return ["1", "2", "3"] def _generate_target_file_path(self, targetinfo: TargetFile) -> str: if self.target_dir is None: @@ -321,12 +305,12 @@ def download_target( def _download_metadata( self, rolename: str, length: int, version: Optional[int] = None - ) -> bytes: + ) -> bytes: """Download a metadata file and return it as bytes""" - encoded_name = parse.quote(rolename, "") + encoded_name = parse.quote(rolename, "") - self.spec_version += ".0.0" - if version is None: # THIS IS SNAPSHOT VERSION !! + self.spec_version += ".0.0" + if version is None: # THIS IS SNAPSHOT VERSION !! url = f"{self._metadata_base_url}{self.spec_version}{encoded_name}.json" else: url = f"{self._metadata_base_url}{self.spec_version}{version}.{encoded_name}.json" @@ -535,19 +519,67 @@ def _preorder_depth_first_walk( # If this point is reached then target is not found, return None return None - def _download_directory(self, folder:str) -> None: + def _download_directory(self, folder: str) -> None: # Downloading all metadata inside the specified folder - path = f"{BASE_URL}/repository_data/TAP 14" # File path to download from - path = os.path.join(path,folder) # Add the folder to the path + path = ( + f"{BASE_URL}/repository_data/TAP 14" # File path to download from + ) + path = os.path.join(path, folder) # Add the folder to the path # Repository might be storing data in different formats. - files = next(os.walk(path))[2] # Get all the files inside the list + files = next(os.walk(path))[2] # Get all the files inside the list for file in files: if file.endswith(".json"): self._download_metadata(file) + def _ensure_trailing_slash(url: str) -> str: """Return url guaranteed to end in a slash""" return url if url.endswith("/") else f"{url}/" + + +def _get_spec_version( + repository_versions: List[str], + spec_version: str, + supported_versions: List[str], +) -> str: + """Returns the specification version to be used.""" + + repository_versions = [int(i) for i in repository_versions] + supported_versions = [int(i) for i in supported_versions] + spec_version = int(spec_version) + + # The client determines the latest version available on the repository by looking + # for the directory with the largest version number. + latestrep_ver = max(repository_versions) + + # If the latest version on the repository is lower than the previous specification + # version the client used from this repository, the client should report an error + # and terminate the update. + if spec_version: + if latestrep_ver < spec_version: + raise exceptions.DownloadError( + "The repository version is lower than the last used spec version" + ) + + # If the latest version on the client is found on the repository or vice versa, the + # client will use this directory to download the metadata. + try: + spec_version = max(set(repository_versions) & set(supported_versions)) + except ValueError: + raise exceptions.DownloadError( + f"""No matching specification version found. Found {repository_versions} in + repository and {supported_versions} in client.""" + ) + # Checks for the highest matching version between the client and the repository + # and reports an error if no matching version is found. + + # If the latest version on the repository is higher than the client spec version, + # the client should report to the user that it is not using the most up to date version + warning = None + if latestrep_ver > spec_version: + warning = "Not using the latest specification version available on the repository" + + return (str(spec_version), warning) From 127bdbf270c62cb1a19641cabe0844038e2ce7d6 Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Mon, 29 Aug 2022 22:54:40 +0530 Subject: [PATCH 11/14] Updated updater.py Made changes to _get_repository_versions() to read the supported-versions file and also removed _look() from fetcher.py and requests_fetcher.py Signed-off-by: Abhisman Sarkar --- tuf/ngclient/_internal/requests_fetcher.py | 14 ---------- tuf/ngclient/fetcher.py | 5 ---- tuf/ngclient/updater.py | 32 ++++++---------------- 3 files changed, 8 insertions(+), 43 deletions(-) diff --git a/tuf/ngclient/_internal/requests_fetcher.py b/tuf/ngclient/_internal/requests_fetcher.py index b485d85962..07562791f3 100644 --- a/tuf/ngclient/_internal/requests_fetcher.py +++ b/tuf/ngclient/_internal/requests_fetcher.py @@ -48,20 +48,6 @@ def __init__(self) -> None: # Default settings self.socket_timeout: int = 4 # seconds self.chunk_size: int = 400000 # bytes - - def _look(self, url: str) -> str: - """Function used for checking if a certain file exists""" - - response = requests.head(url) - - try: - response.raise_for_status() - except requests.HTTPError as e: - response.close() - status = e.response.status_code - raise exceptions.DownloadHTTPError(str(e), status) - - return response def _fetch(self, url: str) -> Iterator[bytes]: """Fetches the contents of HTTP/HTTPS url from a remote server diff --git a/tuf/ngclient/fetcher.py b/tuf/ngclient/fetcher.py index ed0db8194b..f13c893420 100644 --- a/tuf/ngclient/fetcher.py +++ b/tuf/ngclient/fetcher.py @@ -30,11 +30,6 @@ class FetcherInterface: __metaclass__ = abc.ABCMeta - @abc.abstractmethod - def _look(self, url: str) -> str: - """Function used for checking if a certain file exists""" - raise NotImplementedError # pragma: no cover - @abc.abstractmethod def _fetch(self, url: str) -> Iterator[bytes]: """Fetches the contents of HTTP/HTTPS ``url`` from a remote server. diff --git a/tuf/ngclient/updater.py b/tuf/ngclient/updater.py index e2fc4c972f..d58fc13923 100644 --- a/tuf/ngclient/updater.py +++ b/tuf/ngclient/updater.py @@ -37,6 +37,7 @@ import os import shutil import tempfile +import json from typing import Optional, Set, List from urllib import parse @@ -139,6 +140,7 @@ def refresh(self) -> None: logger.warning(specver_message(1)) self.spec_version = specver_message(0) self._persist_metadata("spec_version", json.dumps(self.spec_version)) + self._load_root() self._load_timestamp() self._load_snapshot() @@ -147,32 +149,14 @@ def refresh(self) -> None: def _get_repository_versions(self) -> List[str]: """Returns a list of all the repository versions.""" - encoded_name = parse.quote("root", "") - url = f"{self._metadata_base_url}{self.spec_version}{encoded_name}.json" - repository_versions = [] - - # Here we manually enter the list of all possible versions that might exist on the - # repository side and then we check for each. Not an optimal solution. - for i in ["1", "2", "3"]: - try: - response = self._fetcher._look( - url.replace(self.spec_version, i) - ) # Can I call _look()? - if response.status_code == 200: - repository_versions.append(i) - except Exception as e: - # logger.debug(f"Could not get root metadata from {url.replace(self.spec_version, i)}") - continue - - # Acc to the TAP, repository metadata is supposed to be kept under a folder strucutre - # but that isn't being used here. So, that might be a way to go - - # repository_versions = ["3.0.0","4.0.0","5.0.0"] + url = f"{self._metadata_base_url}supported-versions.json" - # repository_versions = [i[0] for i in repository_versions] + with self._fetcher.download_file( + url, "length placeholder" + ) as target_file: + repository_versions = json.loads(target_file) - # return repository_versions - return ["1", "2", "3"] + return repository_versions["supported_versions"] def _generate_target_file_path(self, targetinfo: TargetFile) -> str: if self.target_dir is None: From 7c9660fd8637fe4c1199f2aa8edd9343f1602218 Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Fri, 2 Sep 2022 22:32:02 +0530 Subject: [PATCH 12/14] Worked on reviews Made changes to updater.py and config.py Signed-off-by: Abhisman Sarkar --- tuf/ngclient/config.py | 1 + tuf/ngclient/updater.py | 76 +++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/tuf/ngclient/config.py b/tuf/ngclient/config.py index e6213d0bed..9da831b5dd 100644 --- a/tuf/ngclient/config.py +++ b/tuf/ngclient/config.py @@ -28,6 +28,7 @@ class UpdaterConfig: max_root_rotations: int = 32 max_delegations: int = 32 + supported_versions_max_length: int = 1000 # bytes root_max_length: int = 512000 # bytes timestamp_max_length: int = 16384 # bytes snapshot_max_length: int = 2000000 # bytes diff --git a/tuf/ngclient/updater.py b/tuf/ngclient/updater.py index d58fc13923..54342aee09 100644 --- a/tuf/ngclient/updater.py +++ b/tuf/ngclient/updater.py @@ -38,7 +38,7 @@ import shutil import tempfile import json -from typing import Optional, Set, List +from typing import Optional, Set, List, Tuple from urllib import parse from tuf.api import exceptions @@ -56,7 +56,7 @@ from tuf.ngclient.fetcher import FetcherInterface logger = logging.getLogger(__name__) -SUPPORTED_VERSIONS = ["1", "2", "3"] +SUPPORTED_VERSIONS = [SPECIFICATION_VERSION] class Updater: @@ -88,7 +88,7 @@ def __init__( fetcher: Optional[FetcherInterface] = None, config: Optional[UpdaterConfig] = None, ): - self.spec_version = None # spec_version is the last used version by the client to get metadata + self._spec_version = None # spec_version is the last used version by the client to get metadata self._dir = metadata_dir self._metadata_base_url = _ensure_trailing_slash(metadata_base_url) self.target_dir = target_dir @@ -132,14 +132,14 @@ def refresh(self) -> None: repository_versions = self._get_repository_versions() # Updating self.spec_version - specver_message = _get_spec_version( - repository_versions, self.spec_version, SUPPORTED_VERSIONS + spec_version, message = _get_spec_version( + repository_versions, self._spec_version, SUPPORTED_VERSIONS ) - if specver_message(1): - logger.warning(specver_message(1)) - self.spec_version = specver_message(0) - self._persist_metadata("spec_version", json.dumps(self.spec_version)) + if message: + logger.warning(message) + self.spec_version = f"{spec_version}/" if spec_version is not None else "" + self._persist_metadata("spec_version", json.dumps(self._spec_version)) self._load_root() self._load_timestamp() @@ -151,8 +151,8 @@ def _get_repository_versions(self) -> List[str]: url = f"{self._metadata_base_url}supported-versions.json" - with self._fetcher.download_file( - url, "length placeholder" + with self._fetcher.download_bytes( + url, self.config.supported_versions_max_length ) as target_file: repository_versions = json.loads(target_file) @@ -293,11 +293,10 @@ def _download_metadata( """Download a metadata file and return it as bytes""" encoded_name = parse.quote(rolename, "") - self.spec_version += ".0.0" if version is None: # THIS IS SNAPSHOT VERSION !! - url = f"{self._metadata_base_url}{self.spec_version}{encoded_name}.json" + url = f"{self._metadata_base_url}{self._spec_version}{encoded_name}.json" else: - url = f"{self._metadata_base_url}{self.spec_version}{version}.{encoded_name}.json" + url = f"{self._metadata_base_url}{self._spec_version}{version}.{encoded_name}.json" return self._fetcher.download_bytes(url, length) def _load_local_metadata(self, rolename: str) -> bytes: @@ -503,21 +502,6 @@ def _preorder_depth_first_walk( # If this point is reached then target is not found, return None return None - def _download_directory(self, folder: str) -> None: - # Downloading all metadata inside the specified folder - - path = ( - f"{BASE_URL}/repository_data/TAP 14" # File path to download from - ) - path = os.path.join(path, folder) # Add the folder to the path - - # Repository might be storing data in different formats. - - files = next(os.walk(path))[2] # Get all the files inside the list - for file in files: - if file.endswith(".json"): - self._download_metadata(file) - def _ensure_trailing_slash(url: str) -> str: """Return url guaranteed to end in a slash""" @@ -528,8 +512,17 @@ def _get_spec_version( repository_versions: List[str], spec_version: str, supported_versions: List[str], -) -> str: - """Returns the specification version to be used.""" +) -> Tuple[str, Optional[str]]: + """Returns the specification version to be used, following the rules of TAP-14 + and displays a warning if chosen spec_version is lower than the highest repository version. + + Raises: + ValueError: supported_versions, repository_version or spec_version contains an + invalid entry (not parseable as ``int()``) + RepositoryError: Latest repository version lower than the last used version from + this repository + RepositoryError: #TODO + """ repository_versions = [int(i) for i in repository_versions] supported_versions = [int(i) for i in supported_versions] @@ -537,33 +530,34 @@ def _get_spec_version( # The client determines the latest version available on the repository by looking # for the directory with the largest version number. - latestrep_ver = max(repository_versions) + latest_repo_version = max(repository_versions) # If the latest version on the repository is lower than the previous specification # version the client used from this repository, the client should report an error # and terminate the update. if spec_version: - if latestrep_ver < spec_version: - raise exceptions.DownloadError( - "The repository version is lower than the last used spec version" + if latest_repo_version < spec_version: + raise exceptions.RepositoryError( + f"The latest repository version ({latest_repo_version}) is lower than the last used spec version ({spec_version})." ) # If the latest version on the client is found on the repository or vice versa, the # client will use this directory to download the metadata. + # Checks for the highest matching version between the client and the repository + # and reports an error if no matching version is found. try: spec_version = max(set(repository_versions) & set(supported_versions)) except ValueError: - raise exceptions.DownloadError( - f"""No matching specification version found. Found {repository_versions} in - repository and {supported_versions} in client.""" + raise exceptions.RepositoryError( + f"No matching specification version found. Found {repository_versions} in" + f"repository and {supported_versions} in client." ) - # Checks for the highest matching version between the client and the repository - # and reports an error if no matching version is found. + # If the latest version on the repository is higher than the client spec version, # the client should report to the user that it is not using the most up to date version warning = None - if latestrep_ver > spec_version: + if latest_repo_version > spec_version: warning = "Not using the latest specification version available on the repository" return (str(spec_version), warning) From 70035696922f157468d79b81c550feb1bf75db57 Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Fri, 2 Sep 2022 22:38:29 +0530 Subject: [PATCH 13/14] Used the black formatter on updater.py Signed-off-by: Abhisman Sarkar --- tuf/ngclient/updater.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tuf/ngclient/updater.py b/tuf/ngclient/updater.py index 54342aee09..14810e3e3c 100644 --- a/tuf/ngclient/updater.py +++ b/tuf/ngclient/updater.py @@ -138,7 +138,9 @@ def refresh(self) -> None: if message: logger.warning(message) - self.spec_version = f"{spec_version}/" if spec_version is not None else "" + self.spec_version = ( + f"{spec_version}/" if spec_version is not None else "" + ) self._persist_metadata("spec_version", json.dumps(self._spec_version)) self._load_root() @@ -513,15 +515,15 @@ def _get_spec_version( spec_version: str, supported_versions: List[str], ) -> Tuple[str, Optional[str]]: - """Returns the specification version to be used, following the rules of TAP-14 + """Returns the specification version to be used, following the rules of TAP-14 and displays a warning if chosen spec_version is lower than the highest repository version. - + Raises: - ValueError: supported_versions, repository_version or spec_version contains an + ValueError: supported_versions, repository_version or spec_version contains an invalid entry (not parseable as ``int()``) RepositoryError: Latest repository version lower than the last used version from this repository - RepositoryError: #TODO + RepositoryError: No matching version found between supported_versions and repository_versions """ repository_versions = [int(i) for i in repository_versions] @@ -553,7 +555,6 @@ def _get_spec_version( f"repository and {supported_versions} in client." ) - # If the latest version on the repository is higher than the client spec version, # the client should report to the user that it is not using the most up to date version warning = None From 8071718802222b1ba4341e4ca7f17725b0a98dcf Mon Sep 17 00:00:00 2001 From: Abhisman Sarkar Date: Fri, 9 Sep 2022 09:52:53 +0530 Subject: [PATCH 14/14] Some more changes to updater.py and test_updater_ng.py Added some more changes adhering to the reviews. Also worked on cleaning the code in the test file. This is the last pull request as part of GSoC'22 Signed-off-by: Abhisman Sarkar --- tests/test_updater_ng.py | 84 +++++++++++++++++++++++++++++----------- tuf/ngclient/updater.py | 56 ++++++++++++++++++--------- 2 files changed, 99 insertions(+), 41 deletions(-) diff --git a/tests/test_updater_ng.py b/tests/test_updater_ng.py index f8096fce0b..9e540dc412 100644 --- a/tests/test_updater_ng.py +++ b/tests/test_updater_ng.py @@ -355,9 +355,13 @@ def test_check_tap14_contents(self) -> None: os.path.isdir(os.path.join(self.tap14_directory, folder)) ) - def test_get_spec_version1(self) -> None: - # This uses the default SUPPORTED_VERSIONS variable from updater.py - with self.assertRaises(exceptions.DownloadError): + def test_get_spec_version_supported(self) -> None: + """This uses the default SUPPORTED_VERSIONS variable from updater.py""" + + with self.assertRaises( + exceptions.RepositoryError, + msg="Latest repository version less than 4", + ): _get_spec_version( ["1", "2", "3"], "4", ngclient.updater.SUPPORTED_VERSIONS ) @@ -367,29 +371,65 @@ def test_get_spec_version1(self) -> None: ["1", "2", "3"], "3", ngclient.updater.SUPPORTED_VERSIONS ), ("3", None), + "3 is selected as the spec version and no warning ensues", ) - def test_get_spec_version2(self) -> None: + def test_get_spec_version(self) -> None: warningchecker = "Not using the latest specification version available on the repository" # Checks with different values - with self.assertRaises(exceptions.DownloadError): - _get_spec_version(["3", "5", "6"], "7", ["1", "2", "3", "4"]) - - self.assertEqual( - _get_spec_version(["3", "5", "6"], "3", ["1", "2", "3", "4"]), - ("3", warningchecker), - ) - self.assertEqual( - _get_spec_version(["1", "2", "3"], "3", ["3", "5", "6"]), - ("3", None), - ) - self.assertEqual( - _get_spec_version(["8", "11", "13"], "12", ["8", "11", "12"]), - ("11", warningchecker), - ) - - with self.assertRaises(exceptions.DownloadError): - _get_spec_version(["3", "5", "6"], "3", ["1", "2", "4"]) + test_cases = [ + ( + ["3", "5", "6"], + "7", + ["1", "2", "3", "4"], + ), # Latest repository version less than 7 + ( + ["3", "5", "6"], + "3", + ["1", "2", "4"], + ), # No common specification version between repository and client + ] + for repo_versions, spec_version, supported_versions in test_cases: + with self.assertRaises(exceptions.RepositoryError): + _get_spec_version( + repo_versions, spec_version, supported_versions + ) + + test_cases = [ + ( + ["3", "5", "6"], + "3", + ["1", "2", "3", "4"], + "3", + True, + ), # 3 is selected as the spec version but a warning ensues + ( + ["1", "2", "3"], + "3", + ["3", "5", "6"], + "3", + False, + ), # 3 is selected as the spec version and no warning ensues + ( + ["8", "11", "13"], + "12", + ["8", "11", "12"], + "11", + True, + ), # 11 is selected as the spec version but a warning ensues + ] + for ( + repo_versions, + spec_version, + supported_versions, + expected_version, + should_have_warning, + ) in test_cases: + actual_version, warning = _get_spec_version( + repo_versions, spec_version, supported_versions + ) + self.assertEqual(actual_version, expected_version) + self.assertEqual(bool(warning), should_have_warning) # TODO Testing logging functionality. # with self.assertLogs(ngclient.updater.__name__) as cm: diff --git a/tuf/ngclient/updater.py b/tuf/ngclient/updater.py index 14810e3e3c..0c0e957508 100644 --- a/tuf/ngclient/updater.py +++ b/tuf/ngclient/updater.py @@ -38,7 +38,7 @@ import shutil import tempfile import json -from typing import Optional, Set, List, Tuple +from typing import Optional, Set, List, Tuple, NewType from urllib import parse from tuf.api import exceptions @@ -126,9 +126,11 @@ def refresh(self) -> None: RepositoryError: Metadata failed to verify in some way DownloadError: Download of a metadata file failed in some way """ - # json.load() - # Load self.spec_version using self._load_local_metadata() here from disk - # Exception would be raised if spec_version is not found locally. Set to "1" in that case + try: + self._spec_version = self._load_local_metadata("spec_version") + except OSError: + self._spec_version = "1" + repository_versions = self._get_repository_versions() # Updating self.spec_version @@ -138,10 +140,14 @@ def refresh(self) -> None: if message: logger.warning(message) - self.spec_version = ( - f"{spec_version}/" if spec_version is not None else "" + self._spec_version = ( + f"{spec_version}/" + if spec_version is not None or spec_version == "1" + else "" + ) + self._persist_metadata( + "spec_version", json.dumps(self._spec_version) ) - self._persist_metadata("spec_version", json.dumps(self._spec_version)) self._load_root() self._load_timestamp() @@ -151,14 +157,18 @@ def refresh(self) -> None: def _get_repository_versions(self) -> List[str]: """Returns a list of all the repository versions.""" - url = f"{self._metadata_base_url}supported-versions.json" + try: + url = f"{self._metadata_base_url}supported-versions.json" - with self._fetcher.download_bytes( - url, self.config.supported_versions_max_length - ) as target_file: - repository_versions = json.loads(target_file) + with self._fetcher.download_bytes( + url, self.config.supported_versions_max_length + ) as target_file: + repository_versions = json.loads(target_file) + return repository_versions["supported_versions"] - return repository_versions["supported_versions"] + # If supported-versions.json is not found, then look through the root directory to find supported versions + except exceptions.DownloadHTTPError as e: + return ["1"] def _generate_target_file_path(self, targetinfo: TargetFile) -> str: if self.target_dir is None: @@ -295,6 +305,7 @@ def _download_metadata( """Download a metadata file and return it as bytes""" encoded_name = parse.quote(rolename, "") + # TODO Seperate URL for when snapshot-version.json doesn't exist if version is None: # THIS IS SNAPSHOT VERSION !! url = f"{self._metadata_base_url}{self._spec_version}{encoded_name}.json" else: @@ -525,6 +536,8 @@ def _get_spec_version( this repository RepositoryError: No matching version found between supported_versions and repository_versions """ + SpecificationVersion = NewType("SpecificationVersion", str) + WarningMessage = NewType("WarningMessage", str) repository_versions = [int(i) for i in repository_versions] supported_versions = [int(i) for i in supported_versions] @@ -543,10 +556,17 @@ def _get_spec_version( f"The latest repository version ({latest_repo_version}) is lower than the last used spec version ({spec_version})." ) - # If the latest version on the client is found on the repository or vice versa, the - # client will use this directory to download the metadata. - # Checks for the highest matching version between the client and the repository - # and reports an error if no matching version is found. + # If the latest version on the repository is equal to that of the client, it will use this directory to download metadata. + + # If the latest version pre-dates the client specification version, it may call functions from a previous client version + # to download the metadata. The client may support as many or as few versions as desired for the application. If the + # previous version is not available, the client shall report that an update can not be performed due to an old + # specification version on the repository. + + # If the latest version on the repository is higher than the client spec version, the client should report + # to the user that it is not using the most up to date version, and then perform the update with the directory + # that corresponds with the latest client specification version, if available. If no such directory exists, + # the client terminates the update. try: spec_version = max(set(repository_versions) & set(supported_versions)) except ValueError: @@ -555,8 +575,6 @@ def _get_spec_version( f"repository and {supported_versions} in client." ) - # If the latest version on the repository is higher than the client spec version, - # the client should report to the user that it is not using the most up to date version warning = None if latest_repo_version > spec_version: warning = "Not using the latest specification version available on the repository"