Skip to content

Commit

Permalink
Fixed issue with empty project tokens after scanning (#4808)
Browse files Browse the repository at this point in the history
* Fixed issue with empty project tokens after scanning
  • Loading branch information
akram8008 authored Jan 29, 2024
1 parent ab62827 commit 689c79e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
7 changes: 4 additions & 3 deletions cmd/whitesourceExecuteScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ func newWhitesourceUtils(config *ScanOptions, client *github.Client) *whitesourc

func newWhitesourceScan(config *ScanOptions) *ws.Scan {
return &ws.Scan{
AggregateProjectName: config.ProjectName,
ProductVersion: config.Version,
BuildTool: config.BuildTool,
AggregateProjectName: config.ProjectName,
ProductVersion: config.Version,
BuildTool: config.BuildTool,
SkipProjectsWithEmptyTokens: config.SkipProjectsWithEmptyTokens,
}
}

Expand Down
11 changes: 11 additions & 0 deletions cmd/whitesourceExecuteScan_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions pkg/whitesource/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ type Scan struct {
// It does not include the ProductVersion.
AggregateProjectName string
// ProductVersion is the global version that is used across all Projects (modules) during the scan.
BuildTool string
ProductToken string
ProductVersion string
scannedProjects map[string]Project
scanTimes map[string]time.Time
AgentName string
AgentVersion string
Coordinates versioning.Coordinates
BuildTool string
ProductToken string
ProductVersion string
scannedProjects map[string]Project
scanTimes map[string]time.Time
AgentName string
AgentVersion string
Coordinates versioning.Coordinates
SkipProjectsWithEmptyTokens bool
}

func (s *Scan) init() {
Expand Down Expand Up @@ -83,6 +84,10 @@ func (s *Scan) ProjectByName(projectName string) (Project, bool) {
func (s *Scan) ScannedProjects() []Project {
var projects []Project
for _, project := range s.scannedProjects {
if len(project.Token) == 0 && s.SkipProjectsWithEmptyTokens {
log.Entry().Debugf("Project will be skipped as the token is empty, project_name: %s", project.Name)
continue
}
projects = append(projects, project)
}
return projects
Expand Down
9 changes: 9 additions & 0 deletions resources/metadata/whitesourceExecuteScan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,15 @@ spec:
- type: vaultSecret
name: golangPrivateModulesGitTokenVaultSecret
default: golang
- name: SkipProjectsWithEmptyTokens
description: Skips projects with empty tokens after scanning. This is for testing purposes only and should not be used until we roll out the new parameter
scope:
- GENERAL
- PARAMETERS
- STAGES
- STEPS
type: bool
default: false
resources:
- name: buildDescriptor
type: stash
Expand Down

0 comments on commit 689c79e

Please sign in to comment.