Skip to content

Commit af862e0

Browse files
remibcursoragent
andcommitted
JGC-449 - Add G101 and G703 nosec suppressions for CI
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c937883 commit af862e0

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

utils/io/content/contentreader_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ func TestCloseReader(t *testing.T) {
9595
reader := NewContentReader(filePathToBeDeleted, DefaultKey)
9696

9797
// Check file exists
98-
_, err = os.Stat(filePathToBeDeleted)
98+
_, err = os.Stat(filePathToBeDeleted) // #nosec G703 -- test file; path from test temp
9999
assert.NoError(t, err)
100100

101101
// Check if the file got deleted
102102
closeAndAssert(t, reader)
103-
_, err = os.Stat(filePathToBeDeleted)
103+
_, err = os.Stat(filePathToBeDeleted) // #nosec G703 -- test file; path from test temp
104104
assert.True(t, os.IsNotExist(err))
105105
}
106106

utils/io/fileutils/files.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ func IsDirExists(path string, preserveSymLink bool) (bool, error) {
7878
// If path points at a symlink and `preserveSymLink == true`, return the file info of the symlink instead
7979
func GetFileInfo(path string, preserveSymLink bool) (fileInfo os.FileInfo, err error) {
8080
if preserveSymLink {
81-
fileInfo, err = os.Lstat(path)
81+
fileInfo, err = os.Lstat(path) // #nosec G703 -- CLI/library runs in user environment
8282
} else {
83-
fileInfo, err = os.Stat(path)
83+
fileInfo, err = os.Stat(path) // #nosec G703 -- CLI/library runs in user environment
8484
}
8585
// We should not do CheckError here, because the error is checked by the calling functions.
8686
return

utils/io/fileutils/files_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestIsPathExistsAndIsPathAccessible(t *testing.T) {
3030
if symlinkCreated {
3131
assert.NoError(t, os.Remove(symlinkPath))
3232
}
33-
assert.NoError(t, os.Remove(tempFile.Name()))
33+
assert.NoError(t, os.Remove(tempFile.Name())) // #nosec G703 -- test file; path from temp
3434
}()
3535

3636
// Test for an existing file

utils/io/fileutils/temp_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestCleanOldDirs(t *testing.T) {
3838
// Check if the file got deleted.
3939
_, err1 := os.Stat(tempDir)
4040
assert.True(t, os.IsNotExist(err1))
41-
_, err2 := os.Stat(tempFile.Name())
41+
_, err2 := os.Stat(tempFile.Name()) // #nosec G703 -- test file; path from temp file
4242
assert.True(t, os.IsNotExist(err2))
4343
}
4444

@@ -75,7 +75,7 @@ func TestExtractTimestamp(t *testing.T) {
7575
}
7676

7777
func AssertFileExists(t *testing.T, name string) {
78-
_, err := os.Stat(name)
78+
_, err := os.Stat(name) // #nosec G703 -- test helper; path from test
7979
assert.NoError(t, err)
8080
}
8181

@@ -137,7 +137,7 @@ func TestCleanOldDirsContinuesOnError(t *testing.T) {
137137
assert.Contains(t, err.Error(), "invalid-no-timestamp")
138138

139139
// Verify valid files were deleted despite error with invalid file
140-
_, err1 := os.Stat(validFile1Name)
140+
_, err1 := os.Stat(validFile1Name) // #nosec G703 -- test file; path from test temp dir
141141
assert.True(t, os.IsNotExist(err1), "validFile1 should be deleted")
142142

143143
_, err2 := os.Stat(validFile2Name) // #nosec G703 -- test file; path from test temp dir

utils/regexputils_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ func TestRemoveCredentialsFromLine(t *testing.T) {
2424
expectedLine string
2525
matched bool
2626
}{
27-
{"http", gofrogio.CmdOutputPattern{RegExp: regExpProtocol, Line: "This is an example line http://user:password@127.0.0.1:8081/artifactory/path/to/repo"}, "This is an example line http://127.0.0.1:8081/artifactory/path/to/repo", true},
28-
{"https", gofrogio.CmdOutputPattern{RegExp: regExpProtocol, Line: "This is an example line https://user:password@127.0.0.1:8081/artifactory/path/to/repo"}, "This is an example line https://127.0.0.1:8081/artifactory/path/to/repo", true},
29-
{"git", gofrogio.CmdOutputPattern{RegExp: regExpProtocol, Line: "This is an example line git://user:password@127.0.0.1:8081/artifactory/path/to/repo"}, "This is an example line git://127.0.0.1:8081/artifactory/path/to/repo", true},
27+
{"http", gofrogio.CmdOutputPattern{RegExp: regExpProtocol, Line: "This is an example line http://user:password@127.0.0.1:8081/artifactory/path/to/repo"}, "This is an example line http://127.0.0.1:8081/artifactory/path/to/repo", true}, // #nosec G101 -- test data: fake URL for regex matching
28+
{"https", gofrogio.CmdOutputPattern{RegExp: regExpProtocol, Line: "This is an example line https://user:password@127.0.0.1:8081/artifactory/path/to/repo"}, "This is an example line https://127.0.0.1:8081/artifactory/path/to/repo", true}, // #nosec G101 -- test data: fake URL for regex matching
29+
{"git", gofrogio.CmdOutputPattern{RegExp: regExpProtocol, Line: "This is an example line git://user:password@127.0.0.1:8081/artifactory/path/to/repo"}, "This is an example line git://127.0.0.1:8081/artifactory/path/to/repo", true}, // #nosec G101 -- test data: fake URL for regex matching
3030
{"Special characters 1", gofrogio.CmdOutputPattern{RegExp: regExpProtocol, Line: "This is an example line https://u-s!<e>_r:!p-a&%%s%sword@127.0.0.1:8081/artifactory/path/to/repo"}, "This is an example line https://127.0.0.1:8081/artifactory/path/to/repo", true},
3131
{"Special characters 2", gofrogio.CmdOutputPattern{RegExp: regExpProtocol, Line: "This is an example line https://!user:[p]a(s)sword@127.0.0.1:8081/artifactory/path/to/repo"}, "This is an example line https://127.0.0.1:8081/artifactory/path/to/repo", true},
3232
{"http with token", gofrogio.CmdOutputPattern{RegExp: regExpProtocol, Line: "This is an example line http://123456@127.0.0.1:8081/artifactory/path/to/repo"}, "This is an example line http://127.0.0.1:8081/artifactory/path/to/repo", true},

0 commit comments

Comments
 (0)