Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
- Thanks to Markus for suggestion about simplify the logic to get
excluded file paths
  • Loading branch information
shashwathi committed Oct 29, 2019
1 parent 76f8c98 commit f3c96a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions test/test_images/runtime/handlers/file_access_attempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ func checkReadable(path string) error {
return err
}
readFile, err := os.OpenFile(path, os.O_RDONLY, 0)
defer readFile.Close()
return err
if err != nil {
return err
}
readFile.Close()
return nil
}

// checkWritable function checks whether path file or directory is writable
Expand Down
8 changes: 5 additions & 3 deletions test/test_images/runtime/handlers/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ func excludeFilePaths(filePaths []string, excludedPaths []string) []string {
var paths []string
for _, path := range filePaths {
excluded := false
for i := len(excludedPaths) - 1; i >= 0 && !excluded; i-- {
excluded = path == excludedPaths[i]
for _, excludedPath := range excludedPaths {
if path == excludedPath {
excluded = true
break
}
}

if !excluded {
paths = append(paths, path)
}
}

return paths
}

0 comments on commit f3c96a4

Please sign in to comment.