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

Fixed Issue #1555 #1557

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cmd/osv-scanner/internal/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ var OfflineFlags = map[string]string{
// "experimental-licenses": "", // StringSliceFlag has to be manually cleared.
}

// sets default port(8000) as a global variable
var (
servePort = "8000" // default port
)

var GlobalScanFlags = []cli.Flag{
&cli.StringFlag{
Name: "config",
Expand All @@ -45,6 +50,14 @@ var GlobalScanFlags = []cli.Flag{
Name: "serve",
Usage: "output as HTML result and serve it locally",
},
&cli.StringFlag{
Name: "port",
Usage: "port number to use when serving HTML report (default: 8000)",
Action: func(_ *cli.Context, p string) error {
servePort = p
return nil
},
},
&cli.StringFlag{
Name: "output",
Usage: "saves the result to the given file path",
Expand Down Expand Up @@ -129,7 +142,6 @@ func OpenHTML(r reporter.Reporter, outputPath string) {
// The program will keep running to serve the HTML report on localhost
// until the user manually terminates it (e.g. using Ctrl+C).
func ServeHTML(r reporter.Reporter, outputPath string) {
servePort := "8000"
localhostURL := fmt.Sprintf("http://localhost:%s/", servePort)
r.Infof("Serving HTML report at %s.\nIf you are accessing remotely, use the following SSH command:\n`ssh -L local_port:destination_server_ip:%s ssh_server_hostname`\n", localhostURL, servePort)
server := &http.Server{
Expand Down