Skip to content

fix: codeql fixes #1606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def get_blob_as_bytes_return_http_response(req: func.HttpRequest, file: bytes) \
assert isinstance(file, bytes)

content_size = len(file)
content_md5 = hashlib.md5(file).hexdigest()
content_sha256 = hashlib.sha256(file).hexdigest()

response_dict = {
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down Expand Up @@ -84,11 +84,11 @@ def get_blob_as_bytes_stream_return_http_response(req: func.HttpRequest,
file_bytes = file.read()

content_size = len(file_bytes)
content_md5 = hashlib.md5(file_bytes).hexdigest()
content_sha256 = hashlib.sha256(file_bytes).hexdigest()

response_dict = {
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down Expand Up @@ -127,11 +127,11 @@ def get_blob_as_str_return_http_response(req: func.HttpRequest,

num_chars = len(file)
content_bytes = file.encode('utf-8')
content_md5 = hashlib.md5(content_bytes).hexdigest()
content_sha256 = hashlib.sha256(content_bytes).hexdigest()

response_dict = {
'num_chars': num_chars,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down Expand Up @@ -212,13 +212,13 @@ def put_blob_as_bytes_return_http_response(req: func.HttpRequest,
content = b'\x01' * content_size
else:
content = bytearray(random.getrandbits(8) for _ in range(content_size))
content_md5 = hashlib.md5(content).hexdigest()
content_sha256 = hashlib.sha256(content).hexdigest()

file.set(content)

response_dict = {
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down Expand Up @@ -249,14 +249,14 @@ def put_blob_as_str_return_http_response(req: func.HttpRequest, file: func.Out[
k=num_chars))
content_bytes = content.encode('utf-8')
content_size = len(content_bytes)
content_md5 = hashlib.md5(content_bytes).hexdigest()
content_sha256 = hashlib.sha256(content_bytes).hexdigest()

file.set(content)

response_dict = {
'num_chars': num_chars,
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down Expand Up @@ -321,8 +321,8 @@ def put_blob_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:

def _generate_content_and_digest(content_size):
content = bytearray(random.getrandbits(8) for _ in range(content_size))
content_md5 = hashlib.md5(content).hexdigest()
return content, content_md5
content_sha256 = hashlib.sha256(content).hexdigest()
return content, content_sha256


@app.function_name(name="put_get_multiple_blobs_as_bytes_return_http_response")
Expand Down Expand Up @@ -359,15 +359,15 @@ def put_get_multiple_blobs_as_bytes_return_http_response(
input_content_size_1 = len(inputfile1)
input_content_size_2 = len(inputfile2)

input_content_md5_1 = hashlib.md5(inputfile1).hexdigest()
input_content_md5_2 = hashlib.md5(inputfile2).hexdigest()
input_content_sha256_1 = hashlib.sha256(inputfile1).hexdigest()
input_content_sha256_2 = hashlib.sha256(inputfile2).hexdigest()

output_content_size_1 = int(req.params['output_content_size_1'])
output_content_size_2 = int(req.params['output_content_size_2'])

output_content_1, output_content_md5_1 = \
output_content_1, output_content_sha256_1 = \
_generate_content_and_digest(output_content_size_1)
output_content_2, output_content_md5_2 = \
output_content_2, output_content_sha256_2 = \
_generate_content_and_digest(output_content_size_2)

outputfile1.set(output_content_1)
Expand All @@ -376,12 +376,12 @@ def put_get_multiple_blobs_as_bytes_return_http_response(
response_dict = {
'input_content_size_1': input_content_size_1,
'input_content_size_2': input_content_size_2,
'input_content_md5_1': input_content_md5_1,
'input_content_md5_2': input_content_md5_2,
'input_content_sha256_1': input_content_sha256_1,
'input_content_sha256_2': input_content_sha256_2,
'output_content_size_1': output_content_size_1,
'output_content_size_2': output_content_size_2,
'output_content_md5_1': output_content_md5_1,
'output_content_md5_2': output_content_md5_2
'output_content_sha256_1': output_content_sha256_1,
'output_content_sha256_2': output_content_sha256_2
}

response_body = json.dumps(response_dict, indent=2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def get_blob_as_bytes_return_http_response(req: func.HttpRequest, file: bytes) \
assert isinstance(file, bytes)

content_size = len(file)
content_md5 = hashlib.md5(file).hexdigest()
content_sha256 = hashlib.sha256(file).hexdigest()

response_dict = {
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down Expand Up @@ -100,11 +100,11 @@ def get_blob_as_bytes_stream_return_http_response(req: func.HttpRequest,
file_bytes = file.read()

content_size = len(file_bytes)
content_md5 = hashlib.md5(file_bytes).hexdigest()
content_sha256 = hashlib.sha256(file_bytes).hexdigest()

response_dict = {
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down Expand Up @@ -151,11 +151,11 @@ def get_blob_as_str_return_http_response(req: func.HttpRequest,

num_chars = len(file)
content_bytes = file.encode('utf-8')
content_md5 = hashlib.md5(content_bytes).hexdigest()
content_sha256 = hashlib.sha256(content_bytes).hexdigest()

response_dict = {
'num_chars': num_chars,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down Expand Up @@ -259,13 +259,13 @@ def put_blob_as_bytes_return_http_response(req: func.HttpRequest,
content = b'\x01' * content_size
else:
content = bytearray(random.getrandbits(8) for _ in range(content_size))
content_md5 = hashlib.md5(content).hexdigest()
content_sha256 = hashlib.sha256(content).hexdigest()

file.set(content)

response_dict = {
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down Expand Up @@ -299,14 +299,14 @@ def put_blob_as_str_return_http_response(
k=num_chars))
content_bytes = content.encode('utf-8')
content_size = len(content_bytes)
content_md5 = hashlib.md5(content_bytes).hexdigest()
content_sha256 = hashlib.sha256(content_bytes).hexdigest()

file.set(content)

response_dict = {
'num_chars': num_chars,
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down Expand Up @@ -389,8 +389,8 @@ def put_blob_trigger(req: func.HttpRequest, file: func.Out[str]) -> str:

def _generate_content_and_digest(content_size):
content = bytearray(random.getrandbits(8) for _ in range(content_size))
content_md5 = hashlib.md5(content).hexdigest()
return content, content_md5
content_sha256 = hashlib.sha256(content).hexdigest()
return content, content_sha256


@app.function_name(name="put_get_multiple_blobs_as_bytes_return_http_response")
Expand Down Expand Up @@ -437,15 +437,15 @@ def put_get_multiple_blobs_as_bytes_return_http_response(
input_content_size_1 = len(inputfile1)
input_content_size_2 = len(inputfile2)

input_content_md5_1 = hashlib.md5(inputfile1).hexdigest()
input_content_md5_2 = hashlib.md5(inputfile2).hexdigest()
input_content_sha256_1 = hashlib.sha256(inputfile1).hexdigest()
input_content_sha256_2 = hashlib.sha256(inputfile2).hexdigest()

output_content_size_1 = int(req.params['output_content_size_1'])
output_content_size_2 = int(req.params['output_content_size_2'])

output_content_1, output_content_md5_1 = \
output_content_1, output_content_sha256_1 = \
_generate_content_and_digest(output_content_size_1)
output_content_2, output_content_md5_2 = \
output_content_2, output_content_sha256_2 = \
_generate_content_and_digest(output_content_size_2)

outputfile1.set(output_content_1)
Expand All @@ -454,12 +454,12 @@ def put_get_multiple_blobs_as_bytes_return_http_response(
response_dict = {
'input_content_size_1': input_content_size_1,
'input_content_size_2': input_content_size_2,
'input_content_md5_1': input_content_md5_1,
'input_content_md5_2': input_content_md5_2,
'input_content_sha256_1': input_content_sha256_1,
'input_content_sha256_2': input_content_sha256_2,
'output_content_size_1': output_content_size_1,
'output_content_size_2': output_content_size_2,
'output_content_md5_1': output_content_md5_1,
'output_content_md5_2': output_content_md5_2
'output_content_sha256_1': output_content_sha256_1,
'output_content_sha256_2': output_content_sha256_2
}

response_body = json.dumps(response_dict, indent=2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def main(req: azf.HttpRequest, file: bytes) -> azf.HttpResponse:
assert isinstance(file, bytes)

content_size = len(file)
content_md5 = hashlib.md5(file).hexdigest()
content_sha256 = hashlib.sha256(file).hexdigest()

response_dict = {
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def main(req: azf.HttpRequest, file: azf.InputStream) -> azf.HttpResponse:
file_bytes = file.read()

content_size = len(file_bytes)
content_md5 = hashlib.md5(file_bytes).hexdigest()
content_sha256 = hashlib.sha256(file_bytes).hexdigest()

response_dict = {
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def main(req: azf.HttpRequest, file: str) -> azf.HttpResponse:

num_chars = len(file)
content_bytes = file.encode('utf-8')
content_md5 = hashlib.md5(content_bytes).hexdigest()
content_sha256 = hashlib.sha256(content_bytes).hexdigest()

response_dict = {
'num_chars': num_chars,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def main(req: azf.HttpRequest, file: azf.Out[bytes]) -> azf.HttpResponse:
content = b'\x01' * content_size
else:
content = bytearray(random.getrandbits(8) for _ in range(content_size))
content_md5 = hashlib.md5(content).hexdigest()
content_sha256 = hashlib.sha256(content).hexdigest()

file.set(content)

response_dict = {
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def main(req: azf.HttpRequest, file: azf.Out[str]) -> azf.HttpResponse:
k=num_chars))
content_bytes = content.encode('utf-8')
content_size = len(content_bytes)
content_md5 = hashlib.md5(content_bytes).hexdigest()
content_sha256 = hashlib.sha256(content_bytes).hexdigest()

file.set(content)

response_dict = {
'num_chars': num_chars,
'content_size': content_size,
'content_md5': content_md5
'content_sha256': content_sha256
}

response_body = json.dumps(response_dict, indent=2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

def _generate_content_and_digest(content_size):
content = bytearray(random.getrandbits(8) for _ in range(content_size))
content_md5 = hashlib.md5(content).hexdigest()
return content, content_md5
content_sha256 = hashlib.sha256(content).hexdigest()
return content, content_sha256


def main(
Expand All @@ -30,15 +30,15 @@ def main(
input_content_size_1 = len(inputfile1)
input_content_size_2 = len(inputfile2)

input_content_md5_1 = hashlib.md5(inputfile1).hexdigest()
input_content_md5_2 = hashlib.md5(inputfile2).hexdigest()
input_content_sha256_1 = hashlib.sha256(inputfile1).hexdigest()
input_content_sha256_2 = hashlib.sha256(inputfile2).hexdigest()

output_content_size_1 = int(req.params['output_content_size_1'])
output_content_size_2 = int(req.params['output_content_size_2'])

output_content_1, output_content_md5_1 = \
output_content_1, output_content_sha256_1 = \
_generate_content_and_digest(output_content_size_1)
output_content_2, output_content_md5_2 = \
output_content_2, output_content_sha256_2 = \
_generate_content_and_digest(output_content_size_2)

outputfile1.set(output_content_1)
Expand All @@ -47,12 +47,12 @@ def main(
response_dict = {
'input_content_size_1': input_content_size_1,
'input_content_size_2': input_content_size_2,
'input_content_md5_1': input_content_md5_1,
'input_content_md5_2': input_content_md5_2,
'input_content_sha256_1': input_content_sha256_1,
'input_content_sha256_2': input_content_sha256_2,
'output_content_size_1': output_content_size_1,
'output_content_size_2': output_content_size_2,
'output_content_md5_1': output_content_md5_1,
'output_content_md5_2': output_content_md5_2
'output_content_sha256_1': output_content_sha256_1,
'output_content_sha256_2': output_content_sha256_2
}

response_body = json.dumps(response_dict, indent=2)
Expand Down
Loading
Loading