feat(config): Auto-upgrade Windows config.toml from v1 to v2 (#1726)
* add: README.md * add: commands(discover,add-server,add-cpe) * add: implements(discover,add-server,add-cpe) * fix: changed os.Exit(1) in main.go to return an error * fix: lint error * delete: trivy-to-vuls stdIn * fix: Incomprehesible error logs * fix: according to review * add: function converts old config to latest one * delete: add-server * fix: lint error * fix * fix: remote scan error in Windows * fix: lint error * fix * fix: lint error * fix: lint error * add: scanner/scanner.go test normalizeHomeDirForWindows() * fix * fix * fix * fix: remove pointless assignment * fix --------- Co-authored-by: 和田皓翔 <wadahiroka@192.168.0.4> Co-authored-by: 和田皓翔 <wadahiroka@192.168.0.10> Co-authored-by: 和田皓翔 <wadahiroka@192.168.0.6>
This commit is contained in:
@@ -2,6 +2,7 @@ package scanner
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -371,6 +372,30 @@ func TestParseSSHScan(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizedForWindows(t *testing.T) {
|
||||
type expected struct {
|
||||
path string
|
||||
}
|
||||
tests := []struct {
|
||||
in string
|
||||
expected expected
|
||||
}{
|
||||
{
|
||||
in: "~/.ssh/known_hosts",
|
||||
expected: expected{
|
||||
path: "C:\\Users\\test-user\\.ssh\\known_hosts",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
os.Setenv("userprofile", `C:\Users\test-user`)
|
||||
path := normalizeHomeDirPathForWindows(tt.in)
|
||||
if path != tt.expected.path {
|
||||
t.Errorf("expected path %s, actual %s", tt.expected.path, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseSSHKeygen(t *testing.T) {
|
||||
type expected struct {
|
||||
keyType string
|
||||
|
||||
Reference in New Issue
Block a user