go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/windows_bitlocker.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package resources
     5  
     6  import (
     7  	"go.mondoo.com/cnquery/llx"
     8  	"go.mondoo.com/cnquery/providers-sdk/v1/util/convert"
     9  	"go.mondoo.com/cnquery/providers/os/connection/shared"
    10  	"go.mondoo.com/cnquery/providers/os/resources/windows"
    11  )
    12  
    13  func (s *mqlWindowsBitlocker) volumes() ([]interface{}, error) {
    14  	conn := s.MqlRuntime.Connection.(shared.Connection)
    15  
    16  	volumes, err := windows.GetBitLockerVolumes(conn)
    17  	if err != nil {
    18  		return nil, err
    19  	}
    20  
    21  	res := []interface{}{}
    22  	for i := range volumes {
    23  		v := volumes[i]
    24  
    25  		cs, _ := convert.JsonToDict(v.ConversionStatus)
    26  		em, _ := convert.JsonToDict(v.EncryptionMethod)
    27  		version, _ := convert.JsonToDict(v.Version)
    28  		ps, _ := convert.JsonToDict(v.ProtectionStatus)
    29  
    30  		volume, err := CreateResource(s.MqlRuntime, "windows.bitlocker.volume", map[string]*llx.RawData{
    31  			"deviceID":           llx.StringData(v.DeviceID),
    32  			"driveLetter":        llx.StringData(v.DriveLetter),
    33  			"conversionStatus":   llx.DictData(cs),
    34  			"encryptionMethod":   llx.DictData(em),
    35  			"lockStatus":         llx.IntData(v.LockStatus),
    36  			"persistentVolumeID": llx.StringData(v.PersistentVolumeID),
    37  			"protectionStatus":   llx.DictData(ps),
    38  			"version":            llx.DictData(version),
    39  		})
    40  		if err != nil {
    41  			return nil, err
    42  		}
    43  		res = append(res, volume)
    44  	}
    45  	return res, nil
    46  }
    47  
    48  func (s *mqlWindowsBitlockerVolume) id() (string, error) {
    49  	return "bitlocker.volume/" + s.DeviceID.Data, nil
    50  }