Projects STRLCPY csprecon Commits 03b914fe
🤬
  • ■ ■ ■ ■ ■
    .golangci.yml
    skipped 51 lines
    52 52   # Default: []
    53 53   ignored-numbers:
    54 54   - '2'
     55 + - '0644'
  • ■ ■ ■ ■ ■ ■
    pkg/csprecon/csp.go
    skipped 2 lines
    3 3  import (
    4 4   "crypto/tls"
    5 5   "fmt"
    6  - "io/ioutil"
     6 + "io"
    7 7   "net"
    8 8   "net/http"
    9 9   "time"
     10 +)
     11 + 
     12 +const (
     13 + TLSHandshakeTimeout = 10
     14 + KeepAlive = 30
    10 15  )
    11 16   
    12 17  func checkCSP(url string, client *http.Client) ([]string, error) {
    skipped 8 lines
    21 26   return result, nil
    22 27   }
    23 28   
    24  - body, err := ioutil.ReadAll(resp.Body)
    25  - 
    26  - if resp != nil {
    27  - defer resp.Body.Close()
    28  - }
     29 + body, _ := io.ReadAll(resp.Body)
     30 + defer resp.Body.Close()
    29 31   
    30 32   headerCSP := resp.Header.Get("Content-Security-Policy")
    31 33   
    skipped 12 lines
    44 46   Dial: (&net.Dialer{
    45 47   // Modify the time to wait for a connection to establish
    46 48   Timeout: time.Duration(timeout) * time.Second,
    47  - KeepAlive: 30 * time.Second,
     49 + KeepAlive: KeepAlive * time.Second,
    48 50   }).Dial,
    49  - TLSHandshakeTimeout: 10 * time.Second,
     51 + TLSHandshakeTimeout: TLSHandshakeTimeout * time.Second,
    50 52   }
    51 53   
    52 54   client := http.Client{
    skipped 7 lines
  • ■ ■ ■ ■ ■ ■
    pkg/csprecon/csprecon.go
    skipped 73 lines
    74 74   
    75 75  func execute(r *Runner) {
    76 76   defer r.InWg.Done()
     77 + 
    77 78   for value := range r.Input {
    78 79   result, err := checkCSP(value, r.Client)
    79 80   if err == nil {
    skipped 9 lines
    89 90   
    90 91   for o := range r.Output {
    91 92   r.OutWg.Add(1)
     93 + 
    92 94   go writeOutput(&r.OutWg, &r.Options, o)
    93 95   }
    94 96  }
    95 97   
    96 98  func writeOutput(wg *sync.WaitGroup, options *input.Options, out string) {
    97 99   defer wg.Done()
     100 + 
    98 101   if options.FileOutput != "" {
    99 102   file, err := os.OpenFile(options.FileOutput, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644)
    100 103   if err != nil {
    101 104   gologger.Fatal().Msg(err.Error())
    102 105   }
     106 + 
    103 107   options.Output = file
    104 108   }
    105 109   
    skipped 5 lines
Please wait...
Page is in error, reload to recover