MCPcopy
hub / github.com/crowdsecurity/crowdsec / GetAllowList

Method GetAllowList

pkg/database/allowlists.go:102–118  ·  view source on GitHub ↗
(ctx context.Context, name string, withContent bool)

Source from the content-addressed store, hash-verified

100}
101
102func (c *Client) GetAllowList(ctx context.Context, name string, withContent bool) (*ent.AllowList, error) {
103 q := c.Ent.AllowList.Query().Where(allowlist.NameEQ(name))
104 if withContent {
105 q = q.WithAllowlistItems()
106 }
107
108 result, err := q.First(ctx)
109 if err != nil {
110 if ent.IsNotFound(err) {
111 return nil, fmt.Errorf("allowlist '%s' not found", name)
112 }
113
114 return nil, err
115 }
116
117 return result, nil
118}
119
120func (c *Client) GetAllowListByID(ctx context.Context, allowlistID string, withContent bool) (*ent.AllowList, error) {
121 q := c.Ent.AllowList.Query().Where(allowlist.AllowlistIDEQ(allowlistID))

Callers 5

GetAllowlistMethod · 0.80
deleteMethod · 0.80
addMethod · 0.80
removeMethod · 0.80
import_allowlistMethod · 0.80

Calls 6

NameEQFunction · 0.92
IsNotFoundFunction · 0.92
WithAllowlistItemsMethod · 0.80
WhereMethod · 0.45
QueryMethod · 0.45
FirstMethod · 0.45

Tested by

no test coverage detected