Fix dependency graph and linter errors

This commit is contained in:
Daniel
2020-04-02 17:09:15 +02:00
parent 180f27307c
commit eec0c37101
23 changed files with 164 additions and 61 deletions

View File

@@ -4,6 +4,7 @@ import (
"github.com/safing/portbase/config"
)
// Configuration Keys
var (
cfgStringOptions = make(map[string]config.StringOption)
cfgStringArrayOptions = make(map[string]config.StringArrayOption)

View File

@@ -10,7 +10,7 @@ import (
)
func TestMain(m *testing.M) {
pmtesting.TestMain(m)
pmtesting.TestMain(m, intel.Module)
}
func testEndpointMatch(t *testing.T, ep Endpoint, entity *intel.Entity, expectedResult EPResult) {

View File

@@ -5,6 +5,7 @@ import (
"github.com/safing/portbase/log"
)
// FindOrCreateLocalProfileByPath returns an existing or new profile for the given application path.
func FindOrCreateLocalProfileByPath(fullPath string) (profile *Profile, new bool, err error) {
// find local profile
it, err := profileDB.Query(

View File

@@ -47,3 +47,41 @@ func (profile *Profile) AddFingerprint(fp *Fingerprint) {
profile.Fingerprints = append(profile.Fingerprints, fp)
}
*/
// TODO: matching
/*
//nolint:deadcode,unused // FIXME
func matchProfile(p *Process, prof *profile.Profile) (score int) {
for _, fp := range prof.Fingerprints {
score += matchFingerprint(p, fp)
}
return
}
//nolint:deadcode,unused // FIXME
func matchFingerprint(p *Process, fp *profile.Fingerprint) (score int) {
if !fp.MatchesOS() {
return 0
}
switch fp.Type {
case "full_path":
if p.Path == fp.Value {
return profile.GetFingerprintWeight(fp.Type)
}
case "partial_path":
// FIXME: if full_path matches, do not match partial paths
return profile.GetFingerprintWeight(fp.Type)
case "md5_sum", "sha1_sum", "sha256_sum":
// FIXME: one sum is enough, check sums in a grouped form, start with the best
sum, err := p.GetExecHash(fp.Type)
if err != nil {
log.Errorf("process: failed to get hash of executable: %s", err)
} else if sum == fp.Value {
return profile.GetFingerprintWeight(fp.Type)
}
}
return 0
}
*/

11
profile/module_test.go Normal file
View File

@@ -0,0 +1,11 @@
package profile
import (
"testing"
"github.com/safing/portmaster/core/pmtesting"
)
func TestMain(m *testing.M) {
pmtesting.TestMain(m, module)
}