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 checkmarx issues. #1672

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
501484c
Fix metadata path
samet-akcay Mar 10, 2023
15ad7e9
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Mar 20, 2023
a6bc69f
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Mar 22, 2023
7b53b78
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Mar 24, 2023
af2022f
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Mar 28, 2023
e4aadca
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Mar 31, 2023
c61472e
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Apr 4, 2023
1e708ba
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Apr 14, 2023
8a3cce7
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Apr 17, 2023
dca5744
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay May 5, 2023
68b7401
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay May 9, 2023
046d72d
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay May 12, 2023
3c4def3
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay May 12, 2023
545f08b
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay May 25, 2023
904e5e7
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jun 2, 2023
8aec0e2
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jun 4, 2023
c065af2
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jun 6, 2023
1efc3aa
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jun 7, 2023
7ea6f15
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jun 15, 2023
4931934
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jun 15, 2023
9ff0f73
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jun 26, 2023
fd5b138
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jun 30, 2023
5e22f99
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jul 5, 2023
a555eaf
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jul 7, 2023
70889d1
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jul 7, 2023
5ca8f5e
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jul 21, 2023
ee42158
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Aug 4, 2023
8efd566
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Aug 7, 2023
6d86c68
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Aug 9, 2023
bca0325
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Aug 10, 2023
aba663d
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Aug 14, 2023
0b6a39d
Ignore hidden directories in folder dataset
samet-akcay Aug 14, 2023
0a699a7
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Aug 15, 2023
ecd8a47
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Aug 15, 2023
d9dd0a2
Add check for mask_dir for segmentation tasks in Folder dataset
samet-akcay Aug 15, 2023
6627a21
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Aug 16, 2023
456f90d
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Aug 17, 2023
6f78670
pull main
samet-akcay Aug 22, 2023
a8e7c13
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Aug 22, 2023
2c70119
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Sep 4, 2023
88eca53
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Sep 4, 2023
21f6df6
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Sep 13, 2023
093f8c1
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Sep 18, 2023
cb0e38c
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Sep 20, 2023
48f825e
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Sep 25, 2023
f86f4cc
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Sep 27, 2023
0737296
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Sep 28, 2023
118cb1c
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Oct 4, 2023
e55f41f
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Nov 3, 2023
216aa62
Limit the gradio version to <4
samet-akcay Nov 3, 2023
d86eb07
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Nov 28, 2023
df486a2
Merge branch 'main' of https://github.com/openvinotoolkit/anomalib
samet-akcay Nov 29, 2023
aff23fe
Merge branch 'main' of github.com:samet-akcay/anomalib
samet-akcay Nov 29, 2023
86b5277
Merge branch 'main' of https://github.com/openvinotoolkit/anomalib
samet-akcay Jan 2, 2024
1bfe7d5
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jan 9, 2024
eb6379b
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jan 10, 2024
89d16c4
Merge branch 'openvinotoolkit:main' into main
samet-akcay Jan 24, 2024
529fbcb
Merge branch 'main' of github.com:samet-akcay/anomalib
samet-akcay Jan 24, 2024
de49b66
Merge branch 'openvinotoolkit:main' into main
samet-akcay Jan 25, 2024
c6519ba
Merge branch 'main' of github.com:openvinotoolkit/anomalib
samet-akcay Jan 25, 2024
640446c
Merge branch 'main' of github.com:samet-akcay/anomalib
samet-akcay Jan 25, 2024
f369eb9
Add should exist flag to validate_path and validate the output paths
samet-akcay Jan 25, 2024
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 src/anomalib/data/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ def generate_output_image_filename(input_path: str | Path, output_path: str | Pa
Returns:
Path: The output filename to save the output predictions from the inferencer.
"""
input_path = Path(input_path)
output_path = Path(output_path)
input_path = validate_path(input_path)
output_path = validate_path(output_path, should_exist=False)

# Input validation: Check if input_path is a valid directory or file
if input_path.is_file() is False:
Expand Down
24 changes: 14 additions & 10 deletions src/anomalib/data/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ def contains_non_printable_characters(path: str | Path) -> bool:
return not printable_pattern.match(str(path))


def validate_path(path: str | Path, base_dir: str | Path | None = None) -> Path:
def validate_path(path: str | Path, base_dir: str | Path | None = None, should_exist: bool = True) -> Path:
"""Validate the path.

Args:
path (str | Path): Path to validate.
base_dir (str | Path): Base directory to restrict file access.
should_exist (bool): If True, do not raise an exception if the path does not exist.

Returns:
Path: Validated path.
Expand Down Expand Up @@ -215,15 +216,18 @@ def validate_path(path: str | Path, base_dir: str | Path | None = None) -> Path:
msg = "Access denied: Path is outside the allowed directory"
raise ValueError(msg)

# Check if the path exists
if not path.exists():
msg = f"Path does not exist: {path}"
raise FileNotFoundError(msg)

# Check the read and execute permissions
if not (os.access(path, os.R_OK) or os.access(path, os.X_OK)):
msg = f"Read or execute permissions denied for the path: {path}"
raise PermissionError(msg)
# In case path ``should_exist``, the path is valid, and should be
# checked for read and execute permissions.
if should_exist:
# Check if the path exists
if not path.exists():
msg = f"Path does not exist: {path}"
raise FileNotFoundError(msg)

# Check the read and execute permissions
if not (os.access(path, os.R_OK) or os.access(path, os.X_OK)):
msg = f"Read or execute permissions denied for the path: {path}"
raise PermissionError(msg)

return path

Expand Down
Loading