1
0

feat: exclude internal errors from success rate

This commit is contained in:
dump_stack() 2023-05-24 18:44:14 +00:00
parent 04d6f0dbd3
commit b8058bffb0
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

15
pew.go
View File

@ -376,6 +376,8 @@ type phasesResult struct {
Output string Output string
Ok bool Ok bool
} }
InternalError error
} }
func copyFile(sourcePath, destinationPath string) (err error) { func copyFile(sourcePath, destinationPath string) (err error) {
@ -399,6 +401,14 @@ func copyFile(sourcePath, destinationPath string) (err error) {
func dumpResult(q *qemu.System, ka config.Artifact, ki distro.KernelInfo, func dumpResult(q *qemu.System, ka config.Artifact, ki distro.KernelInfo,
res *phasesResult, dist, tag, binary string, db *sql.DB) { res *phasesResult, dist, tag, binary string, db *sql.DB) {
if res.InternalError != nil {
q.Log.Error().Err(res.InternalError).
Str("panic", fmt.Sprintf("%v", q.KernelPanic)).
Str("timeout", fmt.Sprintf("%v", q.KilledByTimeout)).
Msg("internal")
return
}
colored := "" colored := ""
switch ka.Type { switch ka.Type {
case config.KernelExploit: case config.KernelExploit:
@ -464,6 +474,7 @@ func copyArtifactAndTest(slog zerolog.Logger, q *qemu.System, ka config.Artifact
} }
err = q.CopyFile(f.User, f.Local, f.Remote) err = q.CopyFile(f.User, f.Local, f.Remote)
if err != nil { if err != nil {
res.InternalError = err
slog.Error().Err(err).Msg("copy test file") slog.Error().Err(err).Msg("copy test file")
return return
} }
@ -717,11 +728,13 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup,
err = q.WaitForSSH(cmd.QemuTimeout) err = q.WaitForSSH(cmd.QemuTimeout)
if err != nil { if err != nil {
result.InternalError = err
return return
} }
remoteTest, err := copyTest(q, cmd.Test, ka) remoteTest, err := copyTest(q, cmd.Test, ka)
if err != nil { if err != nil {
result.InternalError = err
slog.Error().Err(err).Msg("copy test script") slog.Error().Err(err).Msg("copy test script")
return return
} }
@ -731,6 +744,7 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup,
start := time.Now() start := time.Now()
err = copyStandardModules(q, ki) err = copyStandardModules(q, ki)
if err != nil { if err != nil {
result.InternalError = err
slog.Error().Err(err).Msg("copy standard modules") slog.Error().Err(err).Msg("copy standard modules")
return return
} }
@ -740,6 +754,7 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup,
err = preloadModules(q, ka, ki, cmd.DockerTimeout) err = preloadModules(q, ka, ki, cmd.DockerTimeout)
if err != nil { if err != nil {
result.InternalError = err
slog.Error().Err(err).Msg("preload modules") slog.Error().Err(err).Msg("preload modules")
return return
} }