Skip to content

Commit

Permalink
Potential fix for code scanning alert no. 20: Uncontrolled data used …
Browse files Browse the repository at this point in the history
…in path expression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 2b550f3 commit d464649
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions freezing/web/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def _get_cached(key: str, compute):

cache_file = Path(os.path.normpath(Path(cache_dir).joinpath(key))).resolve()

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
.
try:
if not str(cache_file).startswith(str(Path(cache_dir).resolve()) + os.sep):
if os.path.commonpath([str(cache_file), str(Path(cache_dir).resolve())]) != str(Path(cache_dir).resolve()):
raise Exception("Invalid cache file path")
if cache_file.is_file():

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
.
time_stamp = datetime.datetime.fromtimestamp(cache_file.stat().st_mtime)

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
.
Expand All @@ -422,7 +422,7 @@ def _get_cached(key: str, compute):

content = compute()
cache_file.parent.mkdir(parents=True, exist_ok=True)

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
.
if not str(cache_file).startswith(str(Path(cache_dir).resolve()) + os.sep):
if os.path.commonpath([str(cache_file), str(Path(cache_dir).resolve())]) != str(Path(cache_dir).resolve()):
raise Exception("Invalid cache file path")
cache_file.write_bytes(content)

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
.

Expand Down

0 comments on commit d464649

Please sign in to comment.