mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
fix(scanner): leave failed scanner results out of the merge
A scanner that returns a result with status error now counts as a failed scanner, like one that returns an error. Its result no longer joins the merge, and the manager counts it as an infrastructure failure or another failure by its cause. The merged status is error only when every applicable scanner failed. The fail_closed setting then decides that case as before. One scanner failing while another returns clean now reads clean.
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
package pipaudit
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCopyInto(t *testing.T) {
|
||||
s := &Scanner{}
|
||||
src := filepath.Join(t.TempDir(), "pkg.whl")
|
||||
require.NoError(t, os.WriteFile(src, []byte("wheel"), 0600))
|
||||
|
||||
t.Run("copies inside dir", func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
require.NoError(t, s.copyInto(src, dir, "pkg.whl"))
|
||||
got, err := os.ReadFile(filepath.Join(dir, "pkg.whl"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "wheel", string(got))
|
||||
})
|
||||
|
||||
t.Run("refuses name escaping dir", func(t *testing.T) {
|
||||
parent := t.TempDir()
|
||||
dir := filepath.Join(parent, "sub")
|
||||
require.NoError(t, os.Mkdir(dir, 0750))
|
||||
require.Error(t, s.copyInto(src, dir, "../escape.whl"))
|
||||
require.NoFileExists(t, filepath.Join(parent, "escape.whl"))
|
||||
})
|
||||
|
||||
t.Run("missing source", func(t *testing.T) {
|
||||
require.Error(t, s.copyInto(filepath.Join(t.TempDir(), "none"), t.TempDir(), "x"))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user