From 3f9787ad086e0cc0b4dfecd6c485c2e86ba6afe0 Mon Sep 17 00:00:00 2001 From: Derek Abdine <1955040+dabdine@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:10:51 -0700 Subject: [PATCH] Add fingerprint/db reference to fp match --- fingerprints.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fingerprints.go b/fingerprints.go index 37fb223..3cc01ea 100644 --- a/fingerprints.go +++ b/fingerprints.go @@ -45,6 +45,7 @@ type Fingerprint struct { Params []*FingerprintParam `xml:"param,omitempty" json:"param,omitempty"` Certainty string `xml:"certainty,attr,omitempty" json:"certainty,omitempty"` PatternCompiled *regexp.Regexp `xml:"-" json:"-"` + DB *FingerprintDB `xml:"-" json:"-"` } var flagsPattern = regexp.MustCompile("[|,]") @@ -110,6 +111,7 @@ func (fp *Fingerprint) Match(data string) *FingerprintMatch { return res } + res.Fingerprint = fp res.Matched = true res.Values = make(map[string]string) @@ -249,9 +251,10 @@ func (fp *Fingerprint) VerifyExamples(fpath string) error { // FingerprintMatch represents a match of a fingerprint to some data type FingerprintMatch struct { - Matched bool - Errors []error - Values map[string]string + Matched bool + Errors []error + Values map[string]string + Fingerprint *Fingerprint } // FingerprintDB represents a fingerprint database @@ -284,6 +287,9 @@ func (fdb *FingerprintDB) Normalize() error { fdb.DebugLogf("failed to normalize %s: %s", fdb.Name, err) return err } + + // also set the db reference on each fingerprint + fp.DB = fdb } return nil }