Skip to content

Commit

Permalink
Merge pull request #1 from Riddhimaan-Senapati/Riddhimaan-Senapati-fi…
Browse files Browse the repository at this point in the history
…xed_issue_#1555

fixed issue #1555
  • Loading branch information
Riddhimaan-Senapati authored Jan 31, 2025
2 parents a5d0e2b + b00bcb8 commit 8e09ce1
Showing 1 changed file with 13 additions and 1 deletion.
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

0 comments on commit 8e09ce1

Please sign in to comment.