Skip to content

Commit 25d8446

Browse files
committed
affirm our use of insecure hashing
1 parent 999111d commit 25d8446

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

cwltool/command_line_tool.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ def job(self,
354354

355355
keydictstr = json_dumps(keydict, separators=(',', ':'),
356356
sort_keys=True)
357-
cachekey = hashlib.md5(keydictstr.encode('utf-8')).hexdigest()
357+
cachekey = hashlib.md5( # nosec
358+
keydictstr.encode('utf-8')).hexdigest()
358359

359360
_logger.debug("[job %s] keydictstr is %s -> %s", jobname,
360361
keydictstr, cachekey)
@@ -717,7 +718,7 @@ def collect_output(self,
717718
files["contents"] = content_limit_respected_read_bytes(f).decode("utf-8")
718719
if compute_checksum:
719720
with fs_access.open(rfile["location"], "rb") as f:
720-
checksum = hashlib.sha1()
721+
checksum = hashlib.sha1() # nosec
721722
contents = f.read(1024 * 1024)
722723
while contents != b"":
723724
checksum.update(contents)

cwltool/load_tool.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,9 @@ def _convert_stdstreams_to_files(workflowobj):
152152
filename = workflowobj[streamtype]
153153
else:
154154
filename = Text(
155-
hashlib.sha1(json_dumps(workflowobj,
156-
sort_keys=True
157-
).encode('utf-8')
158-
).hexdigest())
155+
hashlib.sha1( # nosec
156+
json_dumps(workflowobj, sort_keys=True
157+
).encode('utf-8')).hexdigest())
159158
workflowobj[streamtype] = filename
160159
out['type'] = 'File'
161160
out['outputBinding'] = cmap({'glob': filename})

cwltool/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ def scandeps(base, # type: Text
10181018

10191019
def compute_checksums(fs_access, fileobj):
10201020
if "checksum" not in fileobj:
1021-
checksum = hashlib.sha1()
1021+
checksum = hashlib.sha1() # nosec
10221022
with fs_access.open(fileobj["location"], "rb") as f:
10231023
contents = f.read(1024 * 1024)
10241024
while contents != b"":

cwltool/provenance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __init__(self, research_object, rel_path):
164164
if posixpath.isabs(rel_path):
165165
raise ValueError("rel_path must be relative: %s" % rel_path)
166166
self.rel_path = rel_path
167-
self.hashes = {SHA1: hashlib.sha1(),
167+
self.hashes = {SHA1: hashlib.sha1(), # nosec
168168
SHA256: hashlib.sha256(),
169169
SHA512: hashlib.sha512()}
170170
# Open file in Research Object folder

cwltool/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,5 +234,5 @@ def random_outdir(): # type: () -> Text
234234
""" Return the random directory name chosen to use for tool / workflow output """
235235
# compute this once and store it as a function attribute - each subsequent call will return the same value
236236
if not hasattr(random_outdir, 'outdir'):
237-
random_outdir.outdir = '/' + ''.join([random.choice(string.ascii_letters) for _ in range(6)]) # type: ignore
237+
random_outdir.outdir = '/' + ''.join([random.choice(string.ascii_letters) for _ in range(6)]) # type: ignore # nosec
238238
return random_outdir.outdir # type: ignore

0 commit comments

Comments
 (0)