From dc9c0edece3844e5ee7a4849d1bb68c50b2a9db4 Mon Sep 17 00:00:00 2001 From: otuki <58715442+tttfrfr2@users.noreply.github.com> Date: Wed, 28 Apr 2021 13:41:38 +0900 Subject: [PATCH] refactor(git-conf): Specifing ignoreGitHubDismissed per repository (#1224) * refactor(git-conf): Specifing ignoreGitHubDismissed per repository with config.toml * refactor(git-conf): change json tag into camelCase * refactor(git-conf): change first char of json tag into lowercase --- config/config.go | 6 ++---- detector/detector.go | 6 +++--- subcmds/report.go | 4 ---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/config/config.go b/config/config.go index 8bd92f01..475e7f40 100644 --- a/config/config.go +++ b/config/config.go @@ -79,9 +79,6 @@ type ReportOpts struct { DiffMinus bool `json:"diffMinus,omitempty"` Diff bool `json:"diff,omitempty"` Lang string `json:"lang,omitempty"` - - //TODO move to GitHubConf - IgnoreGitHubDismissed bool `json:"ignore_git_hub_dismissed,omitempty"` } // ValidateOnConfigtest validates @@ -262,7 +259,8 @@ func (cnf WordPressConf) IsZero() bool { // GitHubConf is used for GitHub Security Alerts type GitHubConf struct { - Token string `json:"-"` + Token string `json:"-"` + IgnoreGitHubDismissed bool `json:"ignoreGitHubDismissed,omitempty"` } // GetServerName returns ServerName if this serverInfo is about host. diff --git a/detector/detector.go b/detector/detector.go index 12c5a186..dc413089 100644 --- a/detector/detector.go +++ b/detector/detector.go @@ -70,7 +70,7 @@ func Detect(rs []models.ScanResult, dir string) ([]models.ScanResult, error) { } repos := config.Conf.Servers[r.ServerName].GitHubRepos - if err := DetectGitHubCves(&r, repos, config.Conf.IgnoreGitHubDismissed); err != nil { + if err := DetectGitHubCves(&r, repos); err != nil { return nil, xerrors.Errorf("Failed to detect GitHub Cves: %w", err) } @@ -219,7 +219,7 @@ func DetectPkgCves(r *models.ScanResult, ovalCnf config.GovalDictConf, gostCnf c } // DetectGitHubCves fetches CVEs from GitHub Security Alerts -func DetectGitHubCves(r *models.ScanResult, githubConfs map[string]config.GitHubConf, ignoreDismissed bool) error { +func DetectGitHubCves(r *models.ScanResult, githubConfs map[string]config.GitHubConf) error { if len(githubConfs) == 0 { return nil } @@ -229,7 +229,7 @@ func DetectGitHubCves(r *models.ScanResult, githubConfs map[string]config.GitHub return xerrors.Errorf("Failed to parse GitHub owner/repo: %s", ownerRepo) } owner, repo := ss[0], ss[1] - n, err := DetectGitHubSecurityAlerts(r, owner, repo, setting.Token, ignoreDismissed) + n, err := DetectGitHubSecurityAlerts(r, owner, repo, setting.Token, setting.IgnoreGitHubDismissed) if err != nil { return xerrors.Errorf("Failed to access GitHub Security Alerts: %w", err) } diff --git a/subcmds/report.go b/subcmds/report.go index 6a67bda1..3a0818f2 100644 --- a/subcmds/report.go +++ b/subcmds/report.go @@ -63,7 +63,6 @@ func (*ReportCmd) Usage() string { [-diff-plus] [-ignore-unscored-cves] [-ignore-unfixed] - [-ignore-github-dismissed] [-to-email] [-to-http] [-to-slack] @@ -131,9 +130,6 @@ func (p *ReportCmd) SetFlags(f *flag.FlagSet) { f.BoolVar(&config.Conf.IgnoreUnfixed, "ignore-unfixed", false, "Don't report the unfixed CVEs") - f.BoolVar(&config.Conf.IgnoreGitHubDismissed, "ignore-github-dismissed", false, - "Don't report the dismissed CVEs on GitHub Security Alerts") - f.StringVar( &config.Conf.HTTPProxy, "http-proxy", "", "http://proxy-url:port (default: empty)")