Conditions | 8 |
Total Lines | 40 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | package producer |
||
34 | func (r *ReProducer) buildReproducer() func(result scan.Result) <-chan scan.Target { |
||
35 | resultRegistry := sync.Map{} |
||
36 | |||
37 | return func(result scan.Result) <-chan scan.Target { |
||
38 | resultChannel := make(chan scan.Target, defaultChannelBuffer) |
||
39 | |||
40 | go func() { |
||
41 | defer close(resultChannel) |
||
42 | |||
43 | if _, ok := statusCodesToSkip[result.Response.StatusCode]; ok { |
||
44 | return |
||
45 | } |
||
46 | |||
47 | if result.Target.Depth <= 0 { |
||
48 | return |
||
49 | } |
||
50 | |||
51 | // no point in appending to a filename |
||
52 | if pathutil.HasExtension(result.Target.Path) { |
||
53 | return |
||
54 | } |
||
55 | |||
56 | _, inRegistry := resultRegistry.Load(result.Target.Path) |
||
57 | if inRegistry { |
||
58 | return |
||
59 | } |
||
60 | resultRegistry.Store(result.Target.Path, false) |
||
61 | |||
62 | for target := range r.producer.Produce() { |
||
63 | newTarget := result.Target |
||
64 | newTarget.Depth-- |
||
65 | newTarget.Path = path.Join(newTarget.Path, target.Path) |
||
66 | newTarget.Method = target.Method |
||
67 | |||
68 | resultChannel <- newTarget |
||
69 | } |
||
70 | |||
71 | }() |
||
72 | |||
73 | return resultChannel |
||
74 | } |
||
76 |