Skip to content

Commit

Permalink
create one sniffer for all containers
Browse files Browse the repository at this point in the history
  • Loading branch information
rcohencyberarmor committed Dec 22, 2022
1 parent dd5f57c commit 0693723
Show file tree
Hide file tree
Showing 8 changed files with 409 additions and 318 deletions.
5 changes: 3 additions & 2 deletions configuration/SneefferConfigurationFile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ snifferEngineLoaderPath=./resources/ebpf/sniffer
sbomCreatorPath=./resources/sbom/syft
vulnCreatorPath=./resources/vuln/grype
snifferTime=1
loggerVerbose=DEBUG
loggerVerbose=INFO
crdFullDetailedPath=./resources/k8s/crd-vuln-full-detailes.yaml
crdVulnSummaryPath=./resources/k8s/crd-vuln-summary.yaml
myNode=minikube
enableProfiling=true
enableContainerProfilingService=true
enableRelaventCVEsService=false
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ go 1.18

require (
github.com/anchore/syft v0.57.0
k8s.io/api v0.25.2
k8s.io/api v0.25.3
k8s.io/apiextensions-apiserver v0.25.2
k8s.io/apimachinery v0.25.2
k8s.io/client-go v0.25.2
k8s.io/apimachinery v0.25.3
k8s.io/client-go v0.25.3
)

require github.com/google/go-cmp v0.5.9 // indirect

require (
github.com/anchore/grype v0.50.2
github.com/docker/docker v20.10.17+incompatible
github.com/kubescape/k8s-interface v0.0.85
github.com/kubescape/k8s-interface v0.0.89
github.com/sirupsen/logrus v1.9.0
github.com/xyproto/randomstring v0.0.0-20220311122621-4964ec363205
gopkg.in/yaml.v2 v2.4.0
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,8 @@ github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kubescape/k8s-interface v0.0.85 h1:OC6uvqLlajwXCmfEFzKowWyAsv94Ec+fJzsjoccX9+8=
github.com/kubescape/k8s-interface v0.0.85/go.mod h1:ihX96yqar+xogHl45mFE8zT9DLI06iy7XQPAP+j5KJE=
github.com/kubescape/k8s-interface v0.0.89 h1:OtlvZosHpjlbHfsilfQk2wRbuBnxwF0e+WZX6GbkfLU=
github.com/kubescape/k8s-interface v0.0.89/go.mod h1:pgFRs20mHiavf6+fFWY7h/f8HuKlwuZwirvjxiKJlu0=
github.com/kulti/thelper v0.4.0/go.mod h1:vMu2Cizjy/grP+jmsvOFDx1kYP6+PD1lqg4Yu5exl2U=
github.com/kunwardeep/paralleltest v1.0.3/go.mod h1:vLydzomDFpk7yu5UX02RmP0H8QfRPOV/oFhWN85Mjb4=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
Expand Down Expand Up @@ -2894,23 +2894,23 @@ honnef.co/go/tools v0.2.1/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY=
k8s.io/api v0.20.1/go.mod h1:KqwcCVogGxQY3nBlRpwt+wpAMF/KjaCc7RpywacvqUo=
k8s.io/api v0.20.4/go.mod h1:++lNL1AJMkDymriNniQsWRkMDzRaX2Y/POTUi8yvqYQ=
k8s.io/api v0.20.6/go.mod h1:X9e8Qag6JV/bL5G6bU8sdVRltWKmdHsFUGS3eVndqE8=
k8s.io/api v0.25.2 h1:v6G8RyFcwf0HR5jQGIAYlvtRNrxMJQG1xJzaSeVnIS8=
k8s.io/api v0.25.2/go.mod h1:qP1Rn4sCVFwx/xIhe+we2cwBLTXNcheRyYXwajonhy0=
k8s.io/api v0.25.3 h1:Q1v5UFfYe87vi5H7NU0p4RXC26PPMT8KOpr1TLQbCMQ=
k8s.io/api v0.25.3/go.mod h1:o42gKscFrEVjHdQnyRenACrMtbuJsVdP+WVjqejfzmI=
k8s.io/apiextensions-apiserver v0.25.2 h1:8uOQX17RE7XL02ngtnh3TgifY7EhekpK+/piwzQNnBo=
k8s.io/apiextensions-apiserver v0.25.2/go.mod h1:iRwwRDlWPfaHhuBfQ0WMa5skdQfrE18QXJaJvIDLvE8=
k8s.io/apimachinery v0.20.1/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU=
k8s.io/apimachinery v0.20.4/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU=
k8s.io/apimachinery v0.20.6/go.mod h1:ejZXtW1Ra6V1O5H8xPBGz+T3+4gfkTCeExAHKU57MAc=
k8s.io/apimachinery v0.25.2 h1:WbxfAjCx+AeN8Ilp9joWnyJ6xu9OMeS/fsfjK/5zaQs=
k8s.io/apimachinery v0.25.2/go.mod h1:hqqA1X0bsgsxI6dXsJ4HnNTBOmJNxyPp8dw3u2fSHwA=
k8s.io/apimachinery v0.25.3 h1:7o9ium4uyUOM76t6aunP0nZuex7gDf8VGwkR5RcJnQc=
k8s.io/apimachinery v0.25.3/go.mod h1:jaF9C/iPNM1FuLl7Zuy5b9v+n35HGSh6AQ4HYRkCqwo=
k8s.io/apiserver v0.20.1/go.mod h1:ro5QHeQkgMS7ZGpvf4tSMx6bBOgPfE+f52KwvXfScaU=
k8s.io/apiserver v0.20.4/go.mod h1:Mc80thBKOyy7tbvFtB4kJv1kbdD0eIH8k8vianJcbFM=
k8s.io/apiserver v0.20.6/go.mod h1:QIJXNt6i6JB+0YQRNcS0hdRHJlMhflFmsBDeSgT1r8Q=
k8s.io/client-go v0.20.1/go.mod h1:/zcHdt1TeWSd5HoUe6elJmHSQ6uLLgp4bIJHVEuy+/Y=
k8s.io/client-go v0.20.4/go.mod h1:LiMv25ND1gLUdBeYxBIwKpkSC5IsozMMmOOeSJboP+k=
k8s.io/client-go v0.20.6/go.mod h1:nNQMnOvEUEsOzRRFIIkdmYOjAZrC8bgq0ExboWSU1I0=
k8s.io/client-go v0.25.2 h1:SUPp9p5CwM0yXGQrwYurw9LWz+YtMwhWd0GqOsSiefo=
k8s.io/client-go v0.25.2/go.mod h1:i7cNU7N+yGQmJkewcRD2+Vuj4iz7b30kI8OcL3horQ4=
k8s.io/client-go v0.25.3 h1:oB4Dyl8d6UbfDHD8Bv8evKylzs3BXzzufLiO27xuPs0=
k8s.io/client-go v0.25.3/go.mod h1:t39LPczAIMwycjcXkVc+CB+PZV69jQuNx4um5ORDjQA=
k8s.io/component-base v0.20.1/go.mod h1:guxkoJnNoh8LNrbtiQOlyp2Y2XFCZQmrcg2n/DeYNLk=
k8s.io/component-base v0.20.4/go.mod h1:t4p9EdiagbVCJKrQ1RsA5/V4rFQNDfRlevJajlGwgjI=
k8s.io/component-base v0.20.6/go.mod h1:6f1MPBAeI+mvuts3sIdtpjljHWBQ2cIy38oBIWMYnrM=
Expand Down
46 changes: 40 additions & 6 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ var sycscallFilterForContainerProfiling []string
var manadatoryConfigurationVars []string
var innerDirectoriesPath []string

var relaventCVEService bool
var containerProfilingService bool

func init() {
manadatoryConfigurationVars = append(manadatoryConfigurationVars, "kernelObjPath")
manadatoryConfigurationVars = append(manadatoryConfigurationVars, "snifferEngineLoaderPath")
Expand All @@ -28,6 +31,8 @@ func init() {
innerDirectoriesPath = append(innerDirectoriesPath, "/sbom")
innerDirectoriesPath = append(innerDirectoriesPath, "/vuln")
sycscallFilterForRelaventCVES = append(sycscallFilterForRelaventCVES, []string{"execve", "execveat", "open", "openat"}...)
containerProfilingService = false
relaventCVEService = false
}

func parseConfigurationFile(configurationFilePath string) error {
Expand Down Expand Up @@ -89,13 +94,38 @@ func loggerConfig() {
logger.ConfigLogger(verbose, "")
}

func servicesConfig() error {
serviceExist := false

val, exist := os.LookupEnv("enableRelaventCVEsService")
if exist {
if val == "true" || val == "True" {
relaventCVEService = true
serviceExist = true
logger.Print(logger.INFO, false, "sneeffer service find relavent CVEs is enabled\n")
}
}
val, exist = os.LookupEnv("enableContainerProfilingService")
if exist {
if val == "true" || val == "True" {
containerProfilingService = true
serviceExist = true
logger.Print(logger.INFO, false, "sneeffer service container profiling is enabled\n")
}
}
if !serviceExist {
return fmt.Errorf("no service is configured to use, please look in the configuration file that one of the services mark as true or True")
}
return nil
}

func afterConfigurationParserActions() error {
err := createInnerDirectories()
if err != nil {
return err
}
loggerConfig()
return nil
return servicesConfig()
}

func ParseConfiguration() error {
Expand Down Expand Up @@ -123,12 +153,16 @@ func ParseConfiguration() error {
}

func GetSyscallFilter() []string {
val, exist := os.LookupEnv("enableProfiling")
if !exist {
return sycscallFilterForRelaventCVES
}
if val == "true" || val == "True" {
if IsContainerProfilingServiceEnabled() {
return sycscallFilterForContainerProfiling
}
return sycscallFilterForRelaventCVES
}

func IsRelaventCVEServiceEnabled() bool {
return relaventCVEService
}

func IsContainerProfilingServiceEnabled() bool {
return containerProfilingService
}
Loading

0 comments on commit 0693723

Please sign in to comment.