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

fix(reporter/http): read response body #2108

Merged
merged 1 commit into from
Jan 17, 2025
Merged

fix(reporter/http): read response body #2108

merged 1 commit into from
Jan 17, 2025

Conversation

MaineK00n
Copy link
Collaborator

If this Pull Request is work in progress, Add a prefix of “[WIP]” in the title.

What did you implement:

Fixes #2105

In the current implementation, the response body is not completely read, which can result in the connection being cut off while the Response Writer is still writing. This PR will fix this so that the entire response body is read.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

$ cat config.toml
...
[http]
url = "http://localhost:5515/vuls"
...

$ vuls server -listen localhost:5515
$ vuls report -to-http

before

$ vuls server -listen localhost:5515
...
[Jan 17 10:45:50]  INFO [localhost] vagrant: 0 CVEs are detected with OVAL
[Jan 17 10:45:50]  INFO [localhost] vagrant: 0 unfixed CVEs are detected with gost
[Jan 17 10:45:50]  INFO [localhost] Fill CVE detailed with gost
[Jan 17 10:45:50]  INFO [localhost] Fill CVE detailed with CVE-DB
[Jan 17 10:45:50]  INFO [localhost] vagrant: 0 PoC detected
[Jan 17 10:45:51]  INFO [localhost] vagrant: 0 exploits are detected
[Jan 17 10:45:51]  INFO [localhost] vagrant: Known Exploited Vulnerabilities are detected for 0 CVEs
[Jan 17 10:45:51]  INFO [localhost] vagrant: Cyber Threat Intelligences are detected for 0 CVEs
[Jan 17 10:45:51]  INFO [localhost] vagrant: total 2217 CVEs detected
[Jan 17 10:45:51]  INFO [localhost] vagrant: 0 CVEs filtered by --confidence-over=80
[Jan 17 10:47:04] ERROR [localhost] Failed to report. err: write tcp 127.0.0.1:5515->127.0.0.1:46836: write: connection reset by peer

after

$ vuls server -listen localhost:5515
...
[Jan 17 12:53:59]  INFO [localhost] vagrant: 0 CVEs are detected with OVAL
[Jan 17 12:53:59]  INFO [localhost] vagrant: 0 unfixed CVEs are detected with gost
[Jan 17 12:53:59]  INFO [localhost] Fill CVE detailed with gost
[Jan 17 12:53:59]  INFO [localhost] Fill CVE detailed with CVE-DB
[Jan 17 12:54:00]  INFO [localhost] vagrant: 0 PoC detected
[Jan 17 12:54:00]  INFO [localhost] vagrant: 0 exploits are detected
[Jan 17 12:54:00]  INFO [localhost] vagrant: Known Exploited Vulnerabilities are detected for 0 CVEs
[Jan 17 12:54:00]  INFO [localhost] vagrant: Cyber Threat Intelligences are detected for 0 CVEs
[Jan 17 12:54:00]  INFO [localhost] vagrant: total 2217 CVEs detected
[Jan 17 12:54:00]  INFO [localhost] vagrant: 0 CVEs filtered by --confidence-over=80

Checklist:

You don't have to satisfy all of the following.

  • Write tests
  • Write documentation
  • Check that there aren't other open pull requests for the same issue/feature
  • Format your source code by make fmt
  • Pass the test by make test
  • Provide verification config / commands
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES

Reference

@MaineK00n MaineK00n self-assigned this Jan 17, 2025
@MaineK00n MaineK00n requested a review from shino January 17, 2025 04:02
Copy link
Collaborator

@shino shino left a comment

Choose a reason for hiding this comment

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

Nice fix!!

@MaineK00n MaineK00n merged commit 40e36cc into master Jan 17, 2025
7 checks passed
@MaineK00n MaineK00n deleted the MaineK00n/patch-2 branch January 17, 2025 08:07
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.

Connection refused from client side when sending report via http in server mode
2 participants