Skip to content

Commit 8e09ce1

Browse files
Merge pull request #1 from Riddhimaan-Senapati/Riddhimaan-Senapati-fixed_issue_#1555
fixed issue google#1555
2 parents a5d0e2b + b00bcb8 commit 8e09ce1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cmd/osv-scanner/internal/helper/helper.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ var OfflineFlags = map[string]string{
2222
// "experimental-licenses": "", // StringSliceFlag has to be manually cleared.
2323
}
2424

25+
// sets default port(8000) as a global variable
26+
var (
27+
servePort = "8000" // default port
28+
)
29+
2530
var GlobalScanFlags = []cli.Flag{
2631
&cli.StringFlag{
2732
Name: "config",
@@ -45,6 +50,14 @@ var GlobalScanFlags = []cli.Flag{
4550
Name: "serve",
4651
Usage: "output as HTML result and serve it locally",
4752
},
53+
&cli.StringFlag{
54+
Name: "port",
55+
Usage: "port number to use when serving HTML report (default: 8000)",
56+
Action: func(_ *cli.Context, p string) error {
57+
servePort = p
58+
return nil
59+
},
60+
},
4861
&cli.StringFlag{
4962
Name: "output",
5063
Usage: "saves the result to the given file path",
@@ -129,7 +142,6 @@ func OpenHTML(r reporter.Reporter, outputPath string) {
129142
// The program will keep running to serve the HTML report on localhost
130143
// until the user manually terminates it (e.g. using Ctrl+C).
131144
func ServeHTML(r reporter.Reporter, outputPath string) {
132-
servePort := "8000"
133145
localhostURL := fmt.Sprintf("http://localhost:%s/", servePort)
134146
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)
135147
server := &http.Server{

0 commit comments

Comments
 (0)