diff --git a/netquery/module_api.go b/netquery/module_api.go index 2787b260..4cb02462 100644 --- a/netquery/module_api.go +++ b/netquery/module_api.go @@ -163,6 +163,5 @@ func (m *module) start() error { } func (m *module) stop() error { - return nil } diff --git a/process/tags/interpreter_unix.go b/process/tags/interpreter_unix.go index 237d8eeb..c254f4a7 100644 --- a/process/tags/interpreter_unix.go +++ b/process/tags/interpreter_unix.go @@ -10,6 +10,7 @@ import ( "unicode/utf8" "github.com/google/shlex" + "github.com/safing/portmaster/process" "github.com/safing/portmaster/profile" ) @@ -113,7 +114,7 @@ func fileMustBeUTF8(path string) bool { // InterpHandler supports adding process tags based on well-known interpreter binaries. type InterpHandler struct{} -// Name returns "Interpreter" +// Name returns "Interpreter". func (h *InterpHandler) Name() string { return "Interpreter" } diff --git a/profile/fingerprint.go b/profile/fingerprint.go index 64ab1203..6f5e6389 100644 --- a/profile/fingerprint.go +++ b/profile/fingerprint.go @@ -25,12 +25,6 @@ import ( // 2. Prefix: Length of prefix // 3. Regex: Length of match -// ms-store:Microsoft.One.Note - -// Path Match /path/to/file -// Tag MS-Store Match value -// Env Regex Key Value - // Fingerprint Type IDs. const ( FingerprintTypeTagID = "tag" @@ -253,34 +247,39 @@ func (parsed *parsedFingerprints) addMatchingFingerprint(fp Fingerprint, matchin // fingerprints and matching data. func MatchFingerprints(prints *parsedFingerprints, md MatchingData) (highestScore int) { // Check tags. - for _, tagPrint := range prints.tagPrints { - for _, tag := range md.Tags() { - // Check if tag key matches. - if !tagPrint.MatchesKey(tag.Key) { - continue - } + tags := md.Tags() + if len(tags) > 0 { + for _, tagPrint := range prints.tagPrints { + for _, tag := range tags { + // Check if tag key matches. + if !tagPrint.MatchesKey(tag.Key) { + continue + } - // Try matching the tag value. - score := tagPrint.Match(tag.Value) - if score > highestScore { + // Try matching the tag value. + score := tagPrint.Match(tag.Value) + if score > highestScore { + highestScore = score + } + } + } + // If something matched, add base score and return. + if highestScore > 0 { + return tagMatchBaseScore + highestScore + } + } + + // Check cmdline. + cmdline := md.Cmdline() + if cmdline != "" { + for _, cmdlinePrint := range prints.cmdlinePrints { + if score := cmdlinePrint.Match(cmdline); score > highestScore { highestScore = score } } - } - // If something matched, add base score and return. - if highestScore > 0 { - return tagMatchBaseScore + highestScore - } - - cmdline := md.Cmdline() - for _, cmdlinePrint := range prints.cmdlinePrints { - if score := cmdlinePrint.Match(cmdline); score > highestScore { - highestScore = score + if highestScore > 0 { + return cmdlineMatchBaseScore + highestScore } - - } - if highestScore > 0 { - return cmdlineMatchBaseScore + highestScore } // Check env.