github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20261111060712-4b23175bf2f5
Go program harvests multiple developer credential filesBacktick shell command-substitution syntax
SHA-256467ac1938955f72e75c17c61100282e60e27fb0f0b352515828ada819a2cca5c
Evidence
1package setup
2
3import (
4 "bytes"
5 "fmt"
6 "io/fs"
7 "net/http"
8 "net/http/httptest"
9 "os"
10 "os/exec"
11 "path/filepath"
12 "runtime"
13 "strings"
14 "testing"
15
16 "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/dotnet"
17 "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/gradle"
18 "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/python"
19 cmdutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
20 "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/maven"
21 "github.com/jfrog/jfrog-cli-core/v2/common/project"
22 "github.com/jfrog/jfrog-cli-core/v2/utils/config"
23 "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
24 "github.com/jfrog/jfrog-cli-core/v2/utils/ioutils"
25 "github.com/jfrog/jfrog-client-go/auth"
26 "github.com/jfrog/jfrog-client-go/utils/io"
27 "github.com/jfrog/jfrog-client-go/utils/log"
28 "github.com/stretchr/testify/assert"
29 "github.com/stretchr/testify/require"
30 "golang.org/x/exp/slices"
31 "gopkg.in/yaml.v3"
32)
33
34const (
35 goProxyEnv = "GOPROXY"
36)
37
38// assertOwnerOnly verifies path is restricted to 0600, the mode jf setup applies
39// to credential-bearing config files. It skips Windows, where os.Chmod only
40// toggles the read-only attribute and the mode always reads back as 0666.
41func assertOwnerOnly(t *testing.T, path string) {
42 t.Helper()
43 if coreutils.IsWindows() {
44 return
45 }
46 info, err := os.Stat(path) …
53:69… TOCTOU gosec
54// flags).
55func collectConfigPaths(t *testing.T, root string) []string {
56 t.Helper()
57 configFileNames := []string{".npmrc", "auth.ini", "rc", "config.yaml"}
58 var configPaths []string
59 require.NoError(t, filepath.WalkDir(root, func(path string, entry fs.DirEntry, err error) error {
60 if err != nil || entry.IsDir() || !slices.Contains(configFileNames, entry.Name()) {
61 return …
147:21… , loginCmd.Run())
148
149 // config.toml: registry index + crates.io redirect, regardless of auth mode.
150 configContent, err := os.ReadFile(filepath.Join(cargoHomeDir, "config.toml"))
151 require.NoError(t, err)
152 cfg := string(configContent)
153 assert.Contains(t, cfg, "sparse+https://acme.jfrog.io/artifactory/api/cargo/test-repo/index/")
154 assert.Contains(t, cfg, `default = "jfrog"`)
155 assert.Contains(t, cfg, `replace-with = "jfrog"`)
156
157 credsPath := filepath.Join(cargoHomeDir, "credentials.toml")
158 switch {
159 case testCase.accessToken != "":
160 cred …
627 nugetConfigFilePath := filepath.Join(homeDir, nugetConfigDir, "NuGet", "NuGet.Config")
628
629 // Back up the existing NuGet.config and ensure restoration after the test.
630 restoreNugetConfigFunc, err := ioutils.BackupF …
764:31… *testing.T) {
765 // Retrieve the home directory and construct the .pypirc file path.
766 homeDir, err := os.UserHomeDir()
767 assert.NoError(t, err)
768 pypircFilePath := filepath.Join(homeDir, ".pypirc")
769
770 // Back up the existing .pypirc file and ensure restoration after the test.
771 restorePypircFunc, err := ioutils.BackupFile(pypircFilePath, ".pypirc.backup")
772 require.NoError(t, err)
773 defer func() {
⋯4 lines
Showing the top 5 files — 6 more files (58 regions) not shown.
No evidence locations were recorded for this file. Raw result