Skip to content

Commit c3a01bd

Browse files
Add TUF version number, and user agent
Merge branch 'trishankatdatadog/fix-for-https-proxies' of github.com:trishankatdatadog/tuf into trishankatdatadog/fix-for-https-proxies Signed-off-by: Trishank K Kuppusamy <trishank.kuppusamy@datadoghq.com>
2 parents d5ec2b8 + 1e97275 commit c3a01bd

File tree

9 files changed

+68
-82
lines changed

9 files changed

+68
-82
lines changed

ci-requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
securesystemslib[crypto,pynacl]
2+
six
3+
iso8601
14
coverage
25
coveralls
3-
iso8601
46
pylint
57
requests
6-
securesystemslib[crypto,pynacl]
7-
six

dev-requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
#
77
-e .
88
asn1crypto==0.24.0
9-
astroid==1.6.5 ; python_version < "3.0"
9+
astroid==1.6.5 ; python_version < "3.0" # pyup: ignore
1010
astroid==2.0.4 ; python_version >= "3.0"
1111
backports.functools-lru-cache==1.5
12-
bandit==1.4.0
12+
bandit==1.5.0
1313
cffi==1.11.5
1414
colorama==0.3.9
1515
configparser==3.5.0
16-
cryptography==2.3
16+
cryptography==2.3.1
1717
enum34==1.1.6
1818
gitdb2==2.0.4
1919
gitpython==2.1.11
@@ -28,7 +28,7 @@ pluggy==0.7.1
2828
py==1.5.4
2929
pycparser==2.18
3030
pylint==2.1.1 ; python_version >= "3.0"
31-
pylint==1.9.3 ; python_version < "3.0"
31+
pylint==1.9.3 ; python_version < "3.0" # pyup: ignore
3232
pynacl==1.2.1
3333
pyyaml==3.13
3434
requests==2.19.1

requirements.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# requirements.in for pip-compile.
22

3+
securesystemslib
34
cryptography
45
colorama
5-
iso8601
66
pynacl
7-
requests
8-
securesystemslib
97
six
8+
iso8601
9+
requests

requirements.txt

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ cffi==1.11.5 \
1717
--hash=sha256:1553d1e99f035ace1c0544050622b7bc963374a00c467edafac50ad7bd276aef \
1818
--hash=sha256:1b0493c091a1898f1136e3f4f991a784437fac3673780ff9de3bcf46c80b6b50 \
1919
--hash=sha256:2ba8a45822b7aee805ab49abfe7eec16b90587f7f26df20c71dd89e45a97076f \
20+
--hash=sha256:3bb6bd7266598f318063e584378b8e27c67de998a43362e8fce664c54ee52d30 \
2021
--hash=sha256:3c85641778460581c42924384f5e68076d724ceac0f267d66c757f7535069c93 \
2122
--hash=sha256:3eb6434197633b7748cea30bf0ba9f66727cdce45117a712b29a443943733257 \
23+
--hash=sha256:495c5c2d43bf6cebe0178eb3e88f9c4aa48d8934aa6e3cddb865c058da76756b \
2224
--hash=sha256:4c91af6e967c2015729d3e69c2e51d92f9898c330d6a851bf8f121236f3defd3 \
25+
--hash=sha256:57b2533356cb2d8fac1555815929f7f5f14d68ac77b085d2326b571310f34f6e \
2326
--hash=sha256:770f3782b31f50b68627e22f91cb182c48c47c02eb405fd689472aa7b7aa16dc \
2427
--hash=sha256:79f9b6f7c46ae1f8ded75f68cf8ad50e5729ed4d590c74840471fc2823457d04 \
2528
--hash=sha256:7a33145e04d44ce95bcd71e522b478d282ad0eafaf34fe1ec5bbd73e662f22b6 \
@@ -28,11 +31,13 @@ cffi==1.11.5 \
2831
--hash=sha256:95d5251e4b5ca00061f9d9f3d6fe537247e145a8524ae9fd30a2f8fbce993b5b \
2932
--hash=sha256:9d1d3e63a4afdc29bd76ce6aa9d58c771cd1599fbba8cf5057e7860b203710dd \
3033
--hash=sha256:a36c5c154f9d42ec176e6e620cb0dd275744aa1d804786a71ac37dc3661a5e95 \
34+
--hash=sha256:a6a5cb8809091ec9ac03edde9304b3ad82ad4466333432b16d78ef40e0cce0d5 \
3135
--hash=sha256:ae5e35a2c189d397b91034642cb0eab0e346f776ec2eb44a49a459e6615d6e2e \
3236
--hash=sha256:b0f7d4a3df8f06cf49f9f121bead236e328074de6449866515cea4907bbc63d6 \
3337
--hash=sha256:b75110fb114fa366b29a027d0c9be3709579602ae111ff61674d28c93606acca \
3438
--hash=sha256:ba5e697569f84b13640c9e193170e89c13c6244c24400fc57e88724ef610cd31 \
3539
--hash=sha256:be2a9b390f77fd7676d80bc3cdc4f8edb940d8c198ed2d8c0be1319018c778e1 \
40+
--hash=sha256:ca1bd81f40adc59011f58159e4aa6445fc585a32bb8ac9badf7a2c1aa23822f2 \
3641
--hash=sha256:d5d8555d9bfc3f02385c1c37e9f998e2011f0db4f90e250e5bc0c0a85a813085 \
3742
--hash=sha256:e55e22ac0a30023426564b1059b035973ec82186ddddbac867078435801c7801 \
3843
--hash=sha256:e90f17980e6ab0f3c2f3730e56d1fe9bcba1891eeea58966e89d352492cc74f4 \
@@ -48,26 +53,26 @@ chardet==3.0.4 \
4853
colorama==0.3.9 \
4954
--hash=sha256:463f8483208e921368c9f306094eb6f725c6ca42b0f97e313cb5d5512459feda \
5055
--hash=sha256:48eb22f4f8461b1df5734a074b57042430fb06e1d61bd1e11b078c0fe6d7a1f1
51-
cryptography==2.3 \
52-
--hash=sha256:21af753934f2f6d1a10fe8f4c0a64315af209ef6adeaee63ca349797d747d687 \
53-
--hash=sha256:27bb401a20a838d6d0ea380f08c6ead3ccd8c9d8a0232dc9adcc0e4994576a66 \
54-
--hash=sha256:29720c4253263cff9aea64585adbbe85013ba647f6e98367efff9db2d7193ded \
55-
--hash=sha256:2a35b7570d8f247889784010aac8b384fd2e4a47b33e15c4a60b45a7c1944120 \
56-
--hash=sha256:42c531a6a354407f42ee07fda5c2c0dc822cf6d52744949c182f2b295fbd4183 \
57-
--hash=sha256:5eb86f03f9c4f0ac2336ac5431271072ddf7ecc76b338e26366732cfac58aa19 \
58-
--hash=sha256:67f7f57eae8dede577f3f7775957f5bec93edd6bdb6ce597bb5b28e1bdf3d4fb \
59-
--hash=sha256:6ec84edcbc966ae460560a51a90046503ff0b5b66157a9efc61515c68059f6c8 \
60-
--hash=sha256:7ba834564daef87557e7fcd35c3c3183a4147b0b3a57314e53317360b9b201b3 \
61-
--hash=sha256:7d7f084cbe1fdb82be5a0545062b59b1ad3637bc5a48612ac2eb428ff31b31ea \
62-
--hash=sha256:82409f5150e529d699e5c33fa8fd85e965104db03bc564f5f4b6a9199e591f7c \
63-
--hash=sha256:87d092a7c2a44e5f7414ab02fb4145723ebba411425e1a99773531dd4c0e9b8d \
64-
--hash=sha256:8c56ef989342e42b9fcaba7c74b446f0cc9bed546dd00034fa7ad66fc00307ef \
65-
--hash=sha256:9449f5d4d7c516a6118fa9210c4a00f34384cb1d2028672100ee0c6cce49d7f6 \
66-
--hash=sha256:bc2301170986ad82d9349a91eb8884e0e191209c45f5541b16aa7c0cfb135978 \
67-
--hash=sha256:c132bab45d4bd0fff1d3fe294d92b0a6eb8404e93337b3127bdec9f21de117e6 \
68-
--hash=sha256:c3d945b7b577f07a477700f618f46cbc287af3a9222cd73035c6ef527ef2c363 \
69-
--hash=sha256:cee18beb4c807b5c0b178f4fa2fae03cef9d51821a358c6890f8b23465b7e5d2 \
70-
--hash=sha256:d01dfc5c2b3495184f683574e03c70022674ca9a7be88589c5aba130d835ea90
56+
cryptography==2.3.1 \
57+
--hash=sha256:02602e1672b62e803e08617ec286041cc453e8d43f093a5f4162095506bc0beb \
58+
--hash=sha256:10b48e848e1edb93c1d3b797c83c72b4c387ab0eb4330aaa26da8049a6cbede0 \
59+
--hash=sha256:17db09db9d7c5de130023657be42689d1a5f60502a14f6f745f6f65a6b8195c0 \
60+
--hash=sha256:227da3a896df1106b1a69b1e319dce218fa04395e8cc78be7e31ca94c21254bc \
61+
--hash=sha256:2cbaa03ac677db6c821dac3f4cdfd1461a32d0615847eedbb0df54bb7802e1f7 \
62+
--hash=sha256:31db8febfc768e4b4bd826750a70c79c99ea423f4697d1dab764eb9f9f849519 \
63+
--hash=sha256:4a510d268e55e2e067715d728e4ca6cd26a8e9f1f3d174faf88e6f2cb6b6c395 \
64+
--hash=sha256:6a88d9004310a198c474d8a822ee96a6dd6c01efe66facdf17cb692512ae5bc0 \
65+
--hash=sha256:76936ec70a9b72eb8c58314c38c55a0336a2b36de0c7ee8fb874a4547cadbd39 \
66+
--hash=sha256:7e3b4aecc4040928efa8a7cdaf074e868af32c58ffc9bb77e7bf2c1a16783286 \
67+
--hash=sha256:8168bcb08403ef144ff1fb880d416f49e2728101d02aaadfe9645883222c0aa5 \
68+
--hash=sha256:8229ceb79a1792823d87779959184a1bf95768e9248c93ae9f97c7a2f60376a1 \
69+
--hash=sha256:8a19e9f2fe69f6a44a5c156968d9fc8df56d09798d0c6a34ccc373bb186cee86 \
70+
--hash=sha256:8d10113ca826a4c29d5b85b2c4e045ffa8bad74fb525ee0eceb1d38d4c70dfd6 \
71+
--hash=sha256:be495b8ec5a939a7605274b6e59fbc35e76f5ad814ae010eb679529671c9e119 \
72+
--hash=sha256:dc2d3f3b1548f4d11786616cf0f4415e25b0fbecb8a1d2cd8c07568f13fdde38 \
73+
--hash=sha256:e4aecdd9d5a3d06c337894c9a6e2961898d3f64fe54ca920a72234a3de0f9cb3 \
74+
--hash=sha256:e79ab4485b99eacb2166f3212218dd858258f374855e1568f728462b0e6ee0d9 \
75+
--hash=sha256:f995d3667301e1754c57b04e0bae6f0fa9d710697a9f8d6712e8cca02550910f
7176
idna==2.7 \
7277
--hash=sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e \
7378
--hash=sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16 \
@@ -88,19 +93,27 @@ pynacl==1.2.1 \
8893
--hash=sha256:1d33e775fab3f383167afb20b9927aaf4961b953d76eeb271a5703a6d756b65b \
8994
--hash=sha256:2a42b2399d0428619e58dac7734838102d35f6dcdee149e0088823629bf99fbb \
9095
--hash=sha256:2dce05ac8b3c37b9e2f65eab56c544885607394753e9613fd159d5e2045c2d98 \
96+
--hash=sha256:63cfccdc6217edcaa48369191ae4dca0c390af3c74f23c619e954973035948cd \
9197
--hash=sha256:6453b0dae593163ffc6db6f9c9c1597d35c650598e2c39c0590d1757207a1ac2 \
9298
--hash=sha256:73a5a96fb5fbf2215beee2353a128d382dbca83f5341f0d3c750877a236569ef \
9399
--hash=sha256:8abb4ef79161a5f58848b30ab6fb98d8c466da21fdd65558ce1d7afc02c70b5f \
94100
--hash=sha256:8ac1167195b32a8755de06efd5b2d2fe76fc864517dab66aaf65662cc59e1988 \
95101
--hash=sha256:8f505f42f659012794414fa57c498404e64db78f1d98dfd40e318c569f3c783b \
102+
--hash=sha256:9c8a06556918ee8e3ab48c65574f318f5a0a4d31437fc135da7ee9d4f9080415 \
103+
--hash=sha256:a1e25fc5650cf64f01c9e435033e53a4aca9de30eb9929d099f3bb078e18f8f2 \
96104
--hash=sha256:be71cd5fce04061e1f3d39597f93619c80cdd3558a6c9ba99a546f144a8d8101 \
105+
--hash=sha256:c5b1a7a680218dee9da0f1b5e24072c46b3c275d35712bc1d505b85bb03441c0 \
106+
--hash=sha256:cb785db1a9468841a1265c9215c60fe5d7af2fb1b209e3316a152704607fc582 \
97107
--hash=sha256:cf6877124ae6a0698404e169b3ba534542cfbc43f939d46b927d956daf0a373a \
98108
--hash=sha256:d0eb5b2795b7ee2cbcfcadacbe95a13afbda048a262bd369da9904fecb568975 \
109+
--hash=sha256:d3a934e2b9f20abac009d5b6951067cfb5486889cb913192b4d8288b216842f1 \
99110
--hash=sha256:d795f506bcc9463efb5ebb0f65ed77921dcc9e0a50499dedd89f208445de9ecb \
100111
--hash=sha256:d8aaf7e5d6b0e0ef7d6dbf7abeb75085713d0100b4eb1a4e4e857de76d77ac45 \
112+
--hash=sha256:de2aaca8386cf4d70f1796352f2346f48ddb0bed61dc43a3ce773ba12e064031 \
101113
--hash=sha256:e0d38fa0a75f65f556fb912f2c6790d1fa29b7dd27a1d9cc5591b281321eaaa9 \
102114
--hash=sha256:eb2acabbd487a46b38540a819ef67e477a674481f84a82a7ba2234b9ba46f752 \
103115
--hash=sha256:eeee629828d0eb4f6d98ac41e9a3a6461d114d1d0aa111a8931c049359298da0 \
116+
--hash=sha256:f5836463a3c0cca300295b229b6c7003c415a9d11f8f9288ddbd728e2746524c \
104117
--hash=sha256:f5ce9e26d25eb0b2d96f3ef0ad70e1d3ae89b5d60255c462252a3e456a48c053 \
105118
--hash=sha256:fabf73d5d0286f9e078774f3435601d2735c94ce9e514ac4fb945701edead7e4
106119
requests==2.19.1 \

tuf/developer_tool.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,7 @@ def add_verification_key(self, key, expires=None):
296296
if len(self.keys) > 0:
297297
raise securesystemslib.exceptions.Error("This project already contains a key.")
298298

299-
try:
300-
super(Project, self).add_verification_key(key, expires)
301-
302-
except securesystemslib.exceptions.FormatError:
303-
raise
299+
super(Project, self).add_verification_key(key, expires)
304300

305301

306302

@@ -791,12 +787,8 @@ def load_project(project_directory, prefix='', new_targets_location=None,
791787
# Load the cfg file and the project.
792788
config_filename = os.path.join(project_directory, PROJECT_FILENAME)
793789

794-
try:
795-
project_configuration = securesystemslib.util.load_json_file(config_filename)
796-
tuf.formats.PROJECT_CFG_SCHEMA.check_match(project_configuration)
797-
798-
except (OSError, IOError, securesystemslib.exceptions.FormatError):
799-
raise
790+
project_configuration = securesystemslib.util.load_json_file(config_filename)
791+
tuf.formats.PROJECT_CFG_SCHEMA.check_match(project_configuration)
800792

801793
targets_directory = os.path.join(project_directory,
802794
project_configuration['targets_location'])
@@ -906,11 +898,7 @@ def load_project(project_directory, prefix='', new_targets_location=None,
906898
continue
907899

908900
signable = None
909-
try:
910-
signable = securesystemslib.util.load_json_file(metadata_path)
911-
912-
except (ValueError, IOError, securesystemslib.exceptions.Error):
913-
raise
901+
signable = securesystemslib.util.load_json_file(metadata_path)
914902

915903
# Strip the prefix from the local working copy, it will be added again
916904
# when the targets metadata is written to disk.

tuf/download.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
import time
4040
import timeit
4141

42+
import tuf
4243
import requests
4344
import six
4445

4546
import securesystemslib
4647
import securesystemslib.util
47-
import tuf
4848
import tuf.exceptions
4949

5050
# See 'log.py' to learn how logging is handled in TUF.
@@ -379,17 +379,12 @@ def _download_fixed_amount_of_data(response, temp_file, required_length):
379379
break
380380

381381
except:
382-
raise
383-
384-
else:
385-
# This else block returns and skips closing the response in the finally
386-
# block, so close the response here.
382+
# Whatever happens, make sure that we always close the connection.
387383
response.close()
388-
return number_of_bytes_received, average_download_speed
384+
raise
389385

390-
finally:
391-
# Whatever happens, make sure that we always close the response.
392-
response.close()
386+
response.close()
387+
return number_of_bytes_received, average_download_speed
393388

394389

395390

tuf/formats.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -952,14 +952,10 @@ def make_versioninfo(version_number):
952952

953953
# Raise 'securesystemslib.exceptions.FormatError' if 'versioninfo' is
954954
# improperly formatted.
955-
try:
956-
securesystemslib.formats.VERSIONINFO_SCHEMA.check_match(versioninfo)
955+
securesystemslib.formats.VERSIONINFO_SCHEMA.check_match(versioninfo)
957956

958-
except:
959-
raise
957+
return versioninfo
960958

961-
else:
962-
return versioninfo
963959

964960

965961

tuf/roledb.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,11 @@ def role_exists(rolename, repository_name='default'):
569569

570570
# Raise securesystemslib.exceptions.FormatError,
571571
# securesystemslib.exceptions.InvalidNameError if the arguments are invalid.
572+
# We do not intercept securesystemslib.exceptions.FormatError
573+
# or securesystemslib.exceptions.InvalidNameError exceptions.
572574
try:
573575
_check_rolename(rolename, repository_name)
574576

575-
except (securesystemslib.exceptions.FormatError, securesystemslib.exceptions.InvalidNameError):
576-
raise
577-
578577
except tuf.exceptions.UnknownRoleError:
579578
return False
580579

tuf/sig.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,15 @@ def get_signature_status(signable, role=None, repository_name='default',
185185
if valid_sig:
186186
if role is not None:
187187

188-
try:
189-
# Is this an unauthorized key? (a keyid associated with 'role')
190-
if keyids is None:
191-
keyids = tuf.roledb.get_role_keyids(role, repository_name)
188+
# Is this an unauthorized key? (a keyid associated with 'role')
189+
# Note that if the role is not known, tuf.exceptions.UnknownRoleError
190+
# is raised here.
191+
if keyids is None:
192+
keyids = tuf.roledb.get_role_keyids(role, repository_name)
192193

193-
if keyid not in keyids:
194-
untrusted_sigs.append(keyid)
195-
continue
196-
197-
# Unknown role, re-raise exception.
198-
except tuf.exceptions.UnknownRoleError:
199-
raise
194+
if keyid not in keyids:
195+
untrusted_sigs.append(keyid)
196+
continue
200197

201198
# This is an unset role, thus an unknown signature.
202199
else:
@@ -215,12 +212,10 @@ def get_signature_status(signable, role=None, repository_name='default',
215212
# role.
216213
if role is not None:
217214
if threshold is None:
218-
try:
219-
threshold = \
220-
tuf.roledb.get_role_threshold(role, repository_name=repository_name)
221-
222-
except tuf.exceptions.UnknownRoleError:
223-
raise
215+
# Note that if the role is not known, tuf.exceptions.UnknownRoleError is
216+
# raised here.
217+
threshold = tuf.roledb.get_role_threshold(
218+
role, repository_name=repository_name)
224219

225220
else:
226221
logger.debug('Not using roledb.py\'s threshold for ' + repr(role))

0 commit comments

Comments
 (0)