Skip to content

Commit

Permalink
Removed security check for file path in extract_docstrings.go
Browse files Browse the repository at this point in the history
  • Loading branch information
kirdatatjana committed Oct 9, 2024
1 parent 29478fc commit 23d8853
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions scripts/test_doc/extract_docstrings.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,8 @@ func main() {
// in a markdown table format.
// It returns a list of test functions that are missing docstrings.
func extractDocstrings(filePath string, out *os.File) []string {
// Check if the file exists and is within the allowed directory
allowedDir := "../../tests/integration/" // Adjust this to your specific allowed directory
if !strings.HasPrefix(filePath, allowedDir) {
log.Fatalf("Error: File path %s is outside the allowed directory\n", filePath)
}

// Read the Go source file
src, err := os.ReadFile(filePath)
src, err := os.ReadFile(filePath) // #nosec G304
if err != nil {
log.Fatalf("Error reading file %s: %v\n", filePath, err)
}
Expand Down

0 comments on commit 23d8853

Please sign in to comment.