← 输入框|github.com|刷新
Skip to content

Passing parameters to ScheduledScan #2315

Open

Description

@danil-smirnov

➹ New Feature implementation request

Is your feature request related to a problem?

When we invoke a scan, e.g. Trivy image scan, we pass an image:tag to the scanner as a parameter:
https://www.securecodebox.io/docs/scanners/trivy/#image-juice-shop

We can define an image and a tag when we create a Scan CRD.

However, if we want to scan periodically using the ScheduledScan, we have to hardcode an image:tag in the ScanSpec field, which forces the scan to run against the same image all the time.

Describe the solution you'd like

It would be great if we could set a custom logic, that calculates an image:tag at the time of scanning and passes the result to the scanner via a parameter.

We can define such logic via the InitContainers parameter, but the only way to pass the result to the scunner is via a mounted volume, which doesn't help e.g. in the case of the Trivy image scan.

It would be great if we could consume InitContainers run results as part of the parameters passed to the scanner.

Describe alternatives you've considered

Additional context

Activity

  1. J12934 commented on Feb 26, 2024

    @J12934
    Member

    Cool idea but not sure if we can or if we should support it.

    couples of thoughts:

    1. Using initContainers to generate the parameters would be hard to impossible. The scans parameters are passed to the scan as args to the scanner container. I'm pretty sure this field is immutable on a pod or at least changing it after the pod is scheduled to a node doesn't have an effect.
      I think what is possible is to change the value in a configmap / secret the pod is mounting e.g. to inject a environments variable. The scan container could then use the value in the environment variable to generate the parameters but this wouldn't work when the scan container doesn't have a shell init. e.g. because it's build using a distroless image
    2. Determining the parameters at runtime would make it really hard to debug why a scan is failing. especially if the value would also only be around at runtime.

    for now if you need to change the parameters of a scheduledScan I'd suggest to do it simmilarly to the auto-discovery which changes the parameters of the scheduledscan and then triggers a premature execution of it by resetting the last executed at timestamp of the scheduledScan, which triggers a new execution right away. https://github.com/secureCodeBox/secureCodeBox/blob/main/operator/utils/retrigger_scheduled_scan.go#L17

    It's not the nicest thing but works really well.

    if somebody is willing to sketch out a design of a "dynamic parameter generator" for schedueld scans I'd be very interessted in looking at this :D (espeically if the the people would also be willing to implement and maintain it :) )

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions