MCPcopy Create free account
hub / github.com/BishopFox/jsluice / ParseRegex

Method ParseRegex

user-patterns.go:28–60  ·  view source on GitHub ↗

ParseRegex parses all of the user-provided regular expressions for a pattern into Go *regexp.Regexp types

()

Source from the content-addressed store, hash-verified

26// ParseRegex parses all of the user-provided regular expressions
27// for a pattern into Go *regexp.Regexp types
28func (u *UserPattern) ParseRegex() error {
29 if u.Value != "" {
30 re, err := regexp.Compile(u.Value)
31 if err != nil {
32 return err
33 }
34 u.reValue = re
35 }
36
37 if u.Key != "" {
38 re, err := regexp.Compile(u.Key)
39 if err != nil {
40 return err
41 }
42 u.reKey = re
43 }
44
45 if len(u.Object) > 0 {
46 for _, m := range u.Object {
47 m.ParseRegex()
48 }
49 }
50
51 if u.Severity == "" {
52 u.Severity = SeverityInfo
53 }
54
55 if u.reValue == nil && u.reKey == nil && len(u.Object) == 0 {
56 return errors.New("'key', 'value', both, or 'object' must be supplied in user-defined matcher")
57 }
58
59 return nil
60}
61
62// MatchValue returns true if a pattern's value regex matches
63// the supplied value, or if there is no value regex.

Callers 1

ParseUserPatternsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected