Skip to content

Commit 5119155

Browse files
authored
refactor: remove GraphQL-based GitHub detection, add Dependency.PURL (#2502)
* refactor: remove GitHub GraphQL dependency graph detection logic and add PURL field * go mod tidy * fix: remove GitHub config template from discover command
1 parent c7e3461 commit 5119155

File tree

7 files changed

+4
-451
lines changed

7 files changed

+4
-451
lines changed

config/config.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ type ServerInfo struct {
247247
Containers map[string]ContainerSetting `toml:"containers,omitempty" json:"containers,omitempty"`
248248
IgnoreCves []string `toml:"ignoreCves,omitempty" json:"ignoreCves,omitempty"`
249249
IgnorePkgsRegexp []string `toml:"ignorePkgsRegexp,omitempty" json:"ignorePkgsRegexp,omitempty"`
250-
GitHubRepos map[string]GitHubConf `toml:"githubs" json:"githubs,omitempty"` // key: owner/repo
251250
UUIDs map[string]string `toml:"uuids,omitempty" json:"uuids,omitempty"`
252251
Memo string `toml:"memo,omitempty" json:"memo,omitempty"`
253252
Enablerepo []string `toml:"enablerepo,omitempty" json:"enablerepo,omitempty"` // For CentOS, Alma, Rocky, RHEL, Amazon
@@ -294,12 +293,6 @@ func (cnf WordPressConf) IsZero() bool {
294293
return cnf.OSUser == "" && cnf.DocRoot == "" && cnf.CmdPath == ""
295294
}
296295

297-
// GitHubConf is used for GitHub Security Alerts
298-
type GitHubConf struct {
299-
Token string `json:"-"`
300-
IgnoreGitHubDismissed bool `json:"ignoreGitHubDismissed,omitempty"`
301-
}
302-
303296
// GetServerName returns ServerName if this serverInfo is about host.
304297
// If this serverInfo is about a container, returns containerID@ServerName
305298
func (s ServerInfo) GetServerName() string {

config/tomlloader.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,6 @@ func (c TOMLLoader) Load(pathToToml string) error {
115115
}
116116
}
117117

118-
for ownerRepo, githubSetting := range server.GitHubRepos {
119-
if ss := strings.Split(ownerRepo, "/"); len(ss) != 2 {
120-
return xerrors.Errorf("Failed to parse GitHub owner/repo: %s in %s", ownerRepo, name)
121-
}
122-
if githubSetting.Token == "" {
123-
return xerrors.Errorf("GitHub owner/repo: %s in %s token is empty", ownerRepo, name)
124-
}
125-
}
126-
127118
if len(server.Enablerepo) == 0 {
128119
server.Enablerepo = Conf.Default.Enablerepo
129120
}

detector/detector.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,6 @@ func Detect(rs []models.ScanResult, dir string) ([]models.ScanResult, error) {
191191
return nil, xerrors.Errorf("Failed to detect CVE of `%s`: %w", cpeURIs, err)
192192
}
193193

194-
repos := config.Conf.Servers[r.ServerName].GitHubRepos
195-
if err := DetectGitHubCves(&r, repos); err != nil {
196-
return nil, xerrors.Errorf("Failed to detect GitHub Cves: %w", err)
197-
}
198-
199194
if err := DetectWordPressCves(&r, config.Conf.WpScan); err != nil {
200195
return nil, xerrors.Errorf("Failed to detect WordPress Cves: %w", err)
201196
}
@@ -392,33 +387,6 @@ func isPkgCvesDetactable(r *models.ScanResult) bool {
392387
}
393388
}
394389

395-
// DetectGitHubCves fetches CVEs from GitHub Security Alerts
396-
func DetectGitHubCves(r *models.ScanResult, githubConfs map[string]config.GitHubConf) error {
397-
if len(githubConfs) == 0 {
398-
return nil
399-
}
400-
401-
r.GitHubManifests = models.DependencyGraphManifests{}
402-
for ownerRepo, setting := range githubConfs {
403-
ss := strings.Split(ownerRepo, "/")
404-
if len(ss) != 2 {
405-
return xerrors.Errorf("Failed to parse GitHub owner/repo: %s", ownerRepo)
406-
}
407-
owner, repo := ss[0], ss[1]
408-
n, err := DetectGitHubSecurityAlerts(r, owner, repo, setting.Token, setting.IgnoreGitHubDismissed)
409-
if err != nil {
410-
return xerrors.Errorf("Failed to access GitHub Security Alerts: %w", err)
411-
}
412-
logging.Log.Infof("%s: %d CVEs detected with GHSA %s/%s",
413-
r.FormatServerName(), n, owner, repo)
414-
415-
if err = DetectGitHubDependencyGraph(r, owner, repo, setting.Token); err != nil {
416-
return xerrors.Errorf("Failed to access GitHub Dependency graph: %w", err)
417-
}
418-
}
419-
return nil
420-
}
421-
422390
// DetectWordPressCves detects CVEs of WordPress
423391
func DetectWordPressCves(r *models.ScanResult, wpCnf config.WpScanConf) error {
424392
if len(r.WordPressPackages) == 0 {

0 commit comments

Comments
 (0)