Giter Site home page Giter Site logo

devopstales / trivy-operator Goto Github PK

View Code? Open in Web Editor NEW
46.0 4.0 10.0 45.58 MB

Kubernetes Operator based on the open-source container vulnerability scanner Trivy.

Home Page: https://devopstales.github.io/trivy-operator/

License: Apache License 2.0

Shell 0.68% Dockerfile 2.11% Python 91.24% Makefile 3.99% Smarty 1.98%
kopf python python3 kubernetes trivy operator kubernetes-operator kubernetes-operators admission-control admission-controller

trivy-operator's Introduction

Trivy Operator

The goal of this project is to provide a vulnerability scanner that continuously scans containers deployed in a Kubernetes cluster. Built with kopf

It works as

  • Operator
    • Scheduled Image scans on running pods
  • Admission Controller
    • protecting unsafe images from being deployed

Inspirated by knqyf263's trivy-enforcer and fleeto's trivy-scanner.

Scheduled Image scans

Default trivy-operator execute a scan script every 5 minutes. It will get images from all the namespaces with the label trivy-scan=true, and then check these images with trivy for vulnerabilities. Finally we will get metrics on http://[pod-ip]:9115/metrics

Trivy Image Validator

The admission controller function can be configured as a ValidatingWebhook in a k8s cluster. Kubernetes will send requests to the admission server when a Pod creation is initiated. The admission controller checks the image using trivy if it is in a namespace with the label trivy-operator-validation=true.

Install

User the helm Chert

Usage

kubectl label namespaces guestbook-demo trivy-scan=true
kubectl label namespaces guestbook-demo trivy-operator-validation=true
# or
kubectl apply -f deploy/kubernetes/10_demo.yaml

kubectl apply -f deploy/kubernetes/04_trivy-config.yaml
curl -s http://10.43.179.39:9115/metrics | grep trivy_vulnerabilities
# HELP trivy_vulnerabilities_sum Container vulnerabilities
# TYPE trivy_vulnerabilities_sum gauge
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/openshift/mysql-56-centos7:latest",severity="scanning_error"} 1.0
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",severity="UNKNOWN"} 0.0
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",severity="LOW"} 83.0
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",severity="MEDIUM"} 5.0
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",severity="HIGH"} 7.0
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",severity="CRITICAL"} 4.0
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="UNKNOWN"} 0.0
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="LOW"} 126.0
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="MEDIUM"} 25.0
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="HIGH"} 43.0
trivy_vulnerabilities_sum{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="CRITICAL"} 21.0
# HELP trivy_vulnerabilities Container vulnerabilities
# TYPE trivy_vulnerabilities gauge
trivy_vulnerabilities{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",installedVersion="2.2.4",pkgName="pkgName",severity="LOW",vulnerabilityId="CVE-2011-3374"} 1.0
trivy_vulnerabilities{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",installedVersion="8.32-4",pkgName="pkgName",severity="LOW",vulnerabilityId="CVE-2016-2781"} 1.0
trivy_vulnerabilities{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",installedVersion="8.32-4",pkgName="pkgName",severity="LOW",vulnerabilityId="CVE-2017-18018"} 1.0
trivy_vulnerabilities{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",installedVersion="7.74.0-1.3",pkgName="pkgName",severity="CRITICAL",vulnerabilityId="CVE-2021-22945"} 1.0
trivy_vulnerabilities{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",installedVersion="7.74.0-1.3",pkgName="pkgName",severity="HIGH",vulnerabilityId="CVE-2021-22946"} 1.0
trivy_vulnerabilities{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",installedVersion="7.74.0-1.3",pkgName="pkgName",severity="MEDIUM",vulnerabilityId="CVE-2021-22947"} 1.0
trivy_vulnerabilities{exported_namespace="trivytest",image="docker.io/nginxinc/nginx-unprivileged:latest",installedVersion="7.74.0-1.3",pkgName="pkgName",severity="LOW",vulnerabilityId="CVE-2021-22898"} 1.0
curl -s http://10.43.179.39:9115/metrics | grep ac_vulnerabilities

# HELP ac_vulnerabilities Admission Controller vulnerabilities
# TYPE ac_vulnerabilities gauge
ac_vulnerabilities{exported_namespace="trivytest",image="nginxinc/nginx-unprivileged:latest",severity="UNKNOWN"} 0.0
ac_vulnerabilities{exported_namespace="trivytest",image="nginxinc/nginx-unprivileged:latest",severity="LOW"} 83.0
ac_vulnerabilities{exported_namespace="trivytest",image="nginxinc/nginx-unprivileged:latest",severity="MEDIUM"} 6.0
ac_vulnerabilities{exported_namespace="trivytest",image="nginxinc/nginx-unprivileged:latest",severity="HIGH"} 6.0
ac_vulnerabilities{exported_namespace="trivytest",image="nginxinc/nginx-unprivileged:latest",severity="CRITICAL"} 4.0
kubectl logs 

[2021-10-02 09:38:38,598] kopf.activities.star [INFO    ] Activity 'startup_fn_crd' succeeded.
[2021-10-02 09:38:38,687] kopf.activities.star [INFO    ] trivy cache created...
[2021-10-02 09:38:38,687] kopf.activities.star [INFO    ] Activity 'startup_fn_trivy_cache' succeeded.
[2021-10-02 09:38:38,689] kopf._core.engines.a [INFO    ] Initial authentication has been initiated.
[2021-10-02 09:38:38,696] kopf.activities.auth [INFO    ] Activity 'login_via_client' succeeded.
[2021-10-02 09:38:38,697] kopf._core.engines.a [INFO    ] Initial authentication has finished.
[2021-10-02 09:38:46,726] kopf.objects         [INFO    ] [trivytest/main-config] Prometheus Exporter started...
[2021-10-02 09:40:01,831] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:1.18
[2021-10-02 09:40:05,245] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:latest
[2021-10-02 09:40:23,817] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:1.18
[2021-10-02 09:40:26,947] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:latest
[2021-10-02 09:40:45,428] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:1.18
[2021-10-02 09:40:48,949] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:latest

[2021-10-02 09:45:08,229] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:1.18
[2021-10-02 09:45:11,922] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:latest
[2021-10-02 09:45:30,381] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:1.18
[2021-10-02 09:45:33,881] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:latest
[2021-10-02 09:45:52,227] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:1.18
[2021-10-02 09:45:55,556] kopf.objects         [INFO    ] [trivytest/main-config] Scanning Image: docker.io/library/nginx:latest

[2021-10-02 18:33:32,742] kopf.objects         [INFO    ] [trivytest/app-85ddd4585b-sdt4t] Admission Controller is working
[2021-10-02 18:33:32,755] kopf.objects         [INFO    ] [trivytest/app-85ddd4585b-sdt4t] Scanning Image: nginxinc/nginx-unprivileged:latest
[2021-10-02 18:33:34,967] kopf.objects         [INFO    ] [trivytest/app-85ddd4585b-sdt4t] severity: {'UNKNOWN': 0, 'LOW': 83, 'MEDIUM': 6, 'HIGH':6, 'CRITICAL': 4}
[2021-10-02 18:33:34,969] kopf.objects         [ERROR   ] [trivytest/app-85ddd4585b-sdt4t] Webhook 'validate1' failed permanently: Too muchvulnerability in the image: nginxinc/nginx-unprivileged:latest
[2021-10-02 18:33:34,971] aiohttp.access       [INFO    ] 10.244.0.1 [17/Dec/2021:18:33:32 +0000] "POST /validate1?timeout=30s HTTP/1.1" 200 417"-" "kube-apiserver-admission"

Example Deploy:

You can define policy to the Admission Controller, by adding annotation to the pod through the deployment:

spec:
  ...
  template:
    metadata:
      annotations:
        trivy.security.devopstales.io/medium: "5"
        trivy.security.devopstales.io/low: "10"
        trivy.security.devopstales.io/critical: "2"
...

Development

Install trivy:

nano /etc/yum.repos.d/trivy.repo
[trivy]
name=Trivy repository
baseurl=https://aquasecurity.github.io/trivy-repo/rpm/releases/$releasever/$basearch/
gpgcheck=0
enabled=1

sudo yum -y install trivy

To run kopf development you need to install the fallowing packages to the k3s host:

yum install -y python3.8
pip3 install --no-cache-dir kopf[dev] kubernetes asyncio pycron prometheus_client oscrypto certvalidator certbuilder validators pyOpenSSL

The admission webhook try to call the host with the domain name host.k3d.internal so I added to the host's /etc/host file.

echo "172.17.12.10 host.k3d.internal" >> /etc/host
kopf run -A ./trivy-operator.py

trivy-operator's People

Contributors

devopstales avatar evgkrsk avatar maxidrom-admin avatar mend-bolt-for-github[bot] avatar stensonb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

trivy-operator's Issues

UnboundLocalError: local variable 'registry_list' referenced before assignment on Openshift.

Describe the bug
I got the following error.

[2023-01-24 14:54:58,548] kopf.objects         [ERROR   ] [my-namespace/trivy-operator-main-config] Handler 'create_fn' failed with an exception. Will retry.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py", line 279, in execute_handler_once
    result = await invoke_handler(
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py", line 374, in invoke_handler
    result = await invocation.invoke(
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/invocation.py", line 116, in invoke
    result = await fn(**kwargs)  # type: ignore
  File "/trivy-operator.py", line 416, in create_fn
    pull_secret_decoder(tmp3, tagged_ns)
  File "/trivy-operator.py", line 240, in pull_secret_decoder
    registry_list.append(data['auths'])
UnboundLocalError: local variable 'registry_list' referenced before assignment

The error I encountered is related to the registry_list = spec['registry'] line of code because I got DEBUG message [2023-01-24 14:54:58,541] kopf.objects [DEBUG ] [my-namespace/trivy-operator-main-config] No registry auth config is defined.

Expected behavior
I set registryAuth > registry in Helm Values file but it looks that trivy-operator pod can't get the value from it.
Value of registry should be configured in trivy-operator pod, so registry_list = spec['registry'] would be success and local variable registry_list would be assigned before registry_list.append(data['auths']).

https://github.com/devopstales/trivy-operator/blob/main/trivy-operator.py#L229-L233
https://github.com/devopstales/trivy-operator/blob/main/trivy-operator.py#L240

Configuration file
Due to the above error, the NamespaceScanner is not created.

Helm Values file

image:
  # -- The docker image repository to use
  repository: devopstales/trivy-operator
  # -- The docker image pull policy
  pullPolicy: Always
  # -- The docker image tag to use
  tag: "2.5"

# -- Time Zone in container
TimeZone: UTC

# -- Log level
log_level: "DEBUG"
# INFO, HIGH, DEBUG

# -- list of secrets to use for imae pull
imagePullSecrets: []
# -- security options for the pod
podSecurityContext:
  fsGroup: 10001
  fsGroupChangePolicy: "OnRootMismatch"

serviceAccount:
  # -- Enable serviceAccount creation
  create: true
  # -- serviceAccount annotations
  annotations: {}
  # -- Name of the serviceAccount
  name: "trivy-operator"

# Dont try to download trivy db, run in air-gapped env:
offline:
  # -- enable air-gapped mode
  enabled: false
  # -- repository to use for download trivy vuln db
  db_repository: localhost:5000/trivy-db
  # -- insecure repository
  db_repository_insecure: False

cache:
  # -- enable redis cache
  enabled: false

monitoring:
  # -- configure prometheus monitoring port
  port: "9115"

# deploy service monitor
serviceMonitor:
  # -- allow to override the namespace for serviceMonitor
  enabled: false
  # -- Name of the namespace for serviceMonitor
  namespace: {}
  labels:
    # -- labels to match the serviceMonitorSelector of the Prometheus Resource
    release: prometheus
  # https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#relabelconfig
  # -- relabel config for serviceMonitor
  relabelings: []
  # see serviceMonitor.relabelings
  # -- metricRelabeling config for serviceMonitor
  metricRelabelings: []

grafana:
  # -- namespace for configMap of grafana dashboards
  namespace:
  dashboards:
    # -- Enable the deployment of grafana dashboards
    enabled: true
    # -- Label to find dashboards using the k8s sidecar
    label: grafana_dashboard
    # -- Label value to find dashboards using the k8s sidecar
    value: "1"
  folder:
    # -- Annotation to enable folder storage using the k8s sidecar
    annotation: grafana_folder
    # -- Grafana folder in which to store the dashboards
    name: Policy Reporter

persistence:
  # -- Volumes for the pod
  enabled: true
  # -- Volumes mode
  accessMode: "ReadWriteOnce"
  # -- Volumes size
  size: "3Gi"
  # -- Volumes annotations
  annotations: {}
  ## database data Persistent Volume Storage Class
  ## If defined, storageClassName: <storageClass>
  ## If set to "-", storageClassName: "", which disables dynamic provisioning
  ## If undefined (the default) or set to null, no storageClassName spec is
  ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
  ##   GKE, AWS & OpenStack)
  ##
  # storageClass: "-"

# content foc ns-scan CRD
namespaceScanner:
  crontab: "*/1 * * * *"
  namespaceSelector: "trivy-scan"
  clusterWide: false
  integrations:
    policyreport: false
#    defectdojo:
#      host: "https://defectdojo.k8s.intra"
#      api_key: "xyz456ucdssd67sd67dsg"
#      k8s-cluster-name: "eks-prod"

kube_bench_scnner:
  image:
    # -- The docker image repository to use
    repository: devopstales/kube-bench-scnner
    # -- The docker image pull policy
    pullPolicy: Always
    # -- The docker image tag to use
    tag: "2.5"

clusterScanner:
  # -- enable clusterScanner cr creation
  enabled: false
  # -- crontab for scheduled scan
  crontab: "*/1 * * * *"
  # -- kube-hunter scan profile
  scanProfileName: "cis-1.23"
  # -- configure defectdojo integration
  integrations: {}
#    defectdojo:
#      host: "https://defectdojo.k8s.intra"
#      api_key: "xyz456ucdssd67sd67dsg"
#      k8s-cluster-name: "eks-prod"

admissionController:
  # -- enable adission controller
  enabled: false

# authentication informatin for trivy to use wen scan image
registryAuth:
  # -- enable registry authentication
  enabled: false
  # -- list of image pull secrets for authentication
  image_pull_secrets:
    - regcred
  registry:
    - name: image-registry.openshift-image-registry.svc\:5000
      username: "serviceaccount"
      password: "******"

# github authentiation token for trivy database download
githubToken:
  # -- enable github authentiation token
  enabled: false
  # -- github authentiation token value
  token: ""

## Define which Nodes the Pods are scheduled on.
## ref: https://kubernetes.io/docs/user-guide/node-selection/
# -- Set the node selector for the pod.
nodeSelector: {}

## Tolerations for use with node taints
## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
# -- Set the tolerations for the pod.
tolerations: []
# - key: "key"
#   operator: "Equal"
#   value: "value"
#   effect: "NoSchedule"

## Assign custom affinity rules to the trivy operator
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
# -- Set the affinity for the pod.
affinity: {}
# nodeAffinity:
#   requiredDuringSchedulingIgnoredDuringExecution:
#     nodeSelectorTerms:
#     - matchExpressions:
#       - key: kubernetes.io/e2e-az-name
#         operator: In
#         values:
#         - e2e-az1
#         - e2e-az2%

Environment:

  • Trivy-Operator version (use trivy-operator version): 2.5.0
  • Installation type (Helm, Kubernetes, OperatorFramework): Helm
  • Kubernetes version (use kubectl version): I use Oenshift(Client Version: 4.10.12/Server Version: 4.10.36/Kubernetes Version: v1.23.5+8471591)
  • OS (macOS 10.15, Windows 10, Ubuntu 19.10 etc):Red Hat Enterprise Linux CoreOS 410.84.202210040010-0 (Ootpa)

Additional context
I got the same error on Kubernetes Deploy.
https://github.com/devopstales/trivy-operator/tree/main/deploy/kubernetes

This is 05_namespace-scanner.yaml I applied for openshift.

# cat 05_namespace-scanner.yaml
apiVersion: trivy-operator.devopstales.io/v1
kind: NamespaceScanner
metadata:
  name: main-config
spec:
  crontab: "*/1 * * * *"
  namespace_selector: "trivy-scan"
  clusterWide: False
  integrations:
    policyreport: True
#    defectdojo:
#      host: "https://defectdojo.k8s.intra"
#      api_key: "xyz456ucdssd67sd67dsg"
  image_pull_secrets:
    - trivy-operator-dockercfg-cw8lh
  registry:
  - name: image-registry.openshift-image-registry.svc\:5000
    username: "serviceaccount"
    password: "******"
    insecure: True

ARM64 build

Hi,

Any chance you can create an ARM64 build for Raspberry PI's?

Regards

no matches for kind "NamespaceScanner"

$ helm install --dry-run trivy-operator .
Error: INSTALLATION FAILED: unable to build kubernetes objects from release manifest: unable to recognize "": no matches for kind "NamespaceScanner" in version "trivy-operator.devopstales.io/v1"

Possibly missing a CRD?

All my scan jobs terminate with "OOMKilled"

Describe the bug
After I set label trivy-scan: "true" on namespace default all scan jobs log the following (with varying containers):

{
  "level": "error",
  "ts": 1669701178.2908242,
  "logger": "reconciler.vulnerabilityreport",
  "msg": "Scan job container",
  "job": "trivy-operator/scan-vulnerabilityreport-54989486b6",
  "container": "aurora-haufe",
  "status.reason": "OOMKilled",
  "status.message": "Killed",
  "stacktrace": "github.com/aquasecurity/trivy-operator/pkg/vulnerabilityreport.(*WorkloadController).processFailedScanJob
	/home/runner/work/trivy-operator/trivy-operator/pkg/vulnerabilityreport/controller.go:573
github.com/aquasecurity/trivy-operator/pkg/vulnerabilityreport.(*WorkloadController).reconcileJobs.func1
	/home/runner/work/trivy-operator/trivy-operator/pkg/vulnerabilityreport/controller.go:398
sigs.k8s.io/controller-runtime/pkg/reconcile.Func.Reconcile
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/reconcile/reconcile.go:102
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:121
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:320
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:273
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:234"
}

Expected behavior
The scan jobs should terminate normally

Configuration file
I don't know where to find it

Helm Values file

ServiceMonitor:
  enabled: true
affinity: {}
automountServiceAccountToken: true
compliance:
  failEntriesLimit: 10
excludeNamespaces: ""
fullnameOverride: ""
image:
  pullPolicy: IfNotPresent
  pullSecrets: []
  repository: ghcr.io/aquasecurity/trivy-operator
  tag: ""
managedBy: Helm
nameOverride: ""
nodeSelector: {}
operator:
  accessGlobalSecretsAndServiceAccount: true
  batchDeleteDelay: 10s
  batchDeleteLimit: 10
  builtInTrivyServer: false
  configAuditScannerEnabled: true
  configAuditScannerScanOnlyCurrentRevisions: true
  exposedSecretScannerEnabled: true
  infraAssessmentScannerEnabled: true
  leaderElectionId: trivyoperator-lock
  logDevMode: false
  mergeRbacFindingWithConfigAudit: false
  metricsFindingsEnabled: true
  metricsVulnIdEnabled: false
  namespace: ""
  podLabels: {}
  privateRegistryScanSecretsNames: {}
  rbacAssessmentScannerEnabled: true
  replicas: 1
  scanJobTimeout: 5m
  scanJobsConcurrentLimit: 10
  scanJobsRetryDelay: 30s
  scannerReportTTL: 24h
  vulnerabilityScannerEnabled: true
  vulnerabilityScannerScanOnlyCurrentRevisions: true
  webhookBroadcastTimeout: 30s
  webhookBroadcastURL: ""
podAnnotations: {}
podSecurityContext: {}
priorityClassName: ""
rbac:
  create: true
resources: {}
securityContext:
  allowPrivilegeEscalation: false
  capabilities:
    drop:
    - ALL
  privileged: false
  readOnlyRootFilesystem: true
service:
  metricsPort: 80
serviceAccount:
  annotations: {}
  create: true
  name: ""
serviceMonitor:
  enabled: false
  interval: ""
  labels: {}
targetNamespaces: ""
targetWorkloads: pod,replicaset,replicationcontroller,statefulset,daemonset,cronjob,job
tolerations: []
trivy:
  additionalVulnerabilityReportFields: ""
  command: image
  createConfig: true
  dbRepository: ghcr.io/aquasecurity/trivy-db
  dbRepositoryInsecure: "false"
  ignoreUnfixed: true
  insecureRegistries: {}
  mode: Standalone
  nonSslRegistries: {}
  offlineScan: false
  registry:
    mirror: {}
  repository: ghcr.io/aquasecurity/trivy
  resources:
    limits:
      cpu: 500m
      memory: 500M
    requests:
      cpu: 100m
      memory: 100M
  serverPassword: ""
  serverServiceName: trivy-service
  serverTokenHeader: Trivy-Token
  serverUser: ""
  severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
  supportedConfigAuditKinds: Workload,Service,Role,ClusterRole,NetworkPolicy,Ingress,LimitRange,ResourceQuota
  tag: 0.34.0
  timeout: 5m0s
  useBuiltinRegoPolicies: "true"
trivyOperator:
  configAuditReportsPlugin: Trivy
  metricsResourceLabelsPrefix: k8s_label_
  reportRecordFailedChecksOnly: false
  reportResourceLabels: ""
  scanJobAnnotations: ""
  scanJobAutomountServiceAccountToken: false
  scanJobCompressLogs: true
  scanJobNodeSelector: {}
  scanJobPodTemplateContainerSecurityContext:
    allowPrivilegeEscalation: false
    capabilities:
      drop:
      - ALL
    privileged: false
    readOnlyRootFilesystem: true
  scanJobPodTemplateLabels: ""
  scanJobPodTemplatePodSecurityContext: {}
  scanJobTolerations: []
  skipResourceByLabels: ""
  vulnerabilityReportsPlugin: Trivy

Environment:

  • Trivy-Operator version (use trivy-operator version): ghcr.io/aquasecurity/trivy-operator:0.7.1
  • Installation type (Helm, Kubernetes, OperatorFramework): helm
  • Kubernetes version (use kubectl version): 1.24
  • OS (macOS 10.15, Windows 10, Ubuntu 19.10 etc): Ubuntu 20

Additional context
After I set ´trivy-scan: "true"on namespacedefault` all scan jobs terminated like this (according to the pod log).

{
  "level": "error",
  "ts": 1669701178.2908242,
  "logger": "reconciler.vulnerabilityreport",
  "msg": "Scan job container",
  "job": "trivy-operator/scan-vulnerabilityreport-54989486b6",
  "container": "aurora-haufe",
  "status.reason": "OOMKilled",
  "status.message": "Killed",
  "stacktrace": "github.com/aquasecurity/trivy-operator/pkg/vulnerabilityreport.(*WorkloadController).processFailedScanJob
	/home/runner/work/trivy-operator/trivy-operator/pkg/vulnerabilityreport/controller.go:573
github.com/aquasecurity/trivy-operator/pkg/vulnerabilityreport.(*WorkloadController).reconcileJobs.func1
	/home/runner/work/trivy-operator/trivy-operator/pkg/vulnerabilityreport/controller.go:398
sigs.k8s.io/controller-runtime/pkg/reconcile.Func.Reconcile
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/reconcile/reconcile.go:102
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:121
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:320
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:273
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
	/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:234"
}

RFE: Offline usage trigger

It may be usefull to run trivy-operator in offline (air-gapped) environment.

But now trivy-operator always fetch trivy db on startup ("startup_fn_trivy_cache" function) and during runtime.

I think that it is difficult to embrace all variants of offline envs in real-life, so my suggestion for now is simple: it is possible to implement completely offline trivy usage trigger? Idea is to leave db update up to sysadmin.

Official documentation may be good starting point: https://aquasecurity.github.io/trivy/v0.31.3/docs/advanced/air-gap/

Add relabeling option in the ServiceMonitor object

Hello,
I would like to add the relabeling section to the service monitor, the object would look like this:

{{- if .Values.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    serviceapp: {{ include "trivy-operator.fullname" . }}-trivy-operator
    {{- with .Values.serviceMonitor.labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  name: {{ include "trivy-operator.fullname" . }}-trivy-operator
  namespace: {{ .Release.Namespace }}
spec:
  endpoints:
  - interval: 60s
    path: /
    scrapeTimeout: 30s
    targetPort: 9115
{{- if .Values.serviceMonitor.relabelings }}
    relabelings:
{{ toYaml .Values.serviceMonitor.relabelings | indent 4 }}
{{- end }}

  selector:
    matchLabels:
      app: trivy-operator
      service: metrics
{{- end }}

And values file:

serviceMonitor:
  enabled: true
  labels:
    release: prometheus
  relabelings: []

Thanks! :)

define nodeSelector, Tolerations and Affinity for trivy and cache applications

Hello,
I tried to create a PR but it seems that it is not possible. I would like you to consider adding nodeSelector, Tolerations and Affinity for the Trivy and Cache manifests.

      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- . | toYaml | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- . | toYaml | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- . | toYaml | nindent 8 }}
      {{- end }}

And values with:

## Define which Nodes the Pods are scheduled on.
## ref: https://kubernetes.io/docs/user-guide/node-selection/
##
nodeSelector: {}

## Tolerations for use with node taints
## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
##
tolerations: []
# - key: "key"
#   operator: "Equal"
#   value: "value"
#   effect: "NoSchedule"

## Assign custom affinity rules to the prometheus operator
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
##
affinity: {}
# nodeAffinity:
#   requiredDuringSchedulingIgnoredDuringExecution:
#     nodeSelectorTerms:
#     - matchExpressions:
#       - key: kubernetes.io/e2e-az-name
#         operator: In
#         values:
#         - e2e-az1
#         - e2e-az2

Thanks!

Please archive this repository

Please archive this unmaintained repository and remove it from the openshift marketplace so people don't install it accidentally or mistake it for the aquasecurity/trivy-operator.

Handler 'create_fn' failed with an exception.

Describe the bug
Hello,
I deployed trivy-operator on a Kubernetes cluster. After running scans it shows the following error.

[2022-07-19 07:41:52,874] kopf.objects         [ERROR   ] [trivy-operator/trivy-operator-main-config] Handler 'create_fn' failed with an exception. Will retry.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py", line 279, in execute_handler_once
    result = await invoke_handler(
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py", line 374, in invoke_handler
    result = await invocation.invoke(
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/invocation.py", line 116, in invoke
    result = await fn(**kwargs)  # type: ignore
  File "/trivy-operator.py", line 518, in create_fn
    "links": item["References"],
KeyError: 'References'

Configuration file

apiVersion: v1
items:
- apiVersion: trivy-operator.devopstales.io/v1
  kind: NamespaceScanner
  metadata:
    annotations:
      helm.sh/hook: post-install,post-upgrade
      kopf.zalando.org/create_fn: '{"started":"2022-07-19T07:34:05.809742","delayed":"2022-07-19T07:42:52.875942","purpose":"create","retries":1,"success":false,"failure":false,"message":"''References''"}'
      kopf.zalando.org/touch-dummy: 2022-07-19T07:42:52.903900
    creationTimestamp: "2022-07-19T07:34:03Z"
    generation: 3
    name: trivy-operator-main-config
    namespace: trivy-operator
    resourceVersion: "63425144"
    uid: 2f7ec00c-03f3-4760-a3dc-0af3618d7920
  spec:
    clusterWide: false
    crontab: '*/5 * * * *'
    namespace_selector: trivy-scan
    registry:
    - name: ****
      password: ****
      user: ****
  status:
    kopf:
      dummy: 2022-07-19T07:42:52.903900
      progress:
        create_fn:
          delayed: 2022-07-19T07:42:52.875942
          failure: false
          message: '''References'''
          purpose: create
          retries: 1
          started: 2022-07-19T07:34:05.809742
          success: false
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

Helm Values file

image:
  repository: devopstales/trivy-operator
  pullPolicy: Always
  tag: "2.4"

# Log level
log_level: "DEBUG"
# INFO, HIGH, DEBUG

imagePullSecrets: []
podSecurityContext:
  fsGroup: 0

serviceAccount:
  create: true
  annotations: {}
  name: "trivy-operator"

# enable tu deploy redis as cache
cache:
  enabled: false

monitoring:
  port: "9115"

# deploy service monitor
serviceMonitor:
  enabled: true
  labels:
    release: prometheus
  # Scrape interval. If not set, the Prometheus default scrape interval is used.
  #
  interval: 60s
  scrapeTimeout: 30s
  ## RelabelConfigs to apply to samples before scraping
  ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#relabelconfig
  ##
  relabelings:
  - action: replace
    regex: (.*)
    replacement: develop
    sourceLabels:
    - __address__
    targetLabel: account
  - action: replace
    regex: (.*)
    replacement: aws
    sourceLabels:
    - __address__
    targetLabel: provider
  - action: replace
    sourceLabels:
    - __metrics_path__
    targetLabel: metrics_path
  - sourceLabels: [job]
    regex: (.*)
    action: replace
    targetLabel: namespace
    replacement: "monitoring"
  metricRelabelings:
  - action: replace
    regex: (.*)
    sourceLabels:
    - severity
    targetLabel: severity_vulnerability
  - action: labeldrop
    regex: severity

persistence:
  enabled: true
  accessMode: "ReadWriteOnce"
  size: "1Gi"
  annotations: {}
  ## database data Persistent Volume Storage Class
  ## If defined, storageClassName: <storageClass>
  ## If set to "-", storageClassName: "", which disables dynamic provisioning
  ## If undefined (the default) or set to null, no storageClassName spec is
  ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
  ##   GKE, AWS & OpenStack)
  ##
  storageClass: "gp3-ephemeral"

# content foc ns-scan CRD
namespaceScanner:
  crontab: "*/5 * * * *"
  namespaceSelector: "trivy-scan"
  clusterWide: false
  policyreport: false

# enable adission controller
admissionController:
  enabled: false

# authentication informatin for trivy to use wen scan image
registryAuth:
  enabled: true
  registry:
  - name: ****
    user: ****
    password: ****

# github authentiation token for trivy database download
githubToken:
  enabled: false
  token: ""

## Define which Nodes the Pods are scheduled on.
## ref: https://kubernetes.io/docs/user-guide/node-selection/
##
nodeSelector:
  project: work

## Tolerations for use with node taints
## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
##
tolerations:
  - effect: NoSchedule
    key: project
    operator: Equal
    value: work
## Assign custom affinity rules to the trivy operator
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
##
affinity: {}
# nodeAffinity:
#   requiredDuringSchedulingIgnoredDuringExecution:
#     nodeSelectorTerms:
#     - matchExpressions:
#       - key: kubernetes.io/e2e-az-name
#         operator: In
#         values:
#         - e2e-az1
#         - e2e-az2

Environment:

  • Trivy-Operator version (use trivy-operator version): 2.4
  • Installation type (Helm, Kubernetes, OperatorFramework): Helm
  • Kubernetes version (use kubectl version): v1.21.10

Thanks!

Trivy operator reached the pull rate limit of docker.io

Describe the bug

[2022-09-30 07:20:30,444] kopf.objects         [ERROR   ] [trivy-system/trivy-system-trivy-system-helm-trivy-operator-main-config] TRIVY ERROR: return 1
[2022-09-30 07:20:30,444] kopf.objects         [ERROR   ] [trivy-system/trivy-system-trivy-system-helm-trivy-operator-main-config] You have reached your pull rate limit.

It's quite easy the reach the rate limit of docker.io, will trivy-operator use the image from the machine other than pull the image from the docker registry?

Expected behavior

Configuration file

Helm Values file
Default helm values.

Environment:

  • Trivy-Operator version (use trivy-operator version): trivy image: 2.4.1
  • Installation type (Helm, Kubernetes, OperatorFramework): Helm: 2.4.3
  • Kubernetes version (use kubectl version): v1.21.10
  • OS (macOS 10.15, Windows 10, Ubuntu 19.10 etc):

Additional context

mkdocs_material-8.5.6-py3-none-any.whl: 11 vulnerabilities (highest severity is: 9.8)

Vulnerable Library - mkdocs_material-8.5.6-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Vulnerabilities

CVE Severity CVSS Dependency Type Fixed in (mkdocs_material version) Remediation Possible**
CVE-2023-37920 Critical 9.8 certifi-2022.9.24-py3-none-any.whl Transitive 8.5.7
CVE-2023-43804 High 8.1 urllib3-1.26.12-py2.py3-none-any.whl Transitive 8.5.7
CVE-2024-39689 High 7.5 certifi-2022.9.24-py3-none-any.whl Transitive N/A*
CVE-2024-3651 High 7.5 idna-3.4-py3-none-any.whl Transitive N/A*
CVE-2023-32309 High 7.5 pymdown_extensions-9.6-py3-none-any.whl Transitive 8.5.7
CVE-2022-23491 High 7.5 certifi-2022.9.24-py3-none-any.whl Transitive 8.5.7
CVE-2023-32681 Medium 6.1 requests-2.28.1-py3-none-any.whl Transitive 8.5.7
CVE-2024-35195 Medium 5.6 requests-2.28.1-py3-none-any.whl Transitive 8.5.7
CVE-2022-40896 Medium 5.5 Pygments-2.13.0-py3-none-any.whl Transitive 8.5.7
CVE-2024-37891 Medium 4.4 urllib3-1.26.12-py2.py3-none-any.whl Transitive 8.5.7
CVE-2023-45803 Medium 4.2 urllib3-1.26.12-py2.py3-none-any.whl Transitive 8.5.7

*For some transitive vulnerabilities, there is no version of direct dependency with a fix. Check the "Details" section below to see if there is a version of transitive dependency where vulnerability is fixed.

**In some cases, Remediation PR cannot be created automatically for a vulnerability despite the availability of remediation

Details

CVE-2023-37920

Vulnerable Library - certifi-2022.9.24-py3-none-any.whl

Python package for providing Mozilla's CA Bundle.

Library home page: https://files.pythonhosted.org/packages/1d/38/fa96a426e0c0e68aabc68e896584b83ad1eec779265a028e156ce509630e/certifi-2022.9.24-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • requests-2.28.1-py3-none-any.whl
      • certifi-2022.9.24-py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

Certifi is a curated collection of Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts. Certifi prior to version 2023.07.22 recognizes "e-Tugra" root certificates. e-Tugra's root certificates were subject to an investigation prompted by reporting of security issues in their systems. Certifi 2023.07.22 removes root certificates from "e-Tugra" from the root store.

Publish Date: 2023-07-25

URL: CVE-2023-37920

CVSS 3 Score Details (9.8)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: High
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-xqr8-7jwr-rhp7

Release Date: 2023-07-25

Fix Resolution (certifi): 2023.7.22

Direct dependency fix Resolution (mkdocs-material): 8.5.7

Step up your Open Source Security Game with Mend here

CVE-2023-43804

Vulnerable Library - urllib3-1.26.12-py2.py3-none-any.whl

HTTP library with thread-safe connection pooling, file post, and more.

Library home page: https://files.pythonhosted.org/packages/6f/de/5be2e3eed8426f871b170663333a0f627fc2924cc386cd41be065e7ea870/urllib3-1.26.12-py2.py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • requests-2.28.1-py3-none-any.whl
      • urllib3-1.26.12-py2.py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

urllib3 is a user-friendly HTTP client library for Python. urllib3 doesn't treat the Cookie HTTP header special or provide any helpers for managing cookies over HTTP, that is the responsibility of the user. However, it is possible for a user to specify a Cookie header and unknowingly leak information via HTTP redirects to a different origin if that user doesn't disable redirects explicitly. This issue has been patched in urllib3 version 1.26.17 or 2.0.5.

Publish Date: 2023-10-04

URL: CVE-2023-43804

CVSS 3 Score Details (8.1)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: Low
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: High
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://www.cve.org/CVERecord?id=CVE-2023-43804

Release Date: 2023-10-04

Fix Resolution (urllib3): 1.26.17

Direct dependency fix Resolution (mkdocs-material): 8.5.7

Step up your Open Source Security Game with Mend here

CVE-2024-39689

Vulnerable Library - certifi-2022.9.24-py3-none-any.whl

Python package for providing Mozilla's CA Bundle.

Library home page: https://files.pythonhosted.org/packages/1d/38/fa96a426e0c0e68aabc68e896584b83ad1eec779265a028e156ce509630e/certifi-2022.9.24-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • requests-2.28.1-py3-none-any.whl
      • certifi-2022.9.24-py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

Certifi is a curated collection of Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts. Certifi starting in 2021.05.30 and prior to 2024.07.4 recognized root certificates from GLOBALTRUST. Certifi 2024.07.04 removes root certificates from GLOBALTRUST from the root store. These are in the process of being removed from Mozilla's trust store. GLOBALTRUST's root certificates are being removed pursuant to an investigation which identified "long-running and unresolved compliance issues."

Publish Date: 2024-07-05

URL: CVE-2024-39689

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: High
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-248v-346w-9cwc

Release Date: 2024-07-05

Fix Resolution: certifi - 2024.07.04

Step up your Open Source Security Game with Mend here

CVE-2024-3651

Vulnerable Library - idna-3.4-py3-none-any.whl

Internationalized Domain Names in Applications (IDNA)

Library home page: https://files.pythonhosted.org/packages/fc/34/3030de6f1370931b9dbb4dad48f6ab1015ab1d32447850b9fc94e60097be/idna-3.4-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • requests-2.28.1-py3-none-any.whl
      • idna-3.4-py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

A vulnerability was identified in the kjd/idna library, specifically within the idna.encode() function, affecting version 3.6. The issue arises from the function's handling of crafted input strings, which can lead to quadratic complexity and consequently, a denial of service condition. This vulnerability is triggered by a crafted input that causes the idna.encode() function to process the input with considerable computational load, significantly increasing the processing time in a quadratic manner relative to the input size.

Publish Date: 2024-07-07

URL: CVE-2024-3651

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://www.cve.org/CVERecord?id=CVE-2024-3651

Release Date: 2024-07-07

Fix Resolution: idna - 3.7

Step up your Open Source Security Game with Mend here

CVE-2023-32309

Vulnerable Library - pymdown_extensions-9.6-py3-none-any.whl

Extension pack for Python Markdown.

Library home page: https://files.pythonhosted.org/packages/06/f4/32ac74ee8790e65820ee140b344b2361faf4158b937abac77f1902ebcac4/pymdown_extensions-9.6-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • pymdown_extensions-9.6-py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

PyMdown Extensions is a set of extensions for the Python-Markdown markdown project. In affected versions an arbitrary file read is possible when using include file syntax. By using the syntax --8<--"/etc/passwd" or --8<--"/proc/self/environ" the content of these files will be rendered in the generated documentation. Additionally, a path relative to a specified, allowed base path can also be used to render the content of a file outside the specified base paths: --8<-- "../../../../etc/passwd". Within the Snippets extension, there exists a base_path option but the implementation is vulnerable to Directory Traversal. The vulnerable section exists in get_snippet_path(self, path) lines 155 to 174 in snippets.py. Any readable file on the host where the plugin is executing may have its content exposed. This can impact any use of Snippets that exposes the use of Snippets to external users. It is never recommended to use Snippets to process user-facing, dynamic content. It is designed to process known content on the backend under the control of the host, but if someone were to accidentally enable it for user-facing content, undesired information could be exposed. This issue has been addressed in version 10.0. Users are advised to upgrade. Users unable to upgrade may restrict relative paths by filtering input.

Publish Date: 2023-05-15

URL: CVE-2023-32309

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: None
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://www.cve.org/CVERecord?id=CVE-2023-32309

Release Date: 2023-05-15

Fix Resolution (pymdown-extensions): 10.2

Direct dependency fix Resolution (mkdocs-material): 8.5.7

Step up your Open Source Security Game with Mend here

CVE-2022-23491

Vulnerable Library - certifi-2022.9.24-py3-none-any.whl

Python package for providing Mozilla's CA Bundle.

Library home page: https://files.pythonhosted.org/packages/1d/38/fa96a426e0c0e68aabc68e896584b83ad1eec779265a028e156ce509630e/certifi-2022.9.24-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • requests-2.28.1-py3-none-any.whl
      • certifi-2022.9.24-py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

Certifi is a curated collection of Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts. Certifi 2022.12.07 removes root certificates from "TrustCor" from the root store. These are in the process of being removed from Mozilla's trust store. TrustCor's root certificates are being removed pursuant to an investigation prompted by media reporting that TrustCor's ownership also operated a business that produced spyware. Conclusions of Mozilla's investigation can be found in the linked google group discussion.

Publish Date: 2022-12-07

URL: CVE-2022-23491

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: High
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://www.cve.org/CVERecord?id=CVE-2022-23491

Release Date: 2022-12-07

Fix Resolution (certifi): 2022.12.7

Direct dependency fix Resolution (mkdocs-material): 8.5.7

Step up your Open Source Security Game with Mend here

CVE-2023-32681

Vulnerable Library - requests-2.28.1-py3-none-any.whl

Python HTTP for Humans.

Library home page: https://files.pythonhosted.org/packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • requests-2.28.1-py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

Requests is a HTTP library. Since Requests 2.3.0, Requests has been leaking Proxy-Authorization headers to destination servers when redirected to an HTTPS endpoint. This is a product of how we use rebuild_proxies to reattach the Proxy-Authorization header to requests. For HTTP connections sent through the tunnel, the proxy will identify the header in the request itself and remove it prior to forwarding to the destination server. However when sent over HTTPS, the Proxy-Authorization header must be sent in the CONNECT request as the proxy has no visibility into the tunneled request. This results in Requests forwarding proxy credentials to the destination server unintentionally, allowing a malicious actor to potentially exfiltrate sensitive information. This issue has been patched in version 2.31.0.

Publish Date: 2023-05-26

URL: CVE-2023-32681

CVSS 3 Score Details (6.1)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: High
    • Privileges Required: None
    • User Interaction: Required
    • Scope: Changed
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: None
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-j8r2-6x86-q33q

Release Date: 2023-05-26

Fix Resolution (requests): 2.32.0

Direct dependency fix Resolution (mkdocs-material): 8.5.7

Step up your Open Source Security Game with Mend here

CVE-2024-35195

Vulnerable Library - requests-2.28.1-py3-none-any.whl

Python HTTP for Humans.

Library home page: https://files.pythonhosted.org/packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • requests-2.28.1-py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

Requests is a HTTP library. Prior to 2.32.2, when making requests through a Requests Session, if the first request is made with verify=False to disable cert verification, all subsequent requests to the same host will continue to ignore cert verification regardless of changes to the value of verify. This behavior will continue for the lifecycle of the connection in the connection pool. This vulnerability is fixed in 2.32.2.

Publish Date: 2024-05-20

URL: CVE-2024-35195

CVSS 3 Score Details (5.6)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Local
    • Attack Complexity: High
    • Privileges Required: High
    • User Interaction: Required
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: High
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-9wx4-h78v-vm56

Release Date: 2024-05-20

Fix Resolution (requests): 2.32.0

Direct dependency fix Resolution (mkdocs-material): 8.5.7

Step up your Open Source Security Game with Mend here

CVE-2022-40896

Vulnerable Library - Pygments-2.13.0-py3-none-any.whl

Pygments is a syntax highlighting package written in Python.

Library home page: https://files.pythonhosted.org/packages/4f/82/672cd382e5b39ab1cd422a672382f08a1fb3d08d9e0c0f3707f33a52063b/Pygments-2.13.0-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • Pygments-2.13.0-py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

A ReDoS issue was discovered in pygments/lexers/smithy.py in pygments through 2.15.0 via SmithyLexer.

Publish Date: 2023-07-19

URL: CVE-2022-40896

CVSS 3 Score Details (5.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Local
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: Required
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://pyup.io/vulnerabilities/CVE-2022-40896/58910/

Release Date: 2023-07-19

Fix Resolution (Pygments): 2.15.0

Direct dependency fix Resolution (mkdocs-material): 8.5.7

Step up your Open Source Security Game with Mend here

CVE-2024-37891

Vulnerable Library - urllib3-1.26.12-py2.py3-none-any.whl

HTTP library with thread-safe connection pooling, file post, and more.

Library home page: https://files.pythonhosted.org/packages/6f/de/5be2e3eed8426f871b170663333a0f627fc2924cc386cd41be065e7ea870/urllib3-1.26.12-py2.py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • requests-2.28.1-py3-none-any.whl
      • urllib3-1.26.12-py2.py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

urllib3 is a user-friendly HTTP client library for Python. When using urllib3's proxy support with ProxyManager, the Proxy-Authorization header is only sent to the configured proxy, as expected. However, when sending HTTP requests without using urllib3's proxy support, it's possible to accidentally configure the Proxy-Authorization header even though it won't have any effect as the request is not using a forwarding proxy or a tunneling proxy. In those cases, urllib3 doesn't treat the Proxy-Authorization HTTP header as one carrying authentication material and thus doesn't strip the header on cross-origin redirects. Because this is a highly unlikely scenario, we believe the severity of this vulnerability is low for almost all users. Out of an abundance of caution urllib3 will automatically strip the Proxy-Authorization header during cross-origin redirects to avoid the small chance that users are doing this on accident. Users should use urllib3's proxy support or disable automatic redirects to achieve safe processing of the Proxy-Authorization header, but we still decided to strip the header by default in order to further protect users who aren't using the correct approach. We believe the number of usages affected by this advisory is low. It requires all of the following to be true to be exploited: 1. Setting the Proxy-Authorization header without using urllib3's built-in proxy support. 2. Not disabling HTTP redirects. 3. Either not using an HTTPS origin server or for the proxy or target origin to redirect to a malicious origin. Users are advised to update to either version 1.26.19 or version 2.2.2. Users unable to upgrade may use the Proxy-Authorization header with urllib3's ProxyManager, disable HTTP redirects using redirects=False when sending requests, or not user the Proxy-Authorization header as mitigations.

Publish Date: 2024-06-17

URL: CVE-2024-37891

CVSS 3 Score Details (4.4)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: High
    • Privileges Required: High
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: None
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-34jh-p97f-mpxf

Release Date: 2024-06-17

Fix Resolution (urllib3): 2.2.2

Direct dependency fix Resolution (mkdocs-material): 8.5.7

Step up your Open Source Security Game with Mend here

CVE-2023-45803

Vulnerable Library - urllib3-1.26.12-py2.py3-none-any.whl

HTTP library with thread-safe connection pooling, file post, and more.

Library home page: https://files.pythonhosted.org/packages/6f/de/5be2e3eed8426f871b170663333a0f627fc2924cc386cd41be065e7ea870/urllib3-1.26.12-py2.py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_material-8.5.6-py3-none-any.whl (Root Library)
    • requests-2.28.1-py3-none-any.whl
      • urllib3-1.26.12-py2.py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

urllib3 is a user-friendly HTTP client library for Python. urllib3 previously wouldn't remove the HTTP request body when an HTTP redirect response using status 301, 302, or 303 after the request had its method changed from one that could accept a request body (like POST) to GET as is required by HTTP RFCs. Although this behavior is not specified in the section for redirects, it can be inferred by piecing together information from different sections and we have observed the behavior in other major HTTP client implementations like curl and web browsers. Because the vulnerability requires a previously trusted service to become compromised in order to have an impact on confidentiality we believe the exploitability of this vulnerability is low. Additionally, many users aren't putting sensitive data in HTTP request bodies, if this is the case then this vulnerability isn't exploitable. Both of the following conditions must be true to be affected by this vulnerability: 1. Using urllib3 and submitting sensitive information in the HTTP request body (such as form data or JSON) and 2. The origin service is compromised and starts redirecting using 301, 302, or 303 to a malicious peer or the redirected-to service becomes compromised. This issue has been addressed in versions 1.26.18 and 2.0.7 and users are advised to update to resolve this issue. Users unable to update should disable redirects for services that aren't expecting to respond with redirects with redirects=False and disable automatic redirects with redirects=False and handle 301, 302, and 303 redirects manually by stripping the HTTP request body.

Publish Date: 2023-10-17

URL: CVE-2023-45803

CVSS 3 Score Details (4.2)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Adjacent
    • Attack Complexity: High
    • Privileges Required: High
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: None
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-g4mx-q9vg-27p4

Release Date: 2023-10-17

Fix Resolution (urllib3): 1.26.18

Direct dependency fix Resolution (mkdocs-material): 8.5.7

Step up your Open Source Security Game with Mend here

Support for using cluster pullsecrets

Hi,

First of all, thanks for trivy-operator :)

Would it be possible to use existing pullsecrets configured for this cluster to do image scanning?

mkdocs_macros_plugin-0.7.0-py3-none-any.whl: 2 vulnerabilities (highest severity is: 5.4)

Vulnerable Library - mkdocs_macros_plugin-0.7.0-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Vulnerabilities

CVE Severity CVSS Dependency Type Fixed in (mkdocs_macros_plugin version) Remediation Possible**
CVE-2024-34064 Medium 5.4 Jinja2-3.1.2-py3-none-any.whl Transitive N/A*
CVE-2024-22195 Medium 5.4 Jinja2-3.1.2-py3-none-any.whl Transitive N/A*

*For some transitive vulnerabilities, there is no version of direct dependency with a fix. Check the "Details" section below to see if there is a version of transitive dependency where vulnerability is fixed.

**In some cases, Remediation PR cannot be created automatically for a vulnerability despite the availability of remediation

Details

CVE-2024-34064

Vulnerable Library - Jinja2-3.1.2-py3-none-any.whl

A very fast and expressive template engine.

Library home page: https://files.pythonhosted.org/packages/bc/c3/f068337a370801f372f2f8f6bad74a5c140f6fda3d9de154052708dd3c65/Jinja2-3.1.2-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_macros_plugin-0.7.0-py3-none-any.whl (Root Library)
    • Jinja2-3.1.2-py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

Jinja is an extensible templating engine. The xmlattr filter in affected versions of Jinja accepts keys containing non-attribute characters. XML/HTML attributes cannot contain spaces, /, >, or =, as each would then be interpreted as starting a separate attribute. If an application accepts keys (as opposed to only values) as user input, and renders these in pages that other users see as well, an attacker could use this to inject other attributes and perform XSS. The fix for CVE-2024-22195 only addressed spaces but not other characters. Accepting keys as user input is now explicitly considered an unintended use case of the xmlattr filter, and code that does so without otherwise validating the input should be flagged as insecure, regardless of Jinja version. Accepting values as user input continues to be safe. This vulnerability is fixed in 3.1.4.

Publish Date: 2024-05-06

URL: CVE-2024-34064

CVSS 3 Score Details (5.4)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: Required
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: Low
    • Integrity Impact: Low
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-h75v-3vvj-5mfj

Release Date: 2024-05-06

Fix Resolution: Jinja2 - 3.1.4

Step up your Open Source Security Game with Mend here

CVE-2024-22195

Vulnerable Library - Jinja2-3.1.2-py3-none-any.whl

A very fast and expressive template engine.

Library home page: https://files.pythonhosted.org/packages/bc/c3/f068337a370801f372f2f8f6bad74a5c140f6fda3d9de154052708dd3c65/Jinja2-3.1.2-py3-none-any.whl

Path to dependency file: /docs/build/requirements.txt

Path to vulnerable library: /docs/build/requirements.txt

Dependency Hierarchy:

  • mkdocs_macros_plugin-0.7.0-py3-none-any.whl (Root Library)
    • Jinja2-3.1.2-py3-none-any.whl (Vulnerable Library)

Found in base branch: main

Vulnerability Details

Jinja is an extensible templating engine. Special placeholders in the template allow writing code similar to Python syntax. It is possible to inject arbitrary HTML attributes into the rendered HTML template, potentially leading to Cross-Site Scripting (XSS). The Jinja xmlattr filter can be abused to inject arbitrary HTML attribute keys and values, bypassing the auto escaping mechanism and potentially leading to XSS. It may also be possible to bypass attribute validation checks if they are blacklist-based.

Publish Date: 2024-01-11

URL: CVE-2024-22195

CVSS 3 Score Details (5.4)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: Required
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: Low
    • Integrity Impact: Low
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-h5c8-rqwp-cp95

Release Date: 2024-01-11

Fix Resolution: jinja2 - 3.1.3

Step up your Open Source Security Game with Mend here

Publicate on OperatorHub

Namespace selector is ignored

Steps to reproduce:

  • kubectl label ns default trivy-scan=true
  • install devopstales/trivy-operator-2.3.0 chart in default ns with following values.yaml:
env:
  vars:
    - name: LOG_LEVEL
      value: "DEBUG"
namespaceScanner:
  crontab: "*/5 * * * *"
  namespaceSelector: "trivy-scan"
  clusterWide: false

Actual results:

  • kubectl logs deploy/trivy-operator gets:
[2022-02-07 05:59:00,399] kopf.activities.star [INFO    ] CRD already exists!!!
[2022-02-07 05:59:00,399] kopf.activities.star [INFO    ] Activity 'startup_fn_crd' succeeded.
[2022-02-07 05:59:10,719] kopf.activities.star [INFO    ] trivy cache created...
[2022-02-07 05:59:10,719] kopf.activities.star [INFO    ] Activity 'startup_fn_trivy_cache' succeeded.
[2022-02-07 05:59:10,720] kopf.activities.star [INFO    ] Prometheus Exporter started...
[2022-02-07 05:59:10,720] kopf.activities.star [INFO    ] Activity 'startup_fn_prometheus_client' succeeded.
[2022-02-07 05:59:10,720] kopf.activities.star [INFO    ] Loading cluster config
[2022-02-07 05:59:10,722] kopf.activities.star [INFO    ] Generating a self-signed certificate for HTTPS.
[2022-02-07 05:59:11,200] kopf.activities.star [INFO    ] validating webhook configuration already exists!!!
[2022-02-07 05:59:11,201] kopf.activities.star [INFO    ] Activity 'configure' succeeded.
[2022-02-07 05:59:11,202] kopf._core.engines.a [INFO    ] Initial authentication has been initiated.
[2022-02-07 05:59:11,203] kopf.activities.auth [INFO    ] Activity 'login_via_client' succeeded.
[2022-02-07 05:59:11,204] kopf._core.engines.a [INFO    ] Initial authentication has finished.
[2022-02-07 05:59:11,361] kopf._core.reactor.o [WARNING ] Not enough permissions to watch for resources: changes (creation/deletion/updates) will not be noticed; the resources are only refreshed on operator restarts.
[2022-02-07 05:59:11,467] kopf.objects         [INFO    ] [default/trivy-operator-main-config] NamespaceScanner Created
[2022-02-07 06:00:11,783] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Scanning Image: devopstales/trivy-operator:2.3
[2022-02-07 06:00:11,783] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Active Registry: None
[2022-02-07 06:00:29,509] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Scanning Image: k8s.gcr.io/ingress-nginx/kube-webhook-certgen@sha256:64d8c73dca984af206adf9d6d7e46aa550362b1d7a01f3a0a91b20cc67868660
[2022-02-07 06:00:29,509] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Active Registry: None
[2022-02-07 06:00:34,583] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Scanning Image: sha256:ae1a7201ec9545194b2889da30face5f2a7a45e2ba8c7479ac68c9a45a73a7eb
[2022-02-07 06:00:34,583] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Active Registry: None
[2022-02-07 06:00:37,760] kopf.objects         [ERROR   ] [default/trivy-operator-main-config] TRIVY ERROR: return 1
[2022-02-07 06:00:37,760] kopf.objects         [ERROR   ] [default/trivy-operator-main-config] Repository: Unauthorized authentication required
[2022-02-07 06:00:37,760] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Scanning Image: k8s.gcr.io/coredns/coredns:v1.8.6
[2022-02-07 06:00:37,760] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Active Registry: None
[2022-02-07 06:00:41,703] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Scanning Image: k8s.gcr.io/etcd:3.5.1-0
[2022-02-07 06:00:41,705] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Active Registry: None
[2022-02-07 06:00:55,711] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Scanning Image: k8s.gcr.io/kube-apiserver:v1.23.1
[2022-02-07 06:00:55,711] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Active Registry: None
[2022-02-07 06:01:01,734] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Scanning Image: k8s.gcr.io/kube-controller-manager:v1.23.1
[2022-02-07 06:01:01,735] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Active Registry: None
^[[2022-02-07 06:01:07,618] kopf.objects         [INFO    ] [default/trivy-operator-main-config] Scanning Image: k8s.gcr.io/kube-proxy:v1.23.1

Expected results:

  • Scanning only trivy-operator's pod (single pod in ns default), not all pods in kube-system/ingress-nginx/...
  • Expected kopf debug logs

Handler 'create_fn' failed with an exception when namespace ha no tag.

[2021-12-17 17:39:25,844] kopf.objects         [ERROR   ] [trivy-operator/trivy-operator-main-config] Handler 'create_fn' failed with an exception. Will retry.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py", line 283, in execute_handler_once
    result = await invoke_handler(
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py", line 378, in invoke_handler
    result = await invocation.invoke(
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/invocation.py", line 117, in invoke
    result = await fn(**kwargs)  # type: ignore
  File "/trivy-operator.py", line 192, in create_fn
    ns_label_list = ns.metadata.labels.items()
AttributeError: 'NoneType' object has no attribute 'items'

set timeout value to more than 5 min

Hey 👋

We're using your Trivy-operator alongside DefectDojo to scan our cluster. Particularly, we're using the namespaceScanner.
Both are installed via Helm and we're using the latest version.
It was working fine when I added the trivy-scan: "true" label to a couple of namespaces, but when I added it to multiple namespaces it seems that the scan will need more than 5 min (which is the default value) to finish and therefore it fails after some time. with the error:

kopf._cogs.clients.w [ERROR ] Request attempt #1/9 failed; will retry: GET https://*.*.*.*:443/apis/trivy-operator.devopstales.io/v1/namespace-scanners?watch=true&resourceVersion=2006420349 -> ServerDisconnectedError('Server disconnected')

Is there a way to override the default value of the timeout as in the duration to wait for scan completion?

Also, I see this error in the logs occasionally
[ERROR ] [security-scanning/trivy-operator-main-config] Handler 'create_fn' failed with an exception. Will retry. Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py", line 279, in execute_handler_once result = await invoke_handler( File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py", line 374, in invoke_handler result = await invocation.invoke( File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/invocation.py", line 116, in invoke result = await fn(**kwargs) # type: ignore File "/trivy-operator.py", line 416, in create_fn pull_secret_decoder(tmp3, tagged_ns) File "/trivy-operator.py", line 238, in pull_secret_decoder secret_data = secret.data['.dockerconfigjson'] KeyError: '.dockerconfigjson'

thanks 🙏

Is there a plan to provide option to specify the secret type?

I would like to use trivy operator for Openshift platform.
Openshift creates secret with format of kubernetes.io/dockercfg ,not kubernetes.io/dockerconfigjson, so following code cause error.
https://github.com/devopstales/trivy-operator/blob/main/trivy-operator.py#L239

[2023-01-30 14:22:48,527] kopf.objects         [ERROR   ] [my-namespace/trivy-operator-main-config] Handler 'create_fn' failed with an exception. Will retry.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py", line 279, in execute_handler_once
    result = await invoke_handler(
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py", line 374, in invoke_handler
    result = await invocation.invoke(
  File "/usr/local/lib/python3.8/site-packages/kopf/_core/actions/invocation.py", line 116, in invoke
    result = await fn(**kwargs)  # type: ignore
  File "/trivy-operator.py", line 417, in create_fn
    pull_secret_decoder(tmp3, tagged_ns)
  File "/trivy-operator.py", line 239, in pull_secret_decoder
    secret_data = secret.data['.dockerconfigjson']
KeyError: '.dockerconfigjson'

Is it possible to provide an option to specify either kubernetes.io/dockercfg or kubernetes.io/dockerconfigjson?

Add Advanced Grafana Dashboard and Change Prometheus Endpoint

# HELP trivy_vulnerabilities Vulnerabilities detected by trivy
# TYPE trivy_vulnerabilities gauge
trivy_vulnerabilities{image="gcr.io/spinnaker-marketplace/echo:2.5.1-20190612034009",installedVersion="0.168-1",pkgName="libelf1",severity="HIGH",vulnerabilityId="CVE-2018-16402"} 1
trivy_vulnerabilities{image="k8s.gcr.io/node-problem-detector:v0.7.1",installedVersion="0.168-1",pkgName="libelf1",severity="HIGH",vulnerabilityId="CVE-2018-16402"} 1
trivy_vulnerabilities{image="gcr.io/spinnaker-marketplace/echo:2.5.1-20190612034009",installedVersion="0.168-1",pkgName="libelf1",severity="MEDIUM",vulnerabilityId="CVE-2018-16062"} 1
trivy_vulnerabilities{image="gcr.io/spinnaker-marketplace/echo:2.5.1-20190612034009",installedVersion="0.168-1",pkgName="libelf1",severity="MEDIUM",vulnerabilityId="CVE-2018-16403"} 1
trivy_vulnerabilities{image="gcr.io/spinnaker-marketplace/echo:2.5.1-20190612034009",installedVersion="0.168-1",pkgName="libelf1",severity="MEDIUM",vulnerabilityId="CVE-2018-18310"} 1
trivy_vulnerabilities{image="gcr.io/spinnaker-marketplace/echo:2.5.1-20190612034009",installedVersion="0.168-1",pkgName="libelf1",severity="MEDIUM",vulnerabilityId="CVE-2018-18520"} 1
trivy_vulnerabilities{image="gcr.io/spinnaker-marketplace/echo:2.5.1-20190612034009",installedVersion="0.168-1",pkgName="libelf1",severity="MEDIUM",vulnerabilityId="CVE-2018-18521"} 1

https://grafana.com/grafana/dashboards/12331
https://grafana.com/grafana/dashboards/12330

so_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="UNKNOWN"} 0
so_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="LOW"} 23
so_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="MEDIUM"} 93
so_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="HIGH"} 76
so_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="CRITICAL"} 25
so_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:latest",severity="UNKNOWN"} 0
so_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:latest",severity="LOW"} 23
so_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:latest",severity="MEDIUM"} 88
so_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:latest",severity="HIGH"} 60
so_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:latest",severity="CRITICAL"} 8

ac_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="UNKNOWN"} 0
ac_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="LOW"} 23
ac_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="MEDIUM"} 93
ac_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="HIGH"} 76
ac_vulnerabilities{exported_namespace="trivytest",image="docker.io/library/nginx:1.18",severity="CRITICAL"} 25

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.