Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion artifactory/commands/transferconfig/transferconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestValidateTargetServer(t *testing.T) {
_, err = w.Write(content)
assert.NoError(t, err)
default:
content, err := json.Marshal(users)
content, err := json.Marshal(users) // #nosec G117 -- test mock response
assert.NoError(t, err)
_, err = w.Write(content)
assert.NoError(t, err)
Expand Down
20 changes: 10 additions & 10 deletions artifactory/commands/transferfiles/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,12 @@ var convertPatternToPathPrefixTestCases = []struct {
input string
expected string
}{
{"folder/subfolder/*", "folder/subfolder"}, // strips trailing /*
{"folder/**", "folder"}, // strips trailing /**
{"folder/", "folder"}, // strips trailing /
{"folder", "folder"}, // no change when no trailing pattern
{"a/b/c/d/e/*", "a/b/c/d/e"}, // deep path with wildcard
{"single", "single"}, // single segment without slash
{"folder/subfolder/*", "folder/subfolder"}, // strips trailing /*
{"folder/**", "folder"}, // strips trailing /**
{"folder/", "folder"}, // strips trailing /
{"folder", "folder"}, // no change when no trailing pattern
{"a/b/c/d/e/*", "a/b/c/d/e"}, // deep path with wildcard
{"single", "single"}, // single segment without slash
}

func TestConvertPatternToPathPrefix(t *testing.T) {
Expand Down Expand Up @@ -592,11 +592,11 @@ var convertPatternToAqlMatchTestCases = []struct {
input string
expected string
}{
{"folder/subfolder/*", "*folder/subfolder*"}, // path with wildcard
{"folder", "*folder*"}, // simple folder name
{"folder/subfolder/*", "*folder/subfolder*"}, // path with wildcard
{"folder", "*folder*"}, // simple folder name
{"org/company/project/*", "*org/company/project*"}, // deep nested path
{"*already/prefixed", "*already/prefixed*"}, // already has leading wildcard
{"already/suffixed*", "*already/suffixed*"}, // already has trailing wildcard
{"*already/prefixed", "*already/prefixed*"}, // already has leading wildcard
{"already/suffixed*", "*already/suffixed*"}, // already has trailing wildcard
}

func TestConvertPatternToAqlMatch(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (rrc *RemoteRepositoryCheck) createRemoteUrlRequest() ([]remoteRepoSettings
func (rrc *RemoteRepositoryCheck) doCheckRemoteRepositories(args RunArguments, remoteUrlRequest []remoteRepoSettings) (inaccessibleRepositories *[]inaccessibleRepository, err error) {
artifactoryUrl := clientutils.AddTrailingSlashIfNeeded(args.ServerDetails.ArtifactoryUrl)

body, err := json.Marshal(remoteUrlRequest)
body, err := json.Marshal(remoteUrlRequest) // #nosec G117 -- credentials sent to Artifactory API
if err != nil {
return nil, errorutils.CheckError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion common/commands/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func doConfig(t *testing.T, serverId string, inputDetails *config.ServerDetails,

func configStructToString(t *testing.T, artConfig *config.ServerDetails) string {
artConfig.IsDefault = false
marshaledStruct, err := json.Marshal(*artConfig)
marshaledStruct, err := json.Marshal(*artConfig) // #nosec G117 -- test helper
assert.NoError(t, err)
return string(marshaledStruct)
}
4 changes: 2 additions & 2 deletions common/commands/metrics_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func TestDetectCISystem(t *testing.T) {
}

// Restore environment after test
defer func() {
defer func() {
for envVar, value := range originalEnv {
if value != "" {
if err := os.Setenv(envVar, value); err != nil {
Expand Down Expand Up @@ -219,7 +219,7 @@ func TestDetectCISystem(t *testing.T) {
{"No CI", "", "", ""},
}

for _, tt := range tests {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Clear all CI environment variables
for _, envVar := range ciEnvVars {
Expand Down
6 changes: 3 additions & 3 deletions common/spec/specfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ type File struct {
TargetPathInArchive string
Include []string `json:"include,omitempty"`
Package string `json:"package,omitempty"`
Version string `json:"version,omitempty"`
Type string `json:"type,omitempty"`
RepoKey string `json:"repoKey,omitempty"`
Version string `json:"version,omitempty"`
Type string `json:"type,omitempty"`
RepoKey string `json:"repoKey,omitempty"`
}

func (f File) GetInclude() []string {
Expand Down
2 changes: 1 addition & 1 deletion general/token/oidctokenexchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (otc *OidcTokenExchangeCommand) PrintResponseToConsole() {
AccessToken: otc.response.AccessToken,
Username: otc.response.Username,
}
jsonOutput, err := json.Marshal(response)
jsonOutput, err := json.Marshal(response) // #nosec G117 -- intentional output of OIDC exchange result
if err != nil {
log.Error("Failed to marshal response to JSON:", err)
return
Expand Down
20 changes: 15 additions & 5 deletions plugins/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,29 @@ func PrintDetailedSummaryReport(basicSummary string, reader *content.ContentRead

// Print a file tree based on the items' path in the reader's list.
func PrintDeploymentView(reader *content.ContentReader) error {
output, err := GetDeploymentViewString(reader)
if err != nil {
return err
}
if len(output) > 0 {
log.Info("These files were uploaded:\n\n" + output)
} else {
log.Info("No files were uploaded.")
}
return nil
}

func GetDeploymentViewString(reader *content.ContentReader) (string, error) {
tree := artifactoryUtils.NewFileTree()
for transferDetails := new(clientutils.FileTransferDetails); reader.NextRecord(transferDetails) == nil; transferDetails = new(clientutils.FileTransferDetails) {
tree.AddFile(transferDetails.TargetPath, "")
}
if err := reader.GetError(); err != nil {
return err
return "", err
}
reader.Reset()
output := tree.String()
if len(output) > 0 {
log.Info("These files were uploaded:\n\n" + output)
}
return nil
return output, nil
}

// Get the detailed summary record.
Expand Down
6 changes: 3 additions & 3 deletions utils/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,11 @@ type ServerDetails struct {
OnemodelUrl string `json:"-"`
ApptrustUrl string `json:"-"`
User string `json:"user,omitempty"`
Password string `json:"password,omitempty"` // #nosec G117 -- config struct for auth
Password string `json:"password,omitempty"` // #nosec G117 -- config struct for auth
SshKeyPath string `json:"sshKeyPath,omitempty"`
SshPassphrase string `json:"sshPassphrase,omitempty"`
AccessToken string `json:"accessToken,omitempty"` // #nosec G117 -- config struct for auth
RefreshToken string `json:"refreshToken,omitempty"` // #nosec G117 -- config struct for auth
AccessToken string `json:"accessToken,omitempty"` // #nosec G117 -- config struct for auth
RefreshToken string `json:"refreshToken,omitempty"` // #nosec G117 -- config struct for auth
ArtifactoryRefreshToken string `json:"artifactoryRefreshToken,omitempty"`
ArtifactoryTokenRefreshInterval int `json:"tokenRefreshInterval,omitempty"`
ClientCertPath string `json:"clientCertPath,omitempty"`
Expand Down
8 changes: 4 additions & 4 deletions utils/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ func createEncryptionTestConfig() *Config {
ServerId: "test-server",
Url: "http://acme.jfrog.io",
User: "elmar",
Password: "Wabbit", // #nosec G101 -- test data only
Password: "Wabbit", // #nosec G101 -- test data only
AccessToken: "DewiciousWegOfWamb", // #nosec G101 -- test data only
SshPassphrase: "KiwwTheWabbit", // #nosec G101 -- test data only
SshPassphrase: "KiwwTheWabbit", // #nosec G101 -- test data only
}}},
}}
}
Expand Down Expand Up @@ -479,7 +479,7 @@ func TestCreateAuthConfigAppendPreRequestFunctionBehavior(t *testing.T) {
name: "DisableTokenRefreshTrue_WithArtifactoryRefreshToken",
serverDetails: &ServerDetails{
ServerId: "test-server",
AccessToken: "access-token-123", // #nosec G101 -- test data only
AccessToken: "access-token-123", // #nosec G101 -- test data only
ArtifactoryRefreshToken: "artifactory-refresh-token-789", // #nosec G101 -- test data only
User: "testuser",
Password: "testpass", // #nosec G101 -- test data only
Expand All @@ -491,7 +491,7 @@ func TestCreateAuthConfigAppendPreRequestFunctionBehavior(t *testing.T) {
name: "DisableTokenRefreshFalse_WithArtifactoryRefreshToken",
serverDetails: &ServerDetails{
ServerId: "test-server",
AccessToken: "access-token-123", // #nosec G101 -- test data only
AccessToken: "access-token-123", // #nosec G101 -- test data only
ArtifactoryRefreshToken: "artifactory-refresh-token-789", // #nosec G101 -- test data only
User: "testuser",
Password: "testpass", // #nosec G101 -- test data only
Expand Down
8 changes: 4 additions & 4 deletions utils/config/configtoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ type configToken struct {
MissionControlUrl string `json:"missionControlUrl,omitempty"`
PipelinesUrl string `json:"pipelinesUrl,omitempty"`
User string `json:"user,omitempty"`
Password string `json:"password,omitempty"` // #nosec G117 -- config struct for auth
Password string `json:"password,omitempty"` // #nosec G117 -- config struct for auth
SshKeyPath string `json:"sshKeyPath,omitempty"`
SshPassphrase string `json:"sshPassphrase,omitempty"`
AccessToken string `json:"accessToken,omitempty"` // #nosec G117 -- config struct for auth
RefreshToken string `json:"refreshToken,omitempty"` // #nosec G117 -- config struct for auth
AccessToken string `json:"accessToken,omitempty"` // #nosec G117 -- config struct for auth
RefreshToken string `json:"refreshToken,omitempty"` // #nosec G117 -- config struct for auth
TokenRefreshInterval int `json:"tokenRefreshInterval,omitempty"`
ClientCertPath string `json:"clientCertPath,omitempty"`
ClientCertKeyPath string `json:"clientCertKeyPath,omitempty"`
Expand Down Expand Up @@ -98,7 +98,7 @@ func Export(details *ServerDetails) (string, error) {
return "", errorutils.CheckErrorf("could not generate config token: config is encrypted, and wrong master key was provided")
}
}
buffer, err := json.Marshal(fromServerDetails(details))
buffer, err := json.Marshal(fromServerDetails(details)) // #nosec G117 -- intentional serialization of auth config for export token
if err != nil {
return "", err
}
Expand Down
Loading
Loading