diff --git a/GNUmakefile b/GNUmakefile
index 12da3108..3e34f03d 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -20,19 +20,23 @@ BUILDTIME := $(shell date "+%Y%m%d_%H%M%S")
LDFLAGS := -X 'github.com/future-architect/vuls/config.Version=$(VERSION)' \
-X 'github.com/future-architect/vuls/config.Revision=build-$(BUILDTIME)_$(REVISION)'
GO := GO111MODULE=on go
+CGO_UNABLED := CGO_ENABLED=0 go
GO_OFF := GO111MODULE=off go
all: build
-build: main.go pretest fmt
- $(GO) build -a -ldflags "$(LDFLAGS)" -o vuls $<
+build: ./cmd/vuls/main.go pretest fmt
+ $(GO) build -a -ldflags "$(LDFLAGS)" -o vuls ./cmd/vuls
-b: main.go pretest fmt
- $(GO) build -ldflags "$(LDFLAGS)" -o vuls $<
+install: ./cmd/vuls/main.go pretest fmt
+ $(GO) install -ldflags "$(LDFLAGS)" ./cmd/vuls
-install: main.go pretest
- $(GO) install -ldflags "$(LDFLAGS)"
+build-scanner: ./cmd/scanner/main.go pretest fmt
+ $(CGO_UNABLED) build -tags=scanner -a -ldflags "$(LDFLAGS)" -o vuls ./cmd/scanner
+
+install-scanner: ./cmd/scanner/main.go pretest fmt
+ $(CGO_UNABLED) install -tags=scanner -ldflags "$(LDFLAGS)" ./cmd/scanner
lint:
$(GO_OFF) get -u golang.org/x/lint/golint
diff --git a/main.go b/cmd/scanner/main.go
similarity index 79%
rename from main.go
rename to cmd/scanner/main.go
index a6ddc35b..99d4b41b 100644
--- a/main.go
+++ b/cmd/scanner/main.go
@@ -7,8 +7,8 @@ import (
"context"
- "github.com/future-architect/vuls/commands"
"github.com/future-architect/vuls/config"
+ commands "github.com/future-architect/vuls/subcmds"
"github.com/google/subcommands"
)
@@ -17,12 +17,9 @@ func main() {
subcommands.Register(subcommands.FlagsCommand(), "")
subcommands.Register(subcommands.CommandsCommand(), "")
subcommands.Register(&commands.DiscoverCmd{}, "discover")
- subcommands.Register(&commands.TuiCmd{}, "tui")
subcommands.Register(&commands.ScanCmd{}, "scan")
subcommands.Register(&commands.HistoryCmd{}, "history")
- subcommands.Register(&commands.ReportCmd{}, "report")
subcommands.Register(&commands.ConfigtestCmd{}, "configtest")
- subcommands.Register(&commands.ServerCmd{}, "server")
var v = flag.Bool("v", false, "Show version")
diff --git a/exploit/exploit.go b/exploit/exploit.go
index c2d2c617..017e7d35 100644
--- a/exploit/exploit.go
+++ b/exploit/exploit.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package exploit
import (
diff --git a/gost/base.go b/gost/base.go
index 59833d8a..d9306088 100644
--- a/gost/base.go
+++ b/gost/base.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package gost
import (
diff --git a/gost/debian.go b/gost/debian.go
index 5c50537b..b991e958 100644
--- a/gost/debian.go
+++ b/gost/debian.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package gost
import (
diff --git a/gost/gost.go b/gost/gost.go
index 9b559cfd..a5387ada 100644
--- a/gost/gost.go
+++ b/gost/gost.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package gost
import (
diff --git a/gost/microsoft.go b/gost/microsoft.go
index 7cfd5d7e..ea920284 100644
--- a/gost/microsoft.go
+++ b/gost/microsoft.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package gost
import (
diff --git a/gost/pseudo.go b/gost/pseudo.go
index 74a3875c..dc9358fb 100644
--- a/gost/pseudo.go
+++ b/gost/pseudo.go
@@ -1,8 +1,8 @@
+// +build !scanner
+
package gost
import (
- "strings"
-
"github.com/future-architect/vuls/models"
"github.com/knqyf263/gost/db"
)
@@ -16,7 +16,3 @@ type Pseudo struct {
func (pse Pseudo) DetectUnfixed(driver db.DB, r *models.ScanResult, _ bool) (int, error) {
return 0, nil
}
-
-func major(osVer string) (majorVersion string) {
- return strings.Split(osVer, ".")[0]
-}
diff --git a/gost/redhat.go b/gost/redhat.go
index 2a3fc729..726a7dde 100644
--- a/gost/redhat.go
+++ b/gost/redhat.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package gost
import (
diff --git a/gost/util.go b/gost/util.go
index 46a188b0..0db2ec06 100644
--- a/gost/util.go
+++ b/gost/util.go
@@ -2,6 +2,7 @@ package gost
import (
"net/http"
+ "strings"
"time"
"github.com/cenkalti/backoff"
@@ -181,3 +182,7 @@ func httpGet(url string, req request, resChan chan<- response, errChan chan<- er
json: body,
}
}
+
+func major(osVer string) (majorVersion string) {
+ return strings.Split(osVer, ".")[0]
+}
diff --git a/models/utils.go b/models/utils.go
index de7937b6..880f704b 100644
--- a/models/utils.go
+++ b/models/utils.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package models
import (
diff --git a/msf/empty.go b/msf/empty.go
new file mode 100644
index 00000000..565ac70f
--- /dev/null
+++ b/msf/empty.go
@@ -0,0 +1 @@
+package msf
diff --git a/msf/msf.go b/msf/msf.go
index 194586ac..a704765f 100644
--- a/msf/msf.go
+++ b/msf/msf.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package msf
import (
diff --git a/oval/alpine.go b/oval/alpine.go
index 648b1a11..3e7cd21d 100644
--- a/oval/alpine.go
+++ b/oval/alpine.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package oval
import (
diff --git a/oval/debian.go b/oval/debian.go
index b1573612..a86aa7ff 100644
--- a/oval/debian.go
+++ b/oval/debian.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package oval
import (
diff --git a/oval/debian_test.go b/oval/debian_test.go
index df9d4959..51fa5a67 100644
--- a/oval/debian_test.go
+++ b/oval/debian_test.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package oval
import (
diff --git a/oval/empty.go b/oval/empty.go
new file mode 100644
index 00000000..5df0f81b
--- /dev/null
+++ b/oval/empty.go
@@ -0,0 +1 @@
+package oval
diff --git a/oval/oval.go b/oval/oval.go
index 72aa5efb..b9263c8c 100644
--- a/oval/oval.go
+++ b/oval/oval.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package oval
import (
diff --git a/oval/redhat.go b/oval/redhat.go
index ff519618..cd1cd5df 100644
--- a/oval/redhat.go
+++ b/oval/redhat.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package oval
import (
diff --git a/oval/redhat_test.go b/oval/redhat_test.go
index 9e50a796..fdf8fe9f 100644
--- a/oval/redhat_test.go
+++ b/oval/redhat_test.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package oval
import (
diff --git a/oval/suse.go b/oval/suse.go
index 02925e9f..9de65619 100644
--- a/oval/suse.go
+++ b/oval/suse.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package oval
import (
diff --git a/oval/util.go b/oval/util.go
index 1f74a080..bdba1f61 100644
--- a/oval/util.go
+++ b/oval/util.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package oval
import (
diff --git a/oval/util_test.go b/oval/util_test.go
index bf1caa88..a919c6f3 100644
--- a/oval/util_test.go
+++ b/oval/util_test.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package oval
import (
diff --git a/report/cve_client.go b/report/cve_client.go
index 2d223e00..84b9bdca 100644
--- a/report/cve_client.go
+++ b/report/cve_client.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package report
import (
diff --git a/report/db_client.go b/report/db_client.go
index 4b5f4c60..97c6f9f5 100644
--- a/report/db_client.go
+++ b/report/db_client.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package report
import (
diff --git a/report/report.go b/report/report.go
index a7756818..72b695ba 100644
--- a/report/report.go
+++ b/report/report.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package report
import (
@@ -36,11 +38,6 @@ import (
"golang.org/x/xerrors"
)
-const (
- vulsOpenTag = ""
- vulsCloseTag = ""
-)
-
// FillCveInfos fills CVE Detailed Information
func FillCveInfos(dbclient DBClient, rs []models.ScanResult, dir string) ([]models.ScanResult, error) {
diff --git a/report/util.go b/report/util.go
index 6ad66bbd..07bc8ffe 100644
--- a/report/util.go
+++ b/report/util.go
@@ -22,7 +22,11 @@ import (
"golang.org/x/xerrors"
)
-const maxColWidth = 100
+const (
+ vulsOpenTag = ""
+ vulsCloseTag = ""
+ maxColWidth = 100
+)
func formatScanSummary(rs ...models.ScanResult) string {
table := uitable.New()
@@ -555,7 +559,7 @@ func getDiffCves(previous, current models.ScanResult) models.VulnInfos {
// TODO commented out because a bug of diff logic when multiple oval defs found for a certain CVE-ID and same updated_at
// if these OVAL defs have different affected packages, this logic detects as updated.
- // This logic will be uncomented after integration with ghost https://github.com/knqyf263/gost
+ // This logic will be uncomented after integration with gost https://github.com/knqyf263/gost
// } else if isCveFixed(v, previous) {
// updated[v.CveID] = v
// util.Log.Debugf("fixed: %s", v.CveID)
diff --git a/server/empty.go b/server/empty.go
new file mode 100644
index 00000000..abb4e431
--- /dev/null
+++ b/server/empty.go
@@ -0,0 +1 @@
+package server
diff --git a/server/server.go b/server/server.go
index 1d625ff9..a8b084ed 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1,3 +1,5 @@
+// +build !scanner
+
package server
import (
diff --git a/commands/configtest.go b/subcmds/configtest.go
similarity index 99%
rename from commands/configtest.go
rename to subcmds/configtest.go
index 8839f746..f51a8ceb 100644
--- a/commands/configtest.go
+++ b/subcmds/configtest.go
@@ -1,4 +1,4 @@
-package commands
+package subcmds
import (
"context"
diff --git a/commands/discover.go b/subcmds/discover.go
similarity index 99%
rename from commands/discover.go
rename to subcmds/discover.go
index 0d6e000a..2c73b84a 100644
--- a/commands/discover.go
+++ b/subcmds/discover.go
@@ -1,4 +1,4 @@
-package commands
+package subcmds
import (
"context"
diff --git a/commands/history.go b/subcmds/history.go
similarity index 99%
rename from commands/history.go
rename to subcmds/history.go
index 8aef60be..616aca04 100644
--- a/commands/history.go
+++ b/subcmds/history.go
@@ -1,4 +1,4 @@
-package commands
+package subcmds
import (
"context"
diff --git a/commands/report.go b/subcmds/report.go
similarity index 99%
rename from commands/report.go
rename to subcmds/report.go
index ae1d6eac..2fec8a65 100644
--- a/commands/report.go
+++ b/subcmds/report.go
@@ -1,4 +1,6 @@
-package commands
+// +build !scanner
+
+package subcmds
import (
"context"
diff --git a/commands/scan.go b/subcmds/scan.go
similarity index 99%
rename from commands/scan.go
rename to subcmds/scan.go
index 510a5d33..23f6d13a 100644
--- a/commands/scan.go
+++ b/subcmds/scan.go
@@ -1,4 +1,4 @@
-package commands
+package subcmds
import (
"context"
diff --git a/commands/server.go b/subcmds/server.go
similarity index 99%
rename from commands/server.go
rename to subcmds/server.go
index 9ed06149..5bd6268d 100644
--- a/commands/server.go
+++ b/subcmds/server.go
@@ -1,4 +1,6 @@
-package commands
+// +build !scanner
+
+package subcmds
import (
"context"
diff --git a/commands/tui.go b/subcmds/tui.go
similarity index 99%
rename from commands/tui.go
rename to subcmds/tui.go
index f69e63cf..0b8d7b65 100644
--- a/commands/tui.go
+++ b/subcmds/tui.go
@@ -1,4 +1,6 @@
-package commands
+// +build !scanner
+
+package subcmds
import (
"context"
diff --git a/commands/util.go b/subcmds/util.go
similarity index 97%
rename from commands/util.go
rename to subcmds/util.go
index 14e6dfef..908808bc 100644
--- a/commands/util.go
+++ b/subcmds/util.go
@@ -1,4 +1,4 @@
-package commands
+package subcmds
import (
"fmt"