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(output): auto-open HTML file after scan #1412

Open
wants to merge 4 commits into
base: v2
Choose a base branch
from

Conversation

hogo6002
Copy link
Contributor

@hogo6002 hogo6002 commented Nov 20, 2024

Added support to automatically open the HTML file in users' default browser after a scan finishes.

If the host flag is enabled, the HTML file will be saved in a temporary directory and then served on localhost.

If only specified the --format html, open the generated HTML file by using the right open command for each OS (like xdg-open for Linux, start for Windows, and open for macOS). Simultaneously, the file is served on localhost for easy remote access.

@codecov-commenter
Copy link

codecov-commenter commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 2.22222% with 44 lines in your changes missing coverage. Please review.

Project coverage is 69.76%. Comparing base (fe13252) to head (1d97d0d).

Files with missing lines Patch % Lines
cmd/osv-scanner/scan/main.go 2.22% 42 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v2    #1412      +/-   ##
==========================================
- Coverage   69.92%   69.76%   -0.17%     
==========================================
  Files         186      186              
  Lines       18518    18562      +44     
==========================================
  Hits        12949    12949              
- Misses       4874     4916      +42     
- Partials      695      697       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hogo6002
Copy link
Contributor Author

Hmm, thinking a bit more, if we host it on a localhost port, users could potentially use SSH port forwarding to access the website if they are remotely accessing the server. But I don't know how likely this case would be.
ssh -L local_port:destination_server_ip:remote_port ssh_server_hostname

@oliverchang
Copy link
Collaborator

Hmm, thinking a bit more, if we host it on a localhost port, users could potentially use SSH port forwarding to access the website if they are remotely accessing the server. But I don't know how likely this case would be. ssh -L local_port:destination_server_ip:remote_port ssh_server_hostname

This is the workflow I typically use whenever I need to inspect a web page generated by some tool (e.g. documentation)

@hogo6002
Copy link
Contributor Author

This is the workflow I typically use whenever I need to inspect a web page generated by some tool (e.g. documentation)

Updated code to also host the HTML file on localhost

cmd/osv-scanner/scan/main.go Outdated Show resolved Hide resolved
cmd/osv-scanner/scan/main.go Show resolved Hide resolved
Copy link
Collaborator

@another-rex another-rex left a comment

Choose a reason for hiding this comment

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

Let's add a flag --host or similar where we assume output is a temporary file, format is html, and run the hosting part of the code

@another-rex another-rex changed the base branch from main to v2 December 3, 2024 05:27
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.

4 participants