MCPcopy
hub / github.com/BishopFox/jsluice / pairMatcher

Method pairMatcher

user-patterns.go:127–163  ·  view source on GitHub ↗

pairMatcher returns a SecretMatcher for matching against key/value pairs

()

Source from the content-addressed store, hash-verified

125
126// pairMatcher returns a SecretMatcher for matching against key/value pairs
127func (u *UserPattern) pairMatcher() SecretMatcher {
128 return SecretMatcher{"(pair) @matches", func(n *Node) *Secret {
129
130 key := n.ChildByFieldName("key")
131 if key == nil || !u.MatchKey(key.RawString()) {
132 return nil
133 }
134
135 value := n.ChildByFieldName("value")
136 if value == nil || value.Type() != "string" {
137 return nil
138 }
139
140 if !u.MatchValue(value.RawString()) {
141 return nil
142 }
143
144 secret := &Secret{
145 Kind: u.Name,
146 Data: map[string]string{
147 "key": key.RawString(),
148 "value": value.RawString(),
149 },
150 Severity: u.Severity,
151 }
152
153 parent := n.Parent()
154 if parent == nil || parent.Type() != "object" {
155 return secret
156 }
157
158 secret.Context = parent.AsObject().AsMap()
159
160 return secret
161
162 }}
163}
164
165// stringMatcher returns a SecretMatcher for matching against string literals
166func (u *UserPattern) stringMatcher() SecretMatcher {

Callers 2

SecretMatcherMethod · 0.95
objectMatcherMethod · 0.80

Calls 8

MatchKeyMethod · 0.95
MatchValueMethod · 0.95
ChildByFieldNameMethod · 0.80
RawStringMethod · 0.80
ParentMethod · 0.80
AsObjectMethod · 0.80
TypeMethod · 0.45
AsMapMethod · 0.45

Tested by

no test coverage detected