Skip to content

Commit ac83d17

Browse files
committed
Present output at the end
1 parent 775fab5 commit ac83d17

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

cmd/exec-linpeas/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Downloads and launches LinPEAS
12
package main
23

34
import (

main.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ func runSimulations(ctx context.Context, checks []choice) error {
153153
}
154154
}
155155

156-
failed := []string{}
156+
failed := map[string]string{}
157157
for i, c := range checks {
158158
if _, err := os.Stat(c.name); err != nil {
159159
log.Printf("%s not found (build failure?) - skipping", c.name)
160-
failed = append(failed, c.name)
160+
failed[c.name] = "MISSING"
161161
continue
162162
}
163163

@@ -183,8 +183,12 @@ func runSimulations(ctx context.Context, checks []choice) error {
183183
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
184184
log.Printf("%s timed out as expected: %v", c.name, err)
185185
} else {
186+
if exiterr, ok := err.(*exec.ExitError); ok {
187+
failed[c.name] = fmt.Sprintf("EXITCODE_%d", exiterr.ExitCode())
188+
} else {
189+
failed[c.name] = fmt.Sprintf("ERR_%s", err)
190+
}
186191
log.Printf("%s failed: %v", c.name, err)
187-
failed = append(failed, c.name)
188192
}
189193
} else {
190194
log.Printf("%s exited successfully", c.name)
@@ -194,10 +198,16 @@ func runSimulations(ctx context.Context, checks []choice) error {
194198
time.Sleep(1 * time.Second)
195199
}
196200

197-
if len(failed) > 0 {
198-
return fmt.Errorf("%d of %d checks failed: %s", len(failed), len(checks), strings.Join(failed, ", "))
201+
title := fmt.Sprintf("CHECKS COMPLETE - %d of %d checks failed", len(failed), len(checks))
202+
announce(title)
203+
204+
for _, c := range checks {
205+
state := failed[c.name]
206+
if state == "" {
207+
state = "SUCCESS"
208+
}
209+
fmt.Printf("%-30.30s: %s\n", c.name, state)
199210
}
200211

201-
log.Printf("wow, everything just worked? amazing.")
202212
return nil
203213
}

0 commit comments

Comments
 (0)