47fac22230
- .claude/CLAUDE.md - .claude/commands/subagentes.md - .claude/rules/INDEX.md - .mcp.json - bash/functions/cybersecurity/analyze_dns.md - bash/functions/cybersecurity/audit_http_headers.md - bash/functions/cybersecurity/audit_ssh_config.md - bash/functions/cybersecurity/check_firewall.md - bash/functions/cybersecurity/detect_suspicious_users.md - bash/functions/cybersecurity/encrypt_file.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.4 KiB
1.4 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| file_delete | function | go | infra | 1.0.0 | impure | func FileDelete(path string) error | Elimina un archivo del disco. Rechaza paths con ".." para evitar path traversal. Retorna error si el archivo no existe o si falla el remove. |
|
false | error_go_core |
|
|
nil si el archivo se elimino correctamente, error si el path es vacio, contiene path traversal, no existe o falla la operacion | true |
|
functions/infra/file_delete_test.go | functions/infra/file_delete.go |
Ejemplo
err := FileDelete("./uploads/a1b2c3d4.png")
if err != nil {
log.Printf("delete fallo: %v", err)
}
Notas
La proteccion contra path traversal es defensiva pero NO es suficiente por si sola: la app debe pasar paths que ya estan resueltos al directorio de storage (usar filepath.Join(baseDir, storedName)). Esta funcion es un cinturon adicional contra bugs en la app que llamaria.
NO sigue symlinks de forma especial — os.Remove borra el symlink, no el target.