You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: internal/vm/vmutils/etw/provider_map.go
+67-42Lines changed: 67 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,19 @@
1
1
package etw
2
2
3
3
import (
4
+
"context"
4
5
"embed"
5
6
"encoding/base64"
6
7
"encoding/json"
7
8
"fmt"
8
9
"strings"
9
10
"sync"
10
-
)
11
11
12
-
//go:embed etw-map.json
13
-
//go:embed default-logsources.json
12
+
"github.com/Microsoft/hcsshim/internal/log"
13
+
)
14
14
15
-
varetwFS embed.FS
16
-
varlistFS embed.FS
15
+
//go:embed etw-map.json default-logsources.json
16
+
varembeddedFiles embed.FS
17
17
18
18
const (
19
19
EtwMapFileName="etw-map.json"
@@ -49,7 +49,7 @@ type Source struct {
49
49
50
50
typeEtwProviderstruct {
51
51
ProviderNamestring`json:"providerName,omitempty"`
52
-
ProviderGuidstring`json:"providerGuid,omitempty"`
52
+
ProviderGUIDstring`json:"providerGuid,omitempty"`
53
53
Levelstring`json:"level,omitempty"`
54
54
Keywordsstring`json:"keywords,omitempty"`
55
55
}
@@ -61,11 +61,11 @@ type EtwInfo struct {
61
61
62
62
typeEtwProviderMapstruct {
63
63
ProviderNamestring`json:"providerName"`
64
-
ProviderGuidstring`json:"providerGuid"`
64
+
ProviderGUIDstring`json:"providerGuid"`
65
65
}
66
66
67
-
// NormalizeGuid takes a GUID string in various formats and normalizes it to the standard 8-4-4-4-12 format with uppercase letters. It returns an error if the input string is not a valid GUID.
68
-
funcNormalizeGuid(instring) (string, error) {
67
+
// NormalizeGUID takes a GUID string in various formats and normalizes it to the standard 8-4-4-4-12 format with uppercase letters. It returns an error if the input string is not a valid GUID.
// LoadEtwMap loads the ETW provider name to GUID mapping from the embedded JSON file. It returns two maps, one for name to GUID and another for GUID to name. If there is an error in loading or parsing the file, it returns empty maps and the error.
// GetDefaultLogSources returns the default log sources from the embedded json file. If there is an error in loading or parsing the file, it returns an empty LogSourcesInfo struct and the error.
// GetDefaultLogSources returns the default log sources from the embedded JSON file. If there is an error in loading or parsing the file, it returns an empty LogSourcesInfo struct and the error.
144
+
// The default log sources are defined in the "default-logsources.json" file and are loaded only once using sync.Once to ensure thread safety and performance.
145
+
// The providers in the default-logsources.json file should only have Provider Names and must not contain GUIDs as the handling of GUIDs is based on the configuration and is done in the UpdateEncodedLogSources function where we
146
+
// check if we need to include GUIDs for the log sources based on the configuration and if needed, we map the provider names to their corresponding GUIDs using the ETW map loaded from the "etw-map.json" file.
147
+
// The only exception to this is if the provider does not have any name and only has a GUID.
// GetDefaultLogSourcesWithMappedGuid returns the default log sources with provider GUIDs included in the providers. If there is an error in loading the default log sources or the ETW map, it returns the default log sources without GUIDs.
// GetDefaultLogSourcesWithMappedGUID returns the default log sources with provider GUIDs included in the providers. If there is an error in loading the default log sources or the ETW map, it returns the default log sources without GUIDs.
// GetProviderGuidFromName returns the provider guid for a given provider name. If the provider name is not found in the map, it returns an empty string.
// GetProviderGUIDFromName returns the provider GUID for a given provider name. If the provider name is not found in the map, it returns an empty string.
// GetProviderNameFromGuid returns the provider name for a given provider guid. If the provider guid is not found in the map, it returns an empty string.
// GetProviderNameFromGUID returns the provider name for a given provider GUID. If the provider GUID is not found in the map, it returns an empty string.
// Updates the user provided log sources with the default log sources based on the configuration and returns the updated log sources as a base64 encoded json string. If there is an error in the process, it returns the original user provided log sources string.
// Updates the user provided log sources with the default log sources based on the configuration and returns the updated log sources as a base64 encoded JSON string. If there is an error in the process, it returns the original user provided log sources string.
0 commit comments