Fix linter errors

This commit is contained in:
Daniel
2022-10-10 22:57:27 +02:00
parent 3c8157fd91
commit 144e5d8312
3 changed files with 30 additions and 31 deletions

View File

@@ -163,6 +163,5 @@ func (m *module) start() error {
}
func (m *module) stop() error {
return nil
}

View File

@@ -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"
}

View File

@@ -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.