feat: 16 funciones cybersecurity — análisis, crypto e IO de seguridad
12 funciones puras con implementación real: HashSHA256, HashMD5, EntropyShannon, IsBase64, IsHex, ExtractURLs, ParseIPCIDR, IPInRange, NormalizeURL, DetectSQLInjection, LevenshteinDistance, JaccardSimilarity 4 funciones impuras con implementación real (stdlib): LookupWhois, ResolveDNS, FetchHTTPHeaders, ScanPortTCP Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package cybersecurity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// FetchHTTPHeaders realiza una solicitud HTTP HEAD a la URL y devuelve los headers de respuesta.
|
||||
func FetchHTTPHeaders(url string) (map[string][]string, error) {
|
||||
client := &http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
}
|
||||
|
||||
resp, err := client.Head(url)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error realizando solicitud HEAD a %s: %w", url, err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
headers := make(map[string][]string, len(resp.Header))
|
||||
for k, v := range resp.Header {
|
||||
headers[k] = v
|
||||
}
|
||||
|
||||
return headers, nil
|
||||
}
|
||||
Reference in New Issue
Block a user