libs

package
v0.0.0-...-d92e82c Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATUS     = "Passed"
	LIMIT      = " limit "
	BACK_SLASH = "\""
	COMMA      = ","
	QUOTATION  = `"`
	INGRESS    = "INGRESS"
	EGRESS     = "EGRESS"
	FORWARDED  = "FORWARDED"
	DROPPED    = "DROPPED"
	ERROR      = "ERROR"
	AUDIT      = "AUDIT"
	L7         = "L7"
	L3_L4      = "L3_L4"
)

Basic Constant

View Source
const (
	TimeForm       string = "2006-01-02T15:04:05.000000"
	TimeFormSimple string = "2006-01-02 15:04:05"
	TimeFormUTC    string = "2006-01-02T15:04:05.000000Z"
	TimeFormHuman  string = "2006-01-02 15:04:05.000000"
	TimeCilium     string = "2006-01-02T15:04:05.000000000Z"
)

Time Format

Variables

View Source
var (
	TableNetworkFlow      string
	TableDiscoveredPolicy string

	DBDriver string
	DBHost   string
	DBPort   string
	DBUser   string
	DBPass   string
	DBName   string
)

env values

View Source
var QueryBaseSimple string = "select id,time,traffic_direction,verdict,policy_match_type,drop_reason,event_type,source,destination,ip,l4,l7 from "

QueryBaseSimple

Functions

func CheckHTTPMethod

func CheckHTTPMethod(method string) bool

CheckHTTPMethod Function

func CheckSpecHTTP

func CheckSpecHTTP(specs []string) bool

CheckSpecHTTP Function

func ClearDBTablesMySQL

func ClearDBTablesMySQL() error

func Combinations

func Combinations(set []string, n int) (subsets [][]string)

Combinations Function

func ConnectInClusterAPIClient

func ConnectInClusterAPIClient() *kubernetes.Clientset

ConnectInClusterAPIClient Function

func ConnectK8sClient

func ConnectK8sClient() *kubernetes.Clientset

ConnectK8sClient Function

func ConnectLocalAPIClient

func ConnectLocalAPIClient() *kubernetes.Clientset

ConnectLocalAPIClient Function

func ConnectMongoDB

func ConnectMongoDB() (*mongo.Client, *mongo.Database)

ConnectMongoDB function

func ConnectMySQL

func ConnectMySQL() (db *sql.DB)

ConnectMySQL function

func ContainLabel

func ContainLabel(label, targetLabel string) bool

ContainLabel Function

func ContainsElement

func ContainsElement(slice interface{}, element interface{}) bool

ContainsElement Function

func ConvertArrayToString

func ConvertArrayToString(arr []string) string

ConvertArrayToString - Convert Array of string to String

func ConvertUnixTSToDateTime

func ConvertUnixTSToDateTime(ts int64) primitive.DateTime

ConvertUnixTSToDateTime Function

func CountLabelByCombinations

func CountLabelByCombinations(labelCount map[string]int, mergedLabels string)

CountLabelByCombinations Function (combination!)

func CountPoliciesByName

func CountPoliciesByName(col *mongo.Collection, name string) int

CountPoliciesByName Function

func CreateTableNetworkLogsMySQL

func CreateTableNetworkLogsMySQL() error

func CreateTableNetworkPolicyMySQL

func CreateTableNetworkPolicyMySQL() error

func GetCommandOutput

func GetCommandOutput(cmd string, args []string) string

GetCommandOutput Function

func GetDocsByFilter

func GetDocsByFilter(col *mongo.Collection, filter primitive.M) ([]map[string]interface{}, error)

GetDocsByFilter Function

func GetEndpoints

func GetEndpoints() []types.Endpoint

GetEndpoints Function

func GetEnv

func GetEnv(key, fallback string) string

GetEnv Function

func GetEnvInt

func GetEnvInt(key string, fallback int) int

GetEnvInt Function

func GetExternalIPAddr

func GetExternalIPAddr() string

GetExternalIPAddr Function

func GetExternalInterface

func GetExternalInterface() string

GetExternalInterface Function

func GetIPAddr

func GetIPAddr(ifname string) string

GetIPAddr Function

func GetNamespaces

func GetNamespaces() []string

GetNamespaces Function

func GetNetworkPolicies

func GetNetworkPolicies(namespace, status string) []types.KnoxNetworkPolicy

GetNetworkPolicies Function

func GetNetworkPoliciesBySelector

func GetNetworkPoliciesBySelector(namespace, status string, selector map[string]string) ([]types.KnoxNetworkPolicy, error)

GetNetworkPoliciesBySelector Function

func GetNetworkPoliciesFromMongo

func GetNetworkPoliciesFromMongo(namespace, status string) ([]types.KnoxNetworkPolicy, error)

GetNetworkPoliciesFromMongo Function

func GetNetworkPoliciesFromMySQL

func GetNetworkPoliciesFromMySQL(namespace, status string) ([]types.KnoxNetworkPolicy, error)

GetNetworkPoliciesFromMySQL function

func GetOSSigChannel

func GetOSSigChannel() chan os.Signal

GetOSSigChannel Function

func GetPods

func GetPods() []types.Pod

GetPods Function

func GetProtocol

func GetProtocol(protocol int) string

GetProtocol Function

func GetProtocolInt

func GetProtocolInt(protocol string) int

GetProtocolInt Function

func GetServices

func GetServices() []types.Service

GetServices Function

func GetTrafficFlow

func GetTrafficFlow() ([]map[string]interface{}, error)

GetTrafficFlow function

func GetTrafficFlowByIDTime

func GetTrafficFlowByIDTime(id, endTime int64) ([]map[string]interface{}, error)

GetTrafficFlowByIDTime function

func GetTrafficFlowByTime

func GetTrafficFlowByTime(startTime, endTime int64) ([]map[string]interface{}, error)

GetTrafficFlowByTime function

func GetTrafficFlowFromDB

func GetTrafficFlowFromDB() []map[string]interface{}

GetTrafficFlowFromDB function

func GetTrafficFlowFromMongo

func GetTrafficFlowFromMongo(startTime, endTime int64) ([]map[string]interface{}, error)

GetTrafficFlowFromMongo function

func InsertDiscoveredPolicies

func InsertDiscoveredPolicies(policies []types.KnoxNetworkPolicy)

InsertDiscoveredPolicies function

func InsertDiscoveredPoliciesToMongoDB

func InsertDiscoveredPoliciesToMongoDB(policies []types.KnoxNetworkPolicy) error

InsertDiscoveredPoliciesToMongoDB function

func InsertDiscoveredPoliciesToMySQL

func InsertDiscoveredPoliciesToMySQL(policies []types.KnoxNetworkPolicy) error

InsertDiscoveredPoliciesToMySQL function

func InsertNetworkLogsMongoDB

func InsertNetworkLogsMongoDB(netLogs []types.NetworkLogRaw) error

InsertNetworkLogsMongoDB

func InsertNetworkLogsMySQL

func InsertNetworkLogsMySQL(netLogs []types.NetworkLogRaw) error

InsertNetworkLogsMySQL -- Update existing log with time and count

func IsK8sEnv

func IsK8sEnv() bool

IsK8sEnv Function

func Prefix

func Prefix(strs []string) string

Prefix returns the longest common prefix of the provided strings

func PrintKnoxPolicyJSON

func PrintKnoxPolicyJSON(data interface{}) (string, error)

PrintKnoxPolicyJSON function

func RandSeq

func RandSeq(n int) string

RandSeq Function

func SetAnnotationsToPod

func SetAnnotationsToPod(podName string, annotation map[string]string) error

SetAnnotationsToPod Function

func SetAnnotationsToPodsInNamespace

func SetAnnotationsToPodsInNamespace(namespace string, annotation map[string]string) error

SetAnnotationsToPodsInNamespace Function

func Suffix

func Suffix(strs []string) string

Suffix returns the longest common suffix of the provided strings

func TrimPrefix

func TrimPrefix(strs []string)

TrimPrefix removes the longest common prefix from all provided strings

func TrimSuffix

func TrimSuffix(strs []string)

TrimSuffix removes the longest common suffix from all provided strings

func UpdateOrInsertNetworkLogs

func UpdateOrInsertNetworkLogs(netLogs []types.NetworkLogRaw)

UpdateOrInsertNetworkLogs function

func UpdateOutdatedPolicy

func UpdateOutdatedPolicy(outdatedPolicy string, latestPolicy string)

UpdateOutdatedPolicy function

func UpdateOutdatedPolicyFromMongo

func UpdateOutdatedPolicyFromMongo(outdatedPolicy string, latestPolicy string) error

UpdateOutdatedPolicyFromMongo function

func UpdateOutdatedPolicyFromMySQL

func UpdateOutdatedPolicyFromMySQL(outdatedPolicy string, latestPolicy string) error

UpdateOutdatedPolicyFromMySQL ...

func UpdateTimeFilters

func UpdateTimeFilters(filter primitive.M, tsStart, tsEnd int64)

UpdateTimeFilters function

func WriteCiliumPolicyToYamlFile

func WriteCiliumPolicyToYamlFile(namespace string, policies []types.CiliumNetworkPolicy)

WriteCiliumPolicyToYamlFile Function

func WriteKnoxPolicyToJSONFile

func WriteKnoxPolicyToJSONFile(namespace string, policies []types.KnoxNetworkPolicy)

WriteKnoxPolicyToJSONFile Function

func WriteKnoxPolicyToYamlFile

func WriteKnoxPolicyToYamlFile(namespace string, policies []types.KnoxNetworkPolicy)

WriteKnoxPolicyToYamlFile Function

Types

This section is empty.

Jump to

Keyboard shortcuts

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