Skip to content

Commit 04fb6d6

Browse files
committed
fix(lint): resolve gosec G118/G703/G122 and yamllint indentation
- validators/context.go: suppress G118 false positive (cancel returned to caller) - pkg/bundler/checksum: clean path before os.Open for G703 - pkg/bundler/handler.go: clean path before os.Open for G122 - tests/uat/aws/config.yaml: fix indentation (10 not 12)
1 parent c8d10e9 commit 04fb6d6

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

pkg/bundler/checksum/checksum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func CountEntries(bundleDir string) int {
169169
// SHA256Raw computes a file's SHA256 digest using streaming I/O and returns
170170
// the raw bytes. Does not load the entire file into memory.
171171
func SHA256Raw(path string) ([]byte, error) {
172-
f, err := os.Open(path)
172+
f, err := os.Open(filepath.Clean(path)) //nolint:gosec // G703: path from internal callers only
173173
if err != nil {
174174
return nil, errors.Wrap(errors.ErrCodeInternal,
175175
fmt.Sprintf("failed to open file for digest: %s", path), err)

pkg/bundler/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func streamZipResponse(w http.ResponseWriter, dir string, output *result.Output)
235235
}
236236

237237
// Open and copy file content
238-
file, err := os.Open(path)
238+
file, err := os.Open(filepath.Clean(path)) //nolint:gosec // G122: path from internal os.MkdirTemp, not user input
239239
if err != nil {
240240
return aicrerrors.Wrap(aicrerrors.ErrCodeInternal, "failed to open file", err)
241241
}

validators/context.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ func LoadContext() (*Context, error) {
116116
}
117117

118118
// Timeout returns a child context with the specified timeout.
119+
// The caller is responsible for calling the returned CancelFunc.
119120
func (c *Context) Timeout(d time.Duration) (context.Context, context.CancelFunc) {
120-
return context.WithTimeout(c.Ctx, d)
121+
return context.WithTimeout(c.Ctx, d) //nolint:gosec // G118: cancel is returned to caller
121122
}
122123

123124
func resolveNamespace() string {

0 commit comments

Comments
 (0)