* Update trivy 0.35.0->0.48.0
- Specify oras-go 1.2.4 in indirect dependencies
docker/docker changes a part of its API at 24.0
- registry: return concrete service type · moby/moby@7b3acdf
- 7b3acdff5d (diff-8325eae896b1149bf92c826d07fc29005b1b102000b766ffa5a238d791e0849bR18-R21)
oras-go 1.2.3 uses 23.0.1 and trivy transitively depends on docker/docker 24.y.z.
There is a build error between oras-go and docker/dockr.
- Update disabled analyzers
- Update language scanners, enable all of them
* move javadb init to scan.go
* Add options for java db init()
* Update scanner/base.go
* Remove unused codes
* Add some lock file names
* Typo fix
* Remove space character (0x20)
* Add java-db options for integration scan
* Minor fomartting fix
* minor fix
* conda is NOT supported by Trivy for library scan
* Configure trivy log in report command too
* Init trivy in scanner
* Use trivy's jar.go and replace client which does almost nothing
* mv jar.go
* Add sha1 hash to result and add filepath for report phase
* Undo added 'vuls scan' options
* Update oras-go to 1.2.4
* Move Java DB related config items to report side
* Add java db search in detect phase
* filter top level jar only
* Update trivy to 0.49.1
* go mod tidy
* Update to newer interface
* Refine lock file list, h/t MaineK00n
* Avoid else clauses if possible, h/t MaineK00n
* Avoid missing word for find and lang types, h/t MaineK00n
* Add missing ecosystems, h/t MaineK00n
* Add comments why to use custom jar analyzer, h/t MaineK00n
* Misc
* Misc
* Misc
* Include go-dep-parser's pares.go for modification
* Move digest field from LibraryScanner to Library
* Use inner jars sha1 for each
* Add Seek to file head before handling zip file entry
* Leave Digest feild empty for entries from pom.xml
* Don't import python/pkg (don't look into package.json)
* Make privete where private is sufficient
* Remove duplicate after Java DB lookup
* misc
* go mod tidy
* Comment out ruby/gemspec
* misc
* Comment out python/packaging
* misc
* Use custom jar
* Update scanner/trivy/jar/parse.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/trivy/jar/parse.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/trivy/jar/parse.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/trivy/jar/parse.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/trivy/jar/parse.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/trivy/jar/jar.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update detector/library.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update models/library.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/base.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/trivy/jar/parse.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/trivy/jar/parse.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Missing changes in name change
* Update models/github.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update models/library.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update models/library.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update models/library.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/base.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/base.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update scanner/trivy/jar/jar.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Don't import fanal/types at github.go
* Rewrite code around java db initialization
* Add comment
* refactor
* Close java db client
* rename
* Let LibraryScanner have java db client
* Update detector/library.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update detector/library.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update detector/library.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* Update detector/library.go
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
* inline variable
* misc
* Fix typo
---------
Co-authored-by: MaineK00n <mainek00n.1229@gmail.com>
162 lines
4.7 KiB
Go
162 lines
4.7 KiB
Go
//go:build !scanner
|
|
// +build !scanner
|
|
|
|
package subcmds
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/aquasecurity/trivy/pkg/utils/fsutils"
|
|
"github.com/future-architect/vuls/config"
|
|
"github.com/future-architect/vuls/detector"
|
|
"github.com/future-architect/vuls/logging"
|
|
"github.com/future-architect/vuls/models"
|
|
"github.com/future-architect/vuls/reporter"
|
|
"github.com/future-architect/vuls/tui"
|
|
"github.com/google/subcommands"
|
|
)
|
|
|
|
// TuiCmd is Subcommand of host discovery mode
|
|
type TuiCmd struct {
|
|
configPath string
|
|
}
|
|
|
|
// Name return subcommand name
|
|
func (*TuiCmd) Name() string { return "tui" }
|
|
|
|
// Synopsis return synopsis
|
|
func (*TuiCmd) Synopsis() string { return "Run Tui view to analyze vulnerabilities" }
|
|
|
|
// Usage return usage
|
|
func (*TuiCmd) Usage() string {
|
|
return `tui:
|
|
tui
|
|
[-refresh-cve]
|
|
[-config=/path/to/config.toml]
|
|
[-cvss-over=7]
|
|
[-confidence-over=80]
|
|
[-diff]
|
|
[-diff-minus]
|
|
[-diff-plus]
|
|
[-ignore-unscored-cves]
|
|
[-ignore-unfixed]
|
|
[-results-dir=/path/to/results]
|
|
[-log-to-file]
|
|
[-log-dir=/path/to/log]
|
|
[-debug]
|
|
[-debug-sql]
|
|
[-quiet]
|
|
[-no-progress]
|
|
[-pipe]
|
|
[-trivy-cachedb-dir=/path/to/dir]
|
|
|
|
`
|
|
}
|
|
|
|
// SetFlags set flag
|
|
func (p *TuiCmd) SetFlags(f *flag.FlagSet) {
|
|
// f.StringVar(&p.lang, "lang", "en", "[en|ja]")
|
|
f.BoolVar(&config.Conf.DebugSQL, "debug-sql", false, "debug SQL")
|
|
f.BoolVar(&config.Conf.Debug, "debug", false, "debug mode")
|
|
f.BoolVar(&config.Conf.Quiet, "quiet", false, "Quiet mode. No output on stdout")
|
|
f.BoolVar(&config.Conf.NoProgress, "no-progress", false, "Suppress progress bar")
|
|
|
|
defaultLogDir := logging.GetDefaultLogDir()
|
|
f.StringVar(&config.Conf.LogDir, "log-dir", defaultLogDir, "/path/to/log")
|
|
f.BoolVar(&config.Conf.LogToFile, "log-to-file", false, "Output log to file")
|
|
|
|
wd, _ := os.Getwd()
|
|
defaultResultsDir := filepath.Join(wd, "results")
|
|
f.StringVar(&config.Conf.ResultsDir, "results-dir", defaultResultsDir, "/path/to/results")
|
|
|
|
defaultConfPath := filepath.Join(wd, "config.toml")
|
|
f.StringVar(&p.configPath, "config", defaultConfPath, "/path/to/toml")
|
|
|
|
f.BoolVar(&config.Conf.RefreshCve, "refresh-cve", false,
|
|
"Refresh CVE information in JSON file under results dir")
|
|
|
|
f.Float64Var(&config.Conf.CvssScoreOver, "cvss-over", 0,
|
|
"-cvss-over=6.5 means reporting CVSS Score 6.5 and over (default: 0 (means report all))")
|
|
|
|
f.IntVar(&config.Conf.ConfidenceScoreOver, "confidence-over", 80,
|
|
"-confidence-over=40 means reporting Confidence Score 40 and over (default: 80)")
|
|
|
|
f.BoolVar(&config.Conf.Diff, "diff", false,
|
|
"Plus Difference between previous result and current result")
|
|
|
|
f.BoolVar(&config.Conf.DiffPlus, "diff-plus", false,
|
|
"Plus Difference between previous result and current result")
|
|
|
|
f.BoolVar(&config.Conf.DiffMinus, "diff-minus", false,
|
|
"Minus Difference between previous result and current result")
|
|
|
|
f.BoolVar(
|
|
&config.Conf.IgnoreUnscoredCves, "ignore-unscored-cves", false,
|
|
"Don't report the unscored CVEs")
|
|
|
|
f.BoolVar(&config.Conf.IgnoreUnfixed, "ignore-unfixed", false,
|
|
"Don't report the unfixed CVEs")
|
|
|
|
f.BoolVar(&config.Conf.Pipe, "pipe", false, "Use stdin via PIPE")
|
|
|
|
f.StringVar(&config.Conf.TrivyCacheDBDir, "trivy-cachedb-dir",
|
|
fsutils.CacheDir(), "/path/to/dir")
|
|
}
|
|
|
|
// Execute execute
|
|
func (p *TuiCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
|
|
logging.Log = logging.NewCustomLogger(config.Conf.Debug, config.Conf.Quiet, config.Conf.LogToFile, config.Conf.LogDir, "", "")
|
|
logging.Log.Infof("vuls-%s-%s", config.Version, config.Revision)
|
|
if err := config.Load(p.configPath); err != nil {
|
|
logging.Log.Errorf("Error loading %s, err: %+v", p.configPath, err)
|
|
return subcommands.ExitUsageError
|
|
}
|
|
|
|
config.Conf.Lang = "en"
|
|
|
|
if config.Conf.Diff {
|
|
config.Conf.DiffPlus = true
|
|
config.Conf.DiffMinus = true
|
|
}
|
|
var dir string
|
|
var err error
|
|
if config.Conf.DiffPlus || config.Conf.DiffMinus {
|
|
dir, err = reporter.JSONDir(config.Conf.ResultsDir, []string{})
|
|
} else {
|
|
dir, err = reporter.JSONDir(config.Conf.ResultsDir, f.Args())
|
|
}
|
|
if err != nil {
|
|
logging.Log.Errorf("Failed to read from JSON. err: %+v", err)
|
|
return subcommands.ExitFailure
|
|
}
|
|
|
|
logging.Log.Info("Validating config...")
|
|
if !config.Conf.ValidateOnReport() {
|
|
return subcommands.ExitUsageError
|
|
}
|
|
|
|
var res models.ScanResults
|
|
if res, err = reporter.LoadScanResults(dir); err != nil {
|
|
logging.Log.Error(err)
|
|
return subcommands.ExitFailure
|
|
}
|
|
logging.Log.Infof("Loaded: %s", dir)
|
|
|
|
if res, err = detector.Detect(res, dir); err != nil {
|
|
logging.Log.Error(err)
|
|
return subcommands.ExitFailure
|
|
}
|
|
|
|
for _, r := range res {
|
|
if len(r.Warnings) != 0 {
|
|
logging.Log.Warnf("Warning: Some warnings occurred while scanning on %s: %s",
|
|
r.FormatServerName(), r.Warnings)
|
|
}
|
|
}
|
|
|
|
return tui.RunTui(res)
|
|
}
|