Skip to content

Commit

Permalink
ignore security in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed Oct 3, 2022
1 parent 779d70b commit d98492d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
14 changes: 7 additions & 7 deletions tests/processes/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,11 +952,11 @@ def test_cwl2json_input_values_ogc_format():
"test1": {"value": "value"},
"test2": {"value": 1},
"test3": {"value": 1.23},
"test4": {"href": "/tmp/random.txt"},
"test4": {"href": "/tmp/random.txt"}, # nosec: B108
"test5": [{"value": "val1"}, {"value": "val2"}],
"test6": [{"value": 1}, {"value": 2}],
"test7": [{"value": 1.23}, {"value": 4.56}],
"test8": [{"href": "/tmp/other.txt"}]
"test8": [{"href": "/tmp/other.txt"}] # nosec: B108
}
result = cwl2json_input_values(values, ProcessSchema.OGC)
assert result == expect
Expand Down Expand Up @@ -1096,17 +1096,17 @@ def test_repr2json_input_values():
{"id": "test6", "value": 2},
{"id": "test7", "value": 1.23},
{"id": "test7", "value": 4.56},
{"id": "test8", "href": "/tmp/other.txt"},
{"id": "test8", "href": "/tmp/other.txt"}, # nosec: B108
{"id": "test9", "value": "short"},
{"id": "test10", "value": "long"},
{"id": "test11", "href": "/tmp/file.json", "format": {
{"id": "test11", "href": "/tmp/file.json", "format": { # nosec: B108
"mediaType": ContentType.APP_JSON, "schema": "http://schema.org/random.json"
}},
{"id": "test12", "href": "/tmp/other.xml", "format": {
{"id": "test12", "href": "/tmp/other.xml", "format": { # nosec: B108
"mediaType": ContentType.TEXT_XML, "schema": "http://schema.org/random.xml"
}},
{"id": "test13", "href": "/tmp/one.json", "format": {"mediaType": ContentType.APP_JSON}},
{"id": "test13", "href": "/tmp/two.xml", "format": {"mediaType": ContentType.TEXT_XML}},
{"id": "test13", "href": "/tmp/one.json", "format": {"mediaType": ContentType.APP_JSON}}, # nosec: B108
{"id": "test13", "href": "/tmp/two.xml", "format": {"mediaType": ContentType.TEXT_XML}}, # nosec: B108
]
result = repr2json_input_values(values)
assert result == expect
Expand Down
5 changes: 3 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import mimetypes
import os
import re
import subprocess
import subprocess # nosec: B404
import sys
import tempfile
import uuid
Expand Down Expand Up @@ -358,7 +358,8 @@ def run_command(command, trim=True, expect_error=False, entrypoint=None):
command = command.split(" ")
command = [str(arg) for arg in command]
if entrypoint is None:
out, _ = subprocess.Popen(["which", "python"], universal_newlines=True, stdout=subprocess.PIPE).communicate()
func = ["which", "python"]
out, _ = subprocess.Popen(func, universal_newlines=True, stdout=subprocess.PIPE).communicate() # nosec: B603
if not out:
out = sys.executable # fallback for some systems that fail above call
python_path = os.path.split(out)[0]
Expand Down
12 changes: 6 additions & 6 deletions tests/wps/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,24 @@ def test_get_wps_output_context_resolution():

def test_map_wps_output_location_duplicate_subdir():
for tmp_dir in [
"/tmp/tmp/tmp",
"/tmp/tmpdir"
"/tmp/tmp/tmp", # nosec: B108 # don't care hardcoded for test
"/tmp/tmpdir" # nosec: B108 # don't care hardcoded for test
]:
wps_out = "http:///localhost/wps-output/tmp"
wps_out = "http:///localhost/wps-output/tmp" # nosec: B108 # don't care hardcoded for test
settings = {
"weaver.wps_output_dir": tmp_dir,
"weaver.wps_output_url": wps_out
}
path = map_wps_output_location(f"{wps_out}/tmp/some-file-tmp.tmp", settings, exists=False)
assert path == f"{tmp_dir}/tmp/some-file-tmp.tmp"
assert path == f"{tmp_dir}/tmp/some-file-tmp.tmp" # nosec: B108 # don't care hardcoded for test

path = map_wps_output_location(f"{tmp_dir}/here/some-file-tmp.tmp", settings, exists=False, url=True)
assert path == f"{wps_out}/here/some-file-tmp.tmp"
assert path == f"{wps_out}/here/some-file-tmp.tmp" # nosec: B108 # don't care hardcoded for test


def test_map_wps_output_location_exists():
wps_url = "http:///localhost/wps-output/tmp"
wps_dir = "/tmp/weaver-test/test-outputs"
wps_dir = "/tmp/weaver-test/test-outputs" # nosec: B108 # don't care hardcoded for test
settings = {
"weaver.wps_output_dir": wps_dir,
"weaver.wps_output_url": wps_url
Expand Down
2 changes: 1 addition & 1 deletion tests/wps_restapi/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def setUpClass(cls):
cls.settings = {
"weaver.url": "https://localhost",
"weaver.wps_email_encrypt_salt": "weaver-test",
"weaver.wps_output_dir": "/tmp/weaver-test/wps-outputs",
"weaver.wps_output_dir": "/tmp/weaver-test/wps-outputs", # nosec: B108 # don't care hardcoded for test
}
cls.config = setup_config_with_mongodb(settings=cls.settings)
cls.app = get_test_weaver_app(config=cls.config)
Expand Down

0 comments on commit d98492d

Please sign in to comment.