lint: Fix implicit memory aliasing in for loops

Fix all instances of gosec G601: Implicit memory aliasing in for loop.
This commit is contained in:
Brian C. Lane 2023-09-15 09:03:28 -07:00 committed by Achilleas Koutsou
parent 1b65f15449
commit 9e39080d00
3 changed files with 8 additions and 6 deletions

View file

@ -157,7 +157,7 @@ func main() {
if repo.GPGKey != "" {
keys = []string{repo.GPGKey}
}
checkGPG := repo.CheckGPG
repos[i] = rpmmd.RepoConfig{
Id: repoId,
Name: repoName,
@ -165,7 +165,7 @@ func main() {
Metalink: repo.Metalink,
MirrorList: repo.MirrorList,
GPGKeys: keys,
CheckGPG: &repo.CheckGPG,
CheckGPG: &checkGPG,
CheckRepoGPG: common.ToPtr(false),
IgnoreSSL: common.ToPtr(false),
PackageSets: repo.PackageSets,

View file

@ -211,10 +211,11 @@ func (c *Customizations) GetUsers() []UserCustomization {
// prepend sshkey for backwards compat (overridden by users)
if len(c.SSHKey) > 0 {
for _, c := range c.SSHKey {
for _, k := range c.SSHKey {
key := k.Key
users = append(users, UserCustomization{
Name: c.User,
Key: &c.Key,
Name: k.User,
Key: &key,
})
}
}

View file

@ -186,9 +186,10 @@ func TestRepoConfigConversion(t *testing.T) {
}
for idx, tc := range testCases {
repoConfig := tc.repoConfig
rc, err := genRepoConfig(tc.repo)
assert.NoError(err)
assert.Equal(&tc.repoConfig, rc, "mismatch in test case %d", idx)
assert.Equal(&repoConfig, rc, "mismatch in test case %d", idx)
}
errorTestCases := []struct {