Skip to content

Commit 2ff3b6e

Browse files
authored
🐛 asset is virtualmachine if hypervisor detected (#5327)
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
1 parent d1c5992 commit 2ff3b6e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

providers/os/id/platform.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"go.mondoo.com/cnquery/v11/providers/os/id/awsecs"
1818
"go.mondoo.com/cnquery/v11/providers/os/id/clouddetect"
1919
"go.mondoo.com/cnquery/v11/providers/os/id/hostname"
20+
"go.mondoo.com/cnquery/v11/providers/os/id/hypervisor"
2021
"go.mondoo.com/cnquery/v11/providers/os/id/ids"
2122
"go.mondoo.com/cnquery/v11/providers/os/id/machineid"
2223
"go.mondoo.com/cnquery/v11/providers/os/id/serialnumber"
@@ -126,6 +127,15 @@ func IdentifyPlatform(conn shared.Connection, req *plugin.ConnectReq, p *invento
126127
})
127128
}
128129

130+
// If at this point we couldn't detect the platform kind, try to detect a hypervisor,
131+
// if we detect one, we will assume this asset is a virtual machine
132+
if p.Kind == "" {
133+
if hv, ok := hypervisor.Hypervisor(conn, p); ok {
134+
log.Debug().Str("hypervisor", hv).Msg("detected hypervisor")
135+
p.Kind = inventory.AssetKindCloudVM
136+
}
137+
}
138+
129139
log.Debug().Interface("id-detector", idDetectors).Strs("platform-ids", platformIds).Msg("detected platform ids")
130140
return &fingerprint, p, nil
131141
}

0 commit comments

Comments
 (0)