Skip to content
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

Address code scanning issues with remote functions and vdms client #205

Merged
merged 6 commits into from
Aug 15, 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
4 changes: 2 additions & 2 deletions .github/coverage/python.develop.coverage_report.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name Stmts Miss Cover Missing
--------------------------------------------------------------------
/vdms/client/python/vdms/__init__.py 2 0 100%
/vdms/client/python/vdms/vdms.py 98 2 98% 151, 166
/vdms/client/python/vdms/vdms.py 99 2 98% 152, 167
--------------------------------------------------------------------
TOTAL 100 2 98%
TOTAL 101 2 98%
2 changes: 1 addition & 1 deletion .github/coverage/python.develop.coverage_value.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
98
98.02
1 change: 1 addition & 0 deletions client/python/vdms/vdms.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def connect(self, host="localhost", port=55555):

if self.use_tls:
context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
context.minimum_version = ssl.TLSVersion.TLSv1_2
if self.ca_file != "":
context.load_verify_locations(cafile=self.ca_file)
if self.cert_file != "" and self.key_file != "":
Expand Down
11 changes: 3 additions & 8 deletions remote_function/udf_server.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from flask import Flask, request, jsonify, send_file, after_this_request
import cv2
import numpy as np
import json
from datetime import datetime, timezone
import os
import sys
from collections import defaultdict, deque
import skvideo.io
import imutils
import uuid
from zipfile import ZipFile
from werkzeug.utils import secure_filename
ifadams marked this conversation as resolved.
Show resolved Hide resolved

for entry in os.scandir("functions"):
if entry.is_file():
Expand All @@ -18,8 +15,6 @@

app = Flask(__name__)

count = 0


def get_current_timestamp():
dt = datetime.now(timezone.utc)
Expand All @@ -42,7 +37,7 @@ def image_api():

format = json_data["format"] if "format" in json_data else "jpg"

tmpfile = "tmpfile" + uuid.uuid1().hex + "." + str(format)
tmpfile = secure_filename("tmpfile" + uuid.uuid1().hex + "." + str(format))

image_data.save(tmpfile)

Expand Down Expand Up @@ -70,7 +65,7 @@ def video_api():
video_data = request.files["videoData"]
format = json_data["format"] if "format" in json_data else "mp4"

tmpfile = "tmpfile" + uuid.uuid1().hex + "." + str(format)
tmpfile = secure_filename("tmpfile" + uuid.uuid1().hex + "." + str(format))
video_data.save(tmpfile)

video_file, metadata_file = "", ""
Expand Down
11 changes: 3 additions & 8 deletions tests/remote_function_test/udf_server.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from flask import Flask, request, jsonify, send_file, after_this_request
import cv2
import numpy as np
import json
from datetime import datetime, timezone
import os
import sys
from collections import defaultdict, deque
import skvideo.io
import imutils
import uuid
from zipfile import ZipFile
from werkzeug.utils import secure_filename

for entry in os.scandir("functions"):
if entry.is_file():
Expand All @@ -18,8 +15,6 @@

app = Flask(__name__)

count = 0


def get_current_timestamp():
dt = datetime.now(timezone.utc)
Expand All @@ -42,7 +37,7 @@ def image_api():

format = json_data["format"] if "format" in json_data else "jpg"

tmpfile = "tmpfile" + uuid.uuid1().hex + "." + str(format)
tmpfile = secure_filename("tmpfile" + uuid.uuid1().hex + "." + str(format))

image_data.save(tmpfile)

Expand Down Expand Up @@ -70,7 +65,7 @@ def video_api():
video_data = request.files["videoData"]
format = json_data["format"] if "format" in json_data else "mp4"

tmpfile = "tmpfile" + uuid.uuid1().hex + "." + str(format)
tmpfile = secure_filename("tmpfile" + uuid.uuid1().hex + "." + str(format))
video_data.save(tmpfile)

video_file, metadata_file = "", ""
Expand Down