-
Notifications
You must be signed in to change notification settings - Fork 151
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
add trusted URL regex #518
add trusted URL regex #518
Conversation
b6b7a5f
to
aaa3a4b
Compare
Signed-off-by: Yaliang Wu <ylwu@amazon.com>
aaa3a4b
to
355d97a
Compare
Codecov Report
@@ Coverage Diff @@
## 2.x #518 +/- ##
============================================
- Coverage 80.06% 78.54% -1.52%
+ Complexity 926 906 -20
============================================
Files 92 92
Lines 3506 3515 +9
Branches 323 323
============================================
- Hits 2807 2761 -46
- Misses 570 631 +61
+ Partials 129 123 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -34,7 +34,7 @@ private MLCommonsSettings() {} | |||
public static final Setting<Long> ML_COMMONS_MONITORING_REQUEST_COUNT = Setting | |||
.longSetting( | |||
"plugins.ml_commons.monitoring_request_count", | |||
10000, | |||
100, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this reduction from 10000 to 100 due to the tuning after performance tests result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is mainly for testing/monitoring purpose, big value will use more memory. So tune the default value to a smaller number. User can tune it if they want to monitor more requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have tests for other ways: file, ftp?
public static final Setting<String> ML_COMMONS_TRUSTED_URL_REGEX = Setting | ||
.simpleString( | ||
"plugins.ml_commons.trusted_url_regex", | ||
"^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this regex cover http & https both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I tested manually , I will add more test cases in next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the question mark means 0 - 1.
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.4 2.4
# Navigate to the new working tree
cd .worktrees/backport-2.4
# Create a new branch
git switch --create backport/backport-518-to-2.4
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a36d11abe2b5ce0892fc89992846d58b939b67d0
# Push it to GitHub
git push --set-upstream origin backport/backport-518-to-2.4
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.4 Then, create a pull request where the |
MLPredictionTaskRequest mlPredictionTaskRequest = getRequest(modelId, algorithm, request); | ||
return channel -> client | ||
.execute(MLPredictionTaskAction.INSTANCE, getRequest(modelId, algorithm, request), new RestToXContentListener<>(channel)); | ||
.execute(MLPredictionTaskAction.INSTANCE, mlPredictionTaskRequest, new RestToXContentListener<>(channel)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because the JVM complier is not able to dynamic resolve getRequest() before executing client.execute()? If that's the case, we need to use another local variable for line 83. https://github.com/opensearch-project/ml-commons/blob/2.x/plugin/src/main/java/org/opensearch/ml/rest/RestMLPredictionAction.java#L83
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for easy testing
Signed-off-by: Yaliang Wu <ylwu@amazon.com> Signed-off-by: Yaliang Wu <ylwu@amazon.com> (cherry picked from commit a36d11a)
Signed-off-by: Yaliang Wu <ylwu@amazon.com> Signed-off-by: Yaliang Wu <ylwu@amazon.com> Signed-off-by: Sicheng Song <sicheng.song@outlook.com>
Signed-off-by: Yaliang Wu ylwu@amazon.com
Description
Address security review comments by adding trusted URL regex, so user can set their own trusted URL regex to avoid uploading model from untrusted source.
Issues Resolved
[List any issues this PR will resolve]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.