Skip to content

support to evaluate CEL expression with the right scanner #167

Description

@ashwiniag

Each scanner (e.g., Trivy, Snyk, Grype) produces reports in different JSON structures. A CEL expression written for one scanner might not work for another due to differences in field names.
Example

Trivy JSON Structure

	{
	  "ArtifactName": "nginx:latest",
	  "Results": [
	    {
	      "Target": "nginx:latest",
	      "Vulnerabilities": [
	        {
	          "VulnerabilityID": "CVE-2023-1234",
	          "Severity": "CRITICAL"
	        }
	      ]
	    }
	  ]
	}
	

CEL Expression (Valid for Trivy)

report.Results.exists(r, r.Vulnerabilities.exists(v, v.Severity == 'CRITICAL'))
	

Snyk JSON Structure

	{
	  "vulnerabilities": [
	    {
	      "id": "CVE-2023-1234",
	      "severity": "critical"
	    }
	  ]
	}
	

CEL Expression (Valid for Snyk)

report.vulnerabilities.exists(v, v.severity == 'critical')

If it tries to evaluate the Trivy CEL expression against a Snyk report, it will fail because Results and Vulnerabilities don’t exist in Snyk's JSON. So, before evaluating a CEL expression, check if it matches the structure expected for that scanner. And have it plugable/extendable support.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions