exprhelpers

package
v1.5.47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CTIApiEnabled = true

this is set for non-recoverable errors, such as 403 when querying API or empty API key

View Source
var CTIApiKey = ""
View Source
var CTIBackOffDuration time.Duration = 5 * time.Minute
View Source
var CTIBackOffUntil time.Time

when hitting quotas or auth errors, we temporarily disable the API

View Source
var CTICache gcache.Cache

Cache for responses

View Source
var CTIUrl = "https://cti.api.crowdsec.net"
View Source
var CTIUrlSuffix = "/v2/smoke/"
View Source
var CacheExpiration time.Duration
View Source
var RegexpCacheMetrics = prometheus.NewGaugeVec(
	prometheus.GaugeOpts{
		Name: "cs_regexp_cache_size",
		Help: "Entries per regexp cache.",
	},
	[]string{"name"},
)

prometheus

Functions

func Atof

func Atof(params ...any) (any, error)

func Atof(x string) float64 {

func B64Decode

func B64Decode(params ...any) (any, error)

func CrowdsecCTI

func CrowdsecCTI(params ...any) (any, error)

func CrowdsecCTI(ip string) (*cticlient.SmokeItem, error) {

func CrowdsecCTIInitCache

func CrowdsecCTIInitCache(size int, ttl time.Duration)

func Distance

func Distance(params ...any) (any, error)

func Distance(lat1 string, long1 string, lat2 string, long2 string) (float64, error) {

func Fields

func Fields(params ...any) (any, error)

func File

func File(params ...any) (any, error)

func File(filename string) []string {

func FileInit

func FileInit(fileFolder string, filename string, fileType string) error

func Get

func Get(params ...any) (any, error)

func Get(arr []string, index int) string {

func GetDecisionsCount

func GetDecisionsCount(params ...any) (any, error)

func GetDecisionsCount(value string) int {

func GetDecisionsSinceCount

func GetDecisionsSinceCount(params ...any) (any, error)

func GetDecisionsSinceCount(value string, since string) int {

func GetExprOptions

func GetExprOptions(ctx map[string]interface{}) []expr.Option

func GetFromStash

func GetFromStash(params ...any) (any, error)

func GetFromStash(cacheName string, key string) (string, error) {

func Hostname

func Hostname(params ...any) (any, error)

func Index

func Index(params ...any) (any, error)

func IndexAny

func IndexAny(params ...any) (any, error)

func Init

func Init(databaseClient *database.Client) error

func InitCrowdsecCTI

func InitCrowdsecCTI(Key *string, TTL *time.Duration, Size *int, LogLevel *log.Level) error

func IpInRange

func IpInRange(params ...any) (any, error)

func IpInRange(ip string, ipRange string) bool {

func IpToRange

func IpToRange(params ...any) (any, error)

func IpToRange(ip string, cidr string) string {

func IsIP

func IsIP(params ...any) (any, error)

func IsIP(ip string) bool {

func IsIPV4

func IsIPV4(params ...any) (any, error)

func IsIPV4(ip string) bool {

func IsIPV6

func IsIPV6(params ...any) (any, error)

func IsIPV6(ip string) bool {

func Join

func Join(params ...any) (any, error)

func JsonExtract

func JsonExtract(params ...any) (any, error)

func JsonExtract(jsblob string, target string) string {

func JsonExtractLib

func JsonExtractLib(params ...any) (any, error)

func JsonExtractLib(jsblob string, target ...string) string {

func JsonExtractObject

func JsonExtractObject(params ...any) (any, error)

func JsonExtractObject(jsblob string, target string) map[string]interface{} {

func JsonExtractSlice

func JsonExtractSlice(params ...any) (any, error)

func JsonExtractSlice(jsblob string, target string) []interface{} {

func JsonExtractUnescape

func JsonExtractUnescape(params ...any) (any, error)

func JsonExtractUnescape(jsblob string, target ...string) string {

func KeyExists

func KeyExists(params ...any) (any, error)

func KeyExists(key string, dict map[string]interface{}) bool {

func LogInfo

func LogInfo(params ...any) (any, error)

func LookupHost

func LookupHost(params ...any) (any, error)

func LookupHost(value string) []string {

func Lower

func Lower(params ...any) (any, error)

func Lower(s string) string {

func Match

func Match(params ...any) (any, error)

func Match(pattern, name string) bool {

func ParseKV

func ParseKV(params ...any) (any, error)

func ParseUnix

func ParseUnix(params ...any) (any, error)

func ParseUnix(value string) string {

func ParseUnixTime

func ParseUnixTime(params ...any) (any, error)

func ParseUnixTime(value string) (time.Time, error) {

func ParseUri

func ParseUri(params ...any) (any, error)

func ParseUri(uri string) map[string][]string {

func PathEscape

func PathEscape(params ...any) (any, error)

func PathEscape(s string) string {

func PathUnescape

func PathUnescape(params ...any) (any, error)

func PathUnescape(s string) string {

func QueryEscape

func QueryEscape(params ...any) (any, error)

func QueryEscape(s string) string {

func QueryUnescape

func QueryUnescape(params ...any) (any, error)

func QueryUnescape(s string) string {

func RegexpCacheInit

func RegexpCacheInit(filename string, CacheCfg types.DataSource) error

func RegexpInFile

func RegexpInFile(params ...any) (any, error)

func RegexpInFile(data string, filename string) bool {

func Replace

func Replace(params ...any) (any, error)

func ReplaceAll

func ReplaceAll(params ...any) (any, error)

func SetInStash

func SetInStash(params ...any) (any, error)

func SetInStash(cacheName string, key string, value string, expiration *time.Duration) any {

func ShutdownCrowdsecCTI

func ShutdownCrowdsecCTI()

func Split

func Split(params ...any) (any, error)

func SplitAfter

func SplitAfter(params ...any) (any, error)

func SplitAfterN

func SplitAfterN(params ...any) (any, error)

func SplitN

func SplitN(params ...any) (any, error)

func Sprintf

func Sprintf(params ...any) (any, error)

func TimeNow

func TimeNow(params ...any) (any, error)

func TimeNow() string {

func ToJson

func ToJson(params ...any) (any, error)

func ToJson(obj interface{}) string {

func ToString

func ToString(params ...any) (any, error)

func ToString(value interface{}) string {

func Trim

func Trim(params ...any) (any, error)

func TrimLeft

func TrimLeft(params ...any) (any, error)

func TrimPrefix

func TrimPrefix(params ...any) (any, error)

func TrimRight

func TrimRight(params ...any) (any, error)

func TrimSpace

func TrimSpace(params ...any) (any, error)

func TrimSuffix

func TrimSuffix(params ...any) (any, error)

func UnmarshalJSON

func UnmarshalJSON(params ...any) (any, error)

Func UnmarshalJSON(jsonBlob []byte, target interface{}) error {

func UpdateRegexpCacheMetrics

func UpdateRegexpCacheMetrics()

UpdateCacheMetrics is called directly by the prom handler

func Upper

func Upper(params ...any) (any, error)

func Upper(s string) string {

func XMLGetAttributeValue

func XMLGetAttributeValue(params ...any) (any, error)

func XMLGetAttributeValue(xmlString string, path string, attributeName string) string {

func XMLGetNodeValue

func XMLGetNodeValue(params ...any) (any, error)

func XMLGetNodeValue(xmlString string, path string) string {

Types

type ExprDebugger

type ExprDebugger struct {
	// contains filtered or unexported fields
}

ExprDebugger contains the list of expression to be run when debugging an expression filter

func NewDebugger

func NewDebugger(filter string, exprEnv ...expr.Option) (*ExprDebugger, error)

NewDebugger is the exported function that build the debuggers expressions

func (*ExprDebugger) Run

func (e *ExprDebugger) Run(logger *log.Entry, filterResult bool, exprEnv map[string]interface{})

Run display the content of each variable of a filter by evaluating them with expr, again the expr environment given in parameter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL