Skip to content

fix: Security Fixes for RESTful APIs #41136

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

Merged
merged 5 commits into from
May 7, 2025
Merged

Conversation

divyaruhil
Copy link
Contributor

Fix for Issue :- #41128

@sre-ci-robot
Copy link
Contributor

Welcome @divyaruhil! It looks like this is your first PR to milvus-io/milvus 🎉

@sre-ci-robot sre-ci-robot added the size/XS Denotes a PR that changes 0-9 lines. label Apr 7, 2025
Copy link
Contributor

mergify bot commented Apr 7, 2025

@divyaruhil Thanks for your contribution. Please submit with DCO, see the contributing guide https://github.com/milvus-io/milvus/blob/master/CONTRIBUTING.md#developer-certificate-of-origin-dco.

@mergify mergify bot added the needs-dco DCO is missing in this pull request. label Apr 7, 2025
Copy link
Contributor

mergify bot commented Apr 7, 2025

@divyaruhil

Invalid PR Title Format Detected

Your PR submission does not adhere to our required standards. To ensure clarity and consistency, please meet the following criteria:

  1. Title Format: The PR title must begin with one of these prefixes:
  • feat: for introducing a new feature.
  • fix: for bug fixes.
  • enhance: for improvements to existing functionality.
  • test: for add tests to existing functionality.
  • doc: for modifying documentation.
  • auto: for the pull request from bot.
  1. Description Requirement: The PR must include a non-empty description, detailing the changes and their impact.

Required Title Structure:

[Type]: [Description of the PR]

Where Type is one of feat, fix, enhance, test or doc.

Example:

enhance: improve search performance significantly 

Please review and update your PR to comply with these guidelines.

@sre-ci-robot sre-ci-robot requested review from cydrain and czs007 April 7, 2025 09:46
@mergify mergify bot added dco-passed DCO check passed. and removed needs-dco DCO is missing in this pull request. labels Apr 7, 2025
Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 78.94737% with 8 lines in your changes missing coverage. Please review.

Project coverage is 80.57%. Comparing base (1e65e32) to head (65c145e).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
internal/distributed/proxy/httpserver/utils.go 27.27% 7 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #41136       +/-   ##
===========================================
+ Coverage   73.93%   80.57%    +6.64%     
===========================================
  Files         330     1509     +1179     
  Lines       30068   213372   +183304     
===========================================
+ Hits        22230   171929   +149699     
- Misses       7838    35267    +27429     
- Partials        0     6176     +6176     
Components Coverage Δ
Client 79.38% <ø> (∅)
Core 73.89% <ø> (-0.04%) ⬇️
Go 81.91% <78.94%> (∅)
Files with missing lines Coverage Δ
pkg/util/paramtable/http_param.go 100.00% <100.00%> (ø)
internal/distributed/proxy/httpserver/utils.go 83.96% <27.27%> (ø)

... and 1179 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@divyaruhil
Copy link
Contributor Author

Hey @cydrain @czs007 , Whenever your schedule allows, I'd be grateful for your review.

@divyaruhil divyaruhil changed the title Security Fixes for RESTful APIs Fix: Security Fixes for RESTful APIs Apr 8, 2025
@divyaruhil divyaruhil changed the title Fix: Security Fixes for RESTful APIs fix: Security Fixes for RESTful APIs Apr 8, 2025
@mergify mergify bot added kind/bug Issues or changes related a bug and removed do-not-merge/invalid-pr-format labels Apr 8, 2025
@czs007
Copy link
Collaborator

czs007 commented Apr 9, 2025

@divyaruhil thanks.

There appears to be a minor issue with the code formatting. Please refer to the information provided below:
diff internal/distributed/proxy/httpserver/utils.go.orig internal/distributed/proxy/httpserver/utils.go
--- internal/distributed/proxy/httpserver/utils.go.orig
+++ internal/distributed/proxy/httpserver/utils.go
@@ -1749,7 +1749,7 @@
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
c.Writer.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, OPTIONS, PATCH")
c.Writer.Header().Set("Strict-Transport-Security", "max-age=31536000; includeSubDomains") // Ensures HTTPS usage

  • c.Writer.Header().Set("X-Content-Type-Options", "nosniff") // Prevents MIME sniffing
  • c.Writer.Header().Set("X-Content-Type-Options", "nosniff") // Prevents MIME sniffing
    if c.Request.Method == "OPTIONS" {
    c.AbortWithStatus(204)
    return
    make: *** [Makefile:156: fmt] Error 1

Some files have not been gofmt'd. To fix these errors,
copy and paste the following:
gofmt -s -w internal/distributed/proxy/httpserver/utils.go

@@ -1748,6 +1748,8 @@ func RequestHandlerFunc(c *gin.Context) {
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
c.Writer.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, OPTIONS, PATCH")
c.Writer.Header().Set("Strict-Transport-Security", "max-age=31536000; includeSubDomains") // Ensures HTTPS usage
Copy link
Collaborator

@czs007 czs007 Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is recommended that Strict-Transport-Security, max-age, and includeSubDomains be made configurable. This way, open source users can modify them as needed.

@divyaruhil
Copy link
Contributor Author

Thankyou @czs007 , for the review comments, i'll make the required changes.

@sre-ci-robot sre-ci-robot added size/M Denotes a PR that changes 30-99 lines. and removed size/XS Denotes a PR that changes 0-9 lines. labels Apr 10, 2025
Copy link
Contributor

mergify bot commented Apr 10, 2025

@divyaruhil Thanks for your contribution. Please submit with DCO, see the contributing guide https://github.com/milvus-io/milvus/blob/master/CONTRIBUTING.md#developer-certificate-of-origin-dco.

@mergify mergify bot added needs-dco DCO is missing in this pull request. and removed dco-passed DCO check passed. labels Apr 10, 2025
@mergify mergify bot added dco-passed DCO check passed. and removed needs-dco DCO is missing in this pull request. labels Apr 10, 2025
@divyaruhil divyaruhil requested a review from czs007 April 10, 2025 10:00
@divyaruhil
Copy link
Contributor Author

Hi @czs007, I've made the updates based on your review comments. Please let me know if there's anything else you'd like me to address.

Copy link
Contributor

mergify bot commented Apr 28, 2025

@divyaruhil E2e jenkins job failed, comment /run-cpu-e2e can trigger the job again.

Copy link
Contributor

mergify bot commented Apr 28, 2025

@divyaruhil go-sdk check failed, comment rerun go-sdk can trigger the job again.

Copy link
Contributor

mergify bot commented Apr 28, 2025

@divyaruhil cpp-unit-test check failed, comment rerun cpp-unit-test can trigger the job again.

Copy link
Contributor

mergify bot commented Apr 28, 2025

@divyaruhil E2e jenkins job failed, comment /run-cpu-e2e can trigger the job again.

Copy link
Contributor

mergify bot commented Apr 28, 2025

@divyaruhil go-sdk check failed, comment rerun go-sdk can trigger the job again.

Copy link
Contributor

mergify bot commented Apr 28, 2025

@divyaruhil cpp-unit-test check failed, comment rerun cpp-unit-test can trigger the job again.

Copy link
Contributor

mergify bot commented Apr 29, 2025

@divyaruhil cpp-unit-test check failed, comment rerun cpp-unit-test can trigger the job again.

@divyaruhil
Copy link
Contributor Author

Hey @czs007, When you have a moment, could you please take a look and review this? I'd really appreciate your feedback.

@sre-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: czs007, divyaruhil

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@czs007
Copy link
Collaborator

czs007 commented Apr 30, 2025

/lgtm

@divyaruhil
Copy link
Contributor Author

divyaruhil commented Apr 30, 2025

Hi @czs007, thank you for approving the PR and for your help! It looks like the integration test is failing, but it doesn’t seem related to our changes. Would it be possible to re-trigger the test?

@divyaruhil
Copy link
Contributor Author

hi @cydrain , can u please have a look at this PR , whenever your time allows and approve it for merging , also Integration test seems to be failing but that's not related to any of the changes we made , is there a way we can re-trigger it ?

@divyaruhil
Copy link
Contributor Author

hi @czs007 , Please let me know if anything else is required from my end .

divyaruhil added 5 commits May 5, 2025 22:19
Signed-off-by: Divya <divyaruhil999@gmail.com>
Signed-off-by: Divya <divyaruhil999@gmail.com>
Signed-off-by: Divya <divyaruhil999@gmail.com>
Signed-off-by: Divya <divyaruhil999@gmail.com>
Signed-off-by: Divya <divyaruhil999@gmail.com>
@czs007
Copy link
Collaborator

czs007 commented May 7, 2025

/lgtm

@mergify mergify bot added the ci-passed label May 7, 2025
@sre-ci-robot sre-ci-robot merged commit 3e67024 into milvus-io:master May 7, 2025
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/compilation area/internal-api area/test ci-passed dco-passed DCO check passed. kind/bug Issues or changes related a bug lgtm sig/testing size/M Denotes a PR that changes 30-99 lines. test/integration integration test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants