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

feat: improve ML CLI and add a README.md #355

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

raphael0202
Copy link
Contributor

No description provided.

@raphael0202 raphael0202 requested a review from a team as a code owner November 4, 2024 17:44
@raphael0202 raphael0202 merged commit 7a6aca2 into develop Nov 4, 2024
3 of 4 checks passed
@raphael0202 raphael0202 deleted the improve-ml-utils-cli branch November 4, 2024 17:44

extra_meta = {}
image_id = Path(urlparse(url).path).stem
if ".openfoodfacts.org" in url:

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

The string
.openfoodfacts.org
may be at an arbitrary position in the sanitized URL.

Copilot Autofix AI 4 months ago

To fix the problem, we need to parse the URL and check the host value instead of using a substring match. This can be done using the urlparse function from the urllib.parse module to extract the hostname and then verify if it ends with .openfoodfacts.org. This approach ensures that the check is performed on the correct part of the URL and prevents bypassing the validation with crafted URLs.

Suggested changeset 1
ml_utils/ml_utils_cli/cli/apps/projects.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/ml_utils/ml_utils_cli/cli/apps/projects.py b/ml_utils/ml_utils_cli/cli/apps/projects.py
--- a/ml_utils/ml_utils_cli/cli/apps/projects.py
+++ b/ml_utils/ml_utils_cli/cli/apps/projects.py
@@ -322,3 +322,4 @@
             image_id = Path(urlparse(url).path).stem
-            if ".openfoodfacts.org" in url:
+            host = urlparse(url).hostname
+            if host and host.endswith(".openfoodfacts.org"):
                 barcode = extract_barcode_from_url(url)
EOF
@@ -322,3 +322,4 @@
image_id = Path(urlparse(url).path).stem
if ".openfoodfacts.org" in url:
host = urlparse(url).hostname
if host and host.endswith(".openfoodfacts.org"):
barcode = extract_barcode_from_url(url)
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
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.

1 participant