Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trivy Executing Incorrect Plugin. #1086

Closed
shpml opened this issue Jun 24, 2021 · 2 comments · Fixed by #1207
Closed

Trivy Executing Incorrect Plugin. #1086

shpml opened this issue Jun 24, 2021 · 2 comments · Fixed by #1207
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@shpml
Copy link

shpml commented Jun 24, 2021

Description

Trivy is executing the wrong plugin. I have two plugins installed. My own and the kubectl example one. When I try to execute my own plugin it executes the kubectl plugin.

─ trivy bigquery -f long -- python:3.4-alpine
error: the path "long" does not exist

─ trivy bigquery -- python:3.4-alpine
You must specify the type of resource to get. Use "kubectl api-resources" for a complete list of supported resources.

error: Required resource not specified.
Use "kubectl explain <resource>" for a detailed description of that resource (e.g. kubectl explain pods).
See 'kubectl get -h' for help and examples

─ ls -al ~/.trivy/plugins
total 0
drwxr-xr-x  4 shpml  staff  128 25 Jun 09:32 .
drwxr-xr-x  3 shpml  staff   96 17 Jun 14:51 ..
drwxr-xr-x  4 shpml  staff  128 25 Jun 09:32 bigquery
drwxr-xr-x  4 shpml  staff  128 25 Jun 09:12 kubectl

Output of run with -debug:

trivy --debug bigquery -f long -- python:3.4-alpine
2021-06-25T09:43:20.852+1000	DEBUG	Platform found, os: darwin, arch: amd64
error: the path "long" does not exist

trivy --debug bigquery test -- python:3.4-alpine
2021-06-25T09:43:10.048+1000	DEBUG	Platform found, os: darwin, arch: amd64
error: the server doesn't have a resource type "test"

trivy --debug bigquery -h -- python:3.4-alpine
2021-06-25T09:47:41.930+1000	DEBUG	Platform found, os: darwin, arch: amd64
Usage: trivy kubectl [-h,--help] TYPE NAME [TRIVY OPTION]
 A Trivy plugin that scans the images of a kubernetes resource.

Options:
  -h, --help    Show usage.

Examples:
  # Scan a Pod
  kubectl trivy pod mypod

  # Scan a Deployment
  kubectl trivy deployment mydeployment -n mynamespace

  # Scan a Job and filter by severity
  kubectl trivy job myjob -n mynamespace -- --severity CRITICAL

Output of trivy -v:

trivy -v
Version: 0.18.3
Vulnerability DB:
  Type: Light
  Version: 1
  UpdatedAt: 2021-06-24 18:04:24.038637867 +0000 UTC
  NextUpdate: 2021-06-25 00:04:24.038637367 +0000 UTC
  DownloadedAt: 2021-06-24 22:44:25.106722 +0000 UTC

Work around

Uninstalling the kubectl plugin with trivy plugin uninstall kubectl will allow my trivy to run my own plugin.

─ trivy plugin uninstall kubectl

─ ls -al ~/.trivy/plugins
total 0
drwxr-xr-x  3 shpml  staff   96 25 Jun 09:48 .
drwxr-xr-x  3 shpml  staff   96 17 Jun 14:51 ..
drwxr-xr-x  7 shpml  staff  224 25 Jun 09:48 bigquery

─ trivy --debug bigquery -f long -- python:3.4-alpine
2021-06-25T09:48:39.442+1000	DEBUG	Platform found, os: darwin, arch: amd64
INFO: working_dir is /Users/shpml/.trivy/plugins/bigquery
INFO: SCRIPTPATH is /Users/shpml/.trivy/plugins/bigquery
INFO: ABSOLUTE_PATH is /Users/shpml/.trivy/plugins/bigquery/trivy-bigquery.sh
@shpml shpml added the kind/bug Categorizes issue or PR as related to a bug. label Jun 24, 2021
@github-actions
Copy link

This issue is stale because it has been labeled with inactivity.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and will be auto-closed. label Aug 24, 2021
@knqyf263 knqyf263 removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and will be auto-closed. label Sep 1, 2021
@knqyf263
Copy link
Collaborator

knqyf263 commented Sep 1, 2021

@afdesk Could you look into it?

afdesk added a commit to afdesk/trivy that referenced this issue Sep 2, 2021
There is a closure inside a function for Action field: variable p always refers on the last plugin.
solution: redefine variable inside the for loop.

Fixes aquasecurity#1086
knqyf263 pushed a commit that referenced this issue Sep 2, 2021
There is a closure inside a function for Action field: variable p always refers on the last plugin.
solution: redefine variable inside the for loop.

Fixes #1086
liamg pushed a commit that referenced this issue Jun 7, 2022
There is a closure inside a function for Action field: variable p always refers on the last plugin.
solution: redefine variable inside the for loop.

Fixes #1086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants