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

D->M #207

Draft
wants to merge 102 commits into
base: master
Choose a base branch
from
Draft

D->M #207

wants to merge 102 commits into from

Conversation

bio-boris
Copy link
Collaborator

@bio-boris bio-boris commented Nov 14, 2024

Notable Changes from copilot

Version Bump
    Updated the version in app.py to align with the new release.

New Endpoints
    Added import_filetypes endpoint.
    Documented write_bulk_specification endpoint providing structure for bulk data insertion.

Bug Fixes and Improvements
    Addressed several markdown formatting issues across documentation.
    Enhanced error handling for file parsing and data type specifications.

These changes encompass significant updates and improvements aimed at enhancing functionality and documentation accuracy.

eapearson and others added 30 commits July 11, 2023 10:10
still more to go, as there are some more serious issues like access to private members, and out of date dependencies, but this puts us on a good footing for any future change w/less format spam.
 Not perfect. The readme has dozens of issues reported.
just to satisfy remark-lint used by codacy, as it uses rules not supported by PyCharm. So annoying.
There are breaking changes; it should be updated, but probably not in this set of changes.
PTV-1887 - linting, formatting, updating reps, fixing tests
* Adding dependabot and codeql workflows to the repo
@@ -476,30 +482,24 @@


@routes.post("/define-upa/{path:.+}")
async def define_UPA(request: web.Request):
async def define_upa(request: web.Request):

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
This path depends on a
user-provided value
.

Copilot Autofix AI 27 days ago

To fix the problem, we need to ensure that the path derived from user input is validated and sanitized before it is used in any file operations. This can be achieved by normalizing the path and ensuring it is contained within a safe root directory.

  1. Normalize the path using os.path.normpath to remove any ".." segments.
  2. Ensure that the normalized path starts with the intended base directory to prevent access to files outside this directory.
Suggested changeset 1
staging_service/app.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/staging_service/app.py b/staging_service/app.py
--- a/staging_service/app.py
+++ b/staging_service/app.py
@@ -416,3 +416,7 @@
     username = await authorize_request(request)
-    path = Path.validate_path(username, request.match_info["path"])
+    user_path = os.path.normpath(request.match_info["path"])
+    full_path = os.path.join(base_path, user_path)
+    if not full_path.startswith(base_path):
+        raise web.HTTPForbidden(text="Invalid path")
+    path = Path.validate_path(username, full_path)
     return web.json_response(await read_metadata_for(path))
@@ -494,4 +498,9 @@
     username = await authorize_request(request)
-    path = Path.validate_path(username, request.match_info["path"])
-    if not os.path.exists(path.full_path or not os.path.isfile(path.full_path)):
+    base_path = '/safe/root/directory'  # Define the base directory
+    user_path = os.path.normpath(request.match_info["path"])
+    full_path = os.path.join(base_path, user_path)
+    if not full_path.startswith(base_path):
+        raise web.HTTPForbidden(text="Invalid path")
+    path = Path.validate_path(username, full_path)
+    if not os.path.exists(path.full_path) or not os.path.isfile(path.full_path):
         # TODO the security model here is to not care if someone wants to put in a false upa
@@ -515,3 +524,7 @@
     username = await authorize_request(request)
-    path = Path.validate_path(username, request.match_info["path"])
+    user_path = os.path.normpath(request.match_info["path"])
+    full_path = os.path.join(base_path, user_path)
+    if not full_path.startswith(base_path):
+        raise web.HTTPForbidden(text="Invalid path")
+    path = Path.validate_path(username, full_path)
     # make sure directory isn't home
EOF
@@ -416,3 +416,7 @@
username = await authorize_request(request)
path = Path.validate_path(username, request.match_info["path"])
user_path = os.path.normpath(request.match_info["path"])
full_path = os.path.join(base_path, user_path)
if not full_path.startswith(base_path):
raise web.HTTPForbidden(text="Invalid path")
path = Path.validate_path(username, full_path)
return web.json_response(await read_metadata_for(path))
@@ -494,4 +498,9 @@
username = await authorize_request(request)
path = Path.validate_path(username, request.match_info["path"])
if not os.path.exists(path.full_path or not os.path.isfile(path.full_path)):
base_path = '/safe/root/directory' # Define the base directory
user_path = os.path.normpath(request.match_info["path"])
full_path = os.path.join(base_path, user_path)
if not full_path.startswith(base_path):
raise web.HTTPForbidden(text="Invalid path")
path = Path.validate_path(username, full_path)
if not os.path.exists(path.full_path) or not os.path.isfile(path.full_path):
# TODO the security model here is to not care if someone wants to put in a false upa
@@ -515,3 +524,7 @@
username = await authorize_request(request)
path = Path.validate_path(username, request.match_info["path"])
user_path = os.path.normpath(request.match_info["path"])
full_path = os.path.join(base_path, user_path)
if not full_path.startswith(base_path):
raise web.HTTPForbidden(text="Invalid path")
path = Path.validate_path(username, full_path)
# make sure directory isn't home
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -476,30 +482,24 @@


@routes.post("/define-upa/{path:.+}")
async def define_UPA(request: web.Request):
async def define_upa(request: web.Request):

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
This path depends on a
user-provided value
.

Copilot Autofix AI 22 days ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants