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

Method stringMatcher

user-patterns.go:166–193  ·  view source on GitHub ↗

stringMatcher returns a SecretMatcher for matching against string literals

()

Source from the content-addressed store, hash-verified

164
165// stringMatcher returns a SecretMatcher for matching against string literals
166func (u *UserPattern) stringMatcher() SecretMatcher {
167 return SecretMatcher{"(string) @matches", func(n *Node) *Secret {
168 in := n.RawString()
169 if !u.MatchValue(in) {
170 return nil
171 }
172
173 secret := &Secret{
174 Kind: u.Name,
175 Data: map[string]string{"match": in},
176 Severity: u.Severity,
177 }
178
179 parent := n.Parent()
180 if parent == nil || parent.Type() != "pair" {
181 return secret
182 }
183
184 grandParent := parent.Parent()
185 if grandParent == nil || grandParent.Type() != "object" {
186 return secret
187 }
188
189 secret.Context = grandParent.AsObject().AsMap()
190
191 return secret
192 }}
193}
194
195// UserPatterns is an alias for a slice of *UserPattern
196type UserPatterns []*UserPattern

Callers 1

SecretMatcherMethod · 0.95

Calls 6

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

Tested by

no test coverage detected