datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

[CONTINT-3760] SBOM Scanner to accept a ScanRequest with minimal information

Open AliDatadog opened this issue 1 year ago • 1 comments

What does this PR do?

This PR modifies the ScanRequest to accept minimal information.

Before:

  • The ScanOptions were specified in each scan request but are always the same for a given collector:
    • This field is non hashable and causes issue
  • The ResultChannel were specified in each scan request.
    • Does not decouple the processing/result forwarding from the request.
    • Difficult to close the channels on shutdown

Now:

  • ScanOptions are specified per Collector
    • The host collector specifies them depending on the flavor
  • ScanResult channels are specified per Collector.
    • Allows to shut them down
    • No dependence between a scanRequest and the result forwarding
  • ScanRequest contains minimal info:
    • The field is now hashable (for future retry mechanism)
    • We retrieve the most up to date ContainerImageMetadata object and cancel the scan if it doesn't exist anymore.

Motivation

We would like to eventually add a retry mechanism in the scanner for the docker and containerd collectors. It would require to use a kubernetes workqueue which also requires the ScanRequests to be properly hashable, see CONTINT-3760 and a larger PR with the retry mechanism implemented: https://github.com/DataDog/datadog-agent/pull/22639

Additional Notes

N/A

Possible Drawbacks / Trade-offs

N/A

Describe how to test/QA your changes

Generic QA for host scans and container image scans using docker or containerd. On containerd:

=== Entity container_image_metadata sources(merged):[runtime] id: sha256:7a32bbdde52eb25f6ef4f3ce8371e0e6c750b789983c1c01f608c3dc2fee0938 ===
----------- Entity ID -----------
Kind: container_image_metadata ID: sha256:7a32bbdde52eb25f6ef4f3ce8371e0e6c750b789983c1c01f608c3dc2fee0938
----------- Entity Meta -----------
Name: sha256:7a32bbdde52eb25f6ef4f3ce8371e0e6c750b789983c1c01f608c3dc2fee0938
Namespace: k8s.io
Annotations:
Labels: baseimage.os:ubuntu  maintainer:Datadog <[email protected]> org.opencontainers.image.ref.name:ubuntu org.opencontainers.image.source:https://github.com/DataDog/datadog-agent org.opencontainers.image.version:23.1 io.cri-containerd.image:managed baseimage.name:ubuntu:
Repo tags: []
Repo digests: [docker.io/alidatadog/agent@sha256:6eb7bda15f71a061ee4e3a3b4c0d716b22912f7b1409a5eb47054a8b11e50aa5]
Media Type: application/vnd.docker.distribution.manifest.v2+json
Size in bytes: 522136879
OS: linux
OS Version:
Architecture: arm64
Variant:
----------- SBOM -----------
Status: Success
Generated in: 1.75 seconds

For host scans you can look at the CSM product and check for vulns filtered with asset_type:Host.

Reviewer's Checklist

  • [ ] If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • [ ] Use the major_change label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.
  • [ ] A release note has been added or the changelog/no-changelog label has been applied.
  • [ ] Changed code has automated tests for its functionality.
  • [ ] Adequate QA/testing plan information is provided. Except if the qa/skip-qa label, with required either qa/done or qa/no-code-change labels, are applied.
  • [ ] At least one team/.. label has been applied, indicating the team(s) that should QA this change.
  • [ ] If applicable, docs team has been notified or an issue has been opened on the documentation repo.
  • [ ] If applicable, the need-change/operator and need-change/helm labels have been applied.
  • [ ] If applicable, the k8s/<min-version> label, indicating the lowest Kubernetes version compatible with this feature.
  • [ ] If applicable, the config template has been updated.

AliDatadog avatar Feb 07 '24 14:02 AliDatadog

Bloop Bleep... Dogbot Here

Regression Detector Results

Run ID: bd98ac6b-cabc-4f21-83ec-728cf08bb8de Baseline: ff3eefad6f31c6721aac938cc25a8e6a5e5ea45a Comparison: c8d0aa9f65b89be497054af356af2ebcfbe500e3 Total CPUs: 7

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

Experiments with missing or malformed data

  • basic_py_check

Usually, this warning means that there is no usable optimization goal data for that experiment, which could be a result of misconfiguration.

No significant changes in experiment optimization goals

Confidence level: 90.00% Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI
file_to_blackhole % cpu utilization -0.26 [-6.81, +6.30]

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
file_tree memory utilization +0.64 [+0.52, +0.76]
process_agent_standard_check_with_stats memory utilization +0.57 [+0.54, +0.60]
process_agent_standard_check memory utilization +0.46 [+0.42, +0.49]
process_agent_real_time_mode memory utilization +0.08 [+0.05, +0.12]
uds_dogstatsd_to_api_cpu % cpu utilization +0.06 [-1.36, +1.48]
trace_agent_msgpack ingress throughput +0.02 [+0.01, +0.03]
uds_dogstatsd_to_api ingress throughput +0.00 [-0.00, +0.00]
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.00, +0.00]
trace_agent_json ingress throughput -0.00 [-0.05, +0.05]
otel_to_otel_logs ingress throughput -0.07 [-0.70, +0.56]
idle memory utilization -0.17 [-0.20, -0.13]
file_to_blackhole % cpu utilization -0.26 [-6.81, +6.30]
tcp_syslog_to_blackhole ingress throughput -0.77 [-0.82, -0.72]

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

pr-commenter[bot] avatar Feb 07 '24 16:02 pr-commenter[bot]

/merge

AliDatadog avatar Feb 28 '24 15:02 AliDatadog

:steam_locomotive: MergeQueue

Pull request added to the queue.

There are 4 builds ahead! (estimated merge in less than 1h)

Use /merge -c to cancel this operation!

dd-devflow[bot] avatar Feb 28 '24 15:02 dd-devflow[bot]