IsSensitivePath checks whether a file path points to a known sensitive location.
(absPath string)
| 36 | |
| 37 | // IsSensitivePath checks whether a file path points to a known sensitive location. |
| 38 | func IsSensitivePath(absPath string) bool { |
| 39 | normalizedPath := filepath.ToSlash(absPath) |
| 40 | if runtime.GOOS != "windows" { |
| 41 | normalizedPath = strings.ToLower(normalizedPath) |
| 42 | } |
| 43 | for _, sensitive := range sensitivePaths { |
| 44 | sensitive = strings.ToLower(sensitive) |
| 45 | if strings.Contains(normalizedPath, "/"+sensitive+"/") || |
| 46 | strings.HasSuffix(normalizedPath, "/"+sensitive) || |
| 47 | strings.Contains(normalizedPath, "/"+sensitive) { |
| 48 | return true |
| 49 | } |
| 50 | } |
| 51 | return false |
| 52 | } |
| 53 | |
| 54 | // ReadFileContent lê o conteúdo de um arquivo, expandindo ~ para o diretório home, |
| 55 | // mostrando um indicador de progresso para arquivos grandes. |