secureCodeBox icon indicating copy to clipboard operation
secureCodeBox copied to clipboard

Handle scheduled scan by days using suffix "d"

Open Spritekin opened this issue 2 years ago • 2 comments

➹ New Feature implementation request

In the ScheduledScan, allow handling days "d"

Is your feature request related to a problem?

I want to run my scans every week, so I setup my ScheduledScan using a period of "7d".

    spec:
      interval: 7d

However the SCB controller errors

W0426 05:55:46.739887       1 reflector.go:324] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: failed to list *v1.ScheduledScan: time: unknown unit "d" in duration "7d"
E0426 05:55:46.740024       1 reflector.go:138] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: Failed to watch *v1.ScheduledScan: failed to list *v1.ScheduledScan: time: unknown unit "d" in duration "7d"

This shouldn't be a problem to describe in as 168h, however if the idea is to handle "h" or "m" why not handle "d" for days as well?

Describe the solution you'd like

I should be able to set an interval using the suffix "d" representing days like 1d or 2d.

In addition the documentation should read the available suffixes as anyone might also try weeks (w) months (m) or years (y) and might not be available.

Describe alternatives you've considered

It is possible to translate days to hours, but is not intuitive.

Additional context

Spritekin avatar Apr 26 '22 08:04 Spritekin

Hi 👋 Thank you for the the feedback, yes we are also a bit fed up with this limitation, see the disclaimer on the API Spec Page of the ScheduledScan: https://docs.securecodebox.io/docs/api/crds/scheduled-scan#interval-required

Support for any time ranges larger then one hour is pretty tricky as they aren't always the same length. A day can contain leap seconds which means its not always 24 * 60 seconds long. This is the reasoning why the golang language support stops at hours: https://github.com/golang/go/issues/11473. Were using the native golang time range type, so thats our current limit too.

When we are to implement this we'd have to decide to either:

  1. take one day as a fixed length: (1d = 24 * 60m)
  2. try to take differences in time duration into account. Which might be hard.

J12934 avatar Apr 26 '22 10:04 J12934

@J12934

Is just a matter of convenience and ease of use.

Personally, I think if I just want to run every 7 days then second-counting is not in my mind. If I would like more precision then I could define the interval in minutes and seconds.

My recommendation, just implement 1d = 24 * 60m as you mention above and write in the docs that for more precision to use the minute-second notation.

Spritekin avatar Apr 26 '22 23:04 Spritekin

We introduce with v4.1.0 a crontab like syntax for scheduled scans: https://github.com/secureCodeBox/secureCodeBox/issues/150

Weltraumschaf avatar Aug 07 '23 11:08 Weltraumschaf