yellow~ opinionated web scanning pipeline for pentesters in a hurry |
| git clone https://github.com/djnnvx/yellow.git |
| log | files | refs | archive | README | LICENSE |
file_test.go (848B)
1 package helper 2 3 import ( 4 "os" 5 "path/filepath" 6 "slices" 7 "strings" 8 "testing" 9 ) 10 11 // a line past bufio.Scanner's 64KB cap used to end the run silently 12 func TestLoadTargetFileKeepsGoingPastALongLine(t *testing.T) { 13 long := strings.Repeat("A", 70_000) 14 path := filepath.Join(t.TempDir(), "targets.txt") 15 if err := os.WriteFile(path, []byte(long+"\n\nexample.com\n example.org \n"), 0644); err != nil { 16 t.Fatal(err) 17 } 18 19 f := LoadTargetFile(path) 20 defer f.Close() 21 22 got := slices.Collect(f.Lines()) 23 want := []string{long, "example.com", "example.org"} 24 if !slices.Equal(got, want) { 25 t.Errorf("got %d targets %q, want %d", len(got), truncate(got), len(want)) 26 } 27 } 28 29 func truncate(lines []string) []string { 30 out := make([]string, len(lines)) 31 for i, l := range lines { 32 if len(l) > 20 { 33 l = l[:20] + "..." 34 } 35 out[i] = l 36 } 37 return out 38 }