Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions pkg/types/constants.go

This file was deleted.

31 changes: 0 additions & 31 deletions pkg/types/event.go

This file was deleted.

73 changes: 73 additions & 0 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package types

import (
"strings"
)

type AuthType = string

const (
ApiKeyAuthType AuthType = "api-key"
TlsAuthType AuthType = "tls"
PasswordAuthType AuthType = "password"
)

type DecisionType = string

const (
DecisionTypeBan DecisionType = "ban"
// TODO: add captcha, fix name..
)

type Origin = string

const (
CscliOrigin Origin = "cscli"
CrowdSecOrigin Origin = "crowdsec"
ConsoleOrigin Origin = "console"
CscliImportOrigin Origin = "cscli-import"
ListOrigin Origin = "lists"
CAPIOrigin Origin = "CAPI"
CommunityBlocklistPullSourceScope Origin = "crowdsecurity/community-blocklist"
RemediationSyncOrigin Origin = "remediation_sync"
)

func GetOrigins() []Origin {
return []Origin{
CscliOrigin,
CrowdSecOrigin,
ConsoleOrigin,
CscliImportOrigin,
ListOrigin,
CAPIOrigin,
RemediationSyncOrigin,
}
}

type Scope = string

// Move in leakybuckets
const (
// TODO: fix names
Undefined Scope = ""
Ip Scope = "Ip"
Range Scope = "Range"
Filter Scope = "Filter"
Country Scope = "Country"
AS Scope = "AS"
)

func NormalizeScope(strScope string) Scope {
switch strings.ToLower(strScope) {
case "ip":
return Ip
case "range":
return Range
case "as":
return AS
case "country":
return Country
default:
return strScope
}
}