Skip to content

Commit fdd37a9

Browse files
author
James Chien
committed
test: address lint problems
Signed-off-by: James Chien <james@numbersprotocol.io>
1 parent d05efeb commit fdd37a9

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ disable=
5858
too-few-public-methods,
5959
too-many-public-methods,
6060
too-many-arguments,
61+
unspecified-encoding,
6162

6263
[flake8]
6364
max-line-length = 120

src/numbers_c2pa/core.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
import mimetypes
33
import os
4-
import subprocess
4+
import subprocess # nosec
55
from datetime import datetime
66
from tempfile import TemporaryDirectory
77
from typing import Any, Dict, List, Optional
@@ -42,9 +42,9 @@ def c2patool_inject(
4242
env=env_vars,
4343
check=True,
4444
stderr=subprocess.PIPE,
45-
)
45+
) # nosec
4646
except subprocess.CalledProcessError as e:
47-
raise UnknownError(e.stderr)
47+
raise UnknownError(e.stderr) from e
4848

4949

5050
def create_c2pa_manifest(
@@ -219,7 +219,7 @@ def inject_file(
219219
with TemporaryDirectory() as temp_dir:
220220
if thumbnail_url:
221221
thumbnail_file_path = os.path.join(temp_dir, 'thumbnail.jpg')
222-
response = requests.get(thumbnail_url, stream=True)
222+
response = requests.get(thumbnail_url, stream=True, timeout=120)
223223
response.raise_for_status()
224224
with open(thumbnail_file_path, 'wb') as thumbnail_file:
225225
for chunk in response.iter_content(chunk_size=8192):
@@ -232,7 +232,7 @@ def inject_file(
232232

233233
# Save the manifest to a temporary file
234234
manifest_file_path = os.path.join(temp_dir, 'manifest.json')
235-
with open(manifest_file_path, 'w') as manifest_file:
235+
with open(manifest_file_path, 'w',) as manifest_file:
236236
json.dump(manifest, manifest_file)
237237
manifest_file.flush()
238238

@@ -254,25 +254,25 @@ def read_c2pa(asset_c2pa_bytes: bytes, asset_mime_type: str):
254254
f.write(asset_c2pa_bytes)
255255

256256
command = ['c2patool', asset_c2pa_file]
257-
process = subprocess.run(command, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
257+
process = subprocess.run(
258+
command, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False
259+
) # nosec
258260
if process.returncode != 0:
259261
if 'No claim found' in process.stderr:
260262
raise NoClaimFound
261-
else:
262-
raise UnknownError(process.stderr)
263+
raise UnknownError(process.stderr)
263264

264265
json_output = json.loads(process.stdout)
265266
return json_output
266267

267268

268269
def read_c2pa_file(c2pa_file: str):
269270
command = ['c2patool', c2pa_file]
270-
process = subprocess.run(command, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
271+
process = subprocess.run(command, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False) # nosec
271272
if process.returncode != 0:
272273
if 'No claim found' in process.stderr:
273274
raise NoClaimFound
274-
else:
275-
raise UnknownError(process.stderr)
275+
raise UnknownError(process.stderr)
276276

277277
json_output = json.loads(process.stdout)
278278
return json_output

src/numbers_c2pa/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def create_self_signed_certificate(private_key_pem, output_file='es256_certs.pem
5353
.not_valid_before(datetime.datetime.utcnow())
5454
.not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=365))
5555
.add_extension(
56-
x509.SubjectAlternativeName([x509.DNSName(u"my-organization.com")]),
56+
x509.SubjectAlternativeName([x509.DNSName('my-organization.com')]),
5757
critical=False,
5858
)
5959
.add_extension(

0 commit comments

Comments
 (0)