Skip to content
This repository was archived by the owner on Apr 30, 2021. It is now read-only.

Commit b11aa83

Browse files
author
Yevgeny Pats
committed
backend: store lastLines for run
1 parent 320202d commit b11aa83

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

client/agent.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const (
2727
AgentNoPermissionError = 22
2828
)
2929

30+
var lastLines []string
31+
3032
func appendPrefixToCmd(cmd *exec.Cmd) error {
3133
stderr, err := cmd.StderrPipe()
3234
if err != nil {
@@ -42,6 +44,10 @@ func appendPrefixToCmd(cmd *exec.Cmd) error {
4244
for scanner.Scan() {
4345
msg := scanner.Text()
4446
fmt.Printf("FUZZER: %s\n", msg)
47+
lastLines = append(lastLines, msg)
48+
if len(lastLines) > 1000 {
49+
lastLines = lastLines[500:]
50+
}
4551
}
4652
}()
4753

client/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type crash struct {
4646
Type string `firestore:"type"`
4747
Time time.Time `firestore:"time,serverTimestamp"`
4848
V2 bool `firestore:"v2"`
49+
LastLines string `firestore:"last_lines"`
4950
}
5051

5152
type FuzzitClient struct {

client/libfuzzer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func (c *FuzzitClient) uploadCrash(exitCode int) error {
122122
OrgId: c.Org,
123123
ExitCode: uint32(exitCode),
124124
Type: "crash",
125+
LastLines: strings.Join(lastLines, "\n"),
125126
V2: true,
126127
})
127128
if err != nil {

client/utils.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,12 @@ func createDirIfNotExist(path string) error {
202202
}
203203
return nil
204204
}
205+
206+
func Contains(arr []string, str string) bool {
207+
for _, a := range arr {
208+
if a == str {
209+
return true
210+
}
211+
}
212+
return false
213+
}

0 commit comments

Comments
 (0)