Skip to content

corgid: add upload application-inventory#910

Draft
sky1122 wants to merge 1 commit intobottlerocket-os:developfrom
sky1122:peach-test
Draft

corgid: add upload application-inventory#910
sky1122 wants to merge 1 commit intobottlerocket-os:developfrom
sky1122:peach-test

Conversation

@sky1122
Copy link
Copy Markdown
Contributor

@sky1122 sky1122 commented Apr 15, 2026

Description of changes:
Add corgid, a new Rust binary that runs as a oneshot systemd service on boot to send Bottlerocket's package inventory
to the Amazon Inspector telemetry API as a CycloneDX 1.5 SBOM.

Testing done:
build variant and check the corgid service

Apr 14 21:02:50 ip-192-168-36-145.ec2.internal systemd[1]: Starting Inspector SBOM telemetry sender...
Apr 14 21:02:50 ip-192-168-36-145.ec2.internal corgid[1751]: 21:02:50 [INFO] Fetching metadata
Apr 14 21:02:50 ip-192-168-36-145.ec2.internal corgid[1751]: 21:02:50 [INFO] Received dynamic/instance-identity/document
Apr 14 21:02:50 ip-192-168-36-145.ec2.internal corgid[1751]: 21:02:50 [INFO] Received meta-data/instance-id
Apr 14 21:02:50 ip-192-168-36-145.ec2.internal corgid[1751]: 21:02:50 [INFO] Received meta-data/local-hostname
Apr 14 21:02:50 ip-192-168-36-145.ec2.internal corgid[1751]: 21:02:50 [INFO] Received meta-data/instance-type
Apr 14 21:02:50 ip-192-168-36-145.ec2.internal corgid[1751]: 21:02:50 [INFO] Received meta-data/services/partition
Apr 14 21:02:50 ip-192-168-36-145.ec2.internal corgid[1751]: 21:02:50 [INFO] Reading inventory and converting to SBOM
Apr 14 21:02:50 ip-192-168-36-145.ec2.internal corgid[1751]: 21:02:50 [INFO] Fetching IAM credentials
Apr 14 21:02:50 ip-192-168-36-145.ec2.internal corgid[1751]: 21:02:50 [INFO] Using new /telemetry API endpoint
Apr 14 21:02:50 ip-192-168-36-145.ec2.internal corgid[1751]: 21:02:50 [INFO] Starting session
....
Apr 14 21:02:51 ip-192-168-36-145.ec2.internal systemd[1]: corgid.service: Deactivated successfully.
Apr 14 21:02:51 ip-192-168-36-145.ec2.internal systemd[1]: Finished Inspector SBOM telemetry sender.
bash-5.2#

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@sky1122
Copy link
Copy Markdown
Contributor Author

sky1122 commented Apr 15, 2026

force pushed to fix the clippy

@sky1122 sky1122 force-pushed the peach-test branch 4 times, most recently from 1a6e780 to abbf248 Compare April 16, 2026 19:09
@sky1122
Copy link
Copy Markdown
Contributor Author

sky1122 commented Apr 16, 2026

force pushed to add user cannot manual start the corgid systemd service and systemd retry.
remvoe the write to the /tmp file and comparing entire hsah logic to always send sbom.

Comment thread packages/os/corgid.service Outdated
Comment on lines +11 to +16
# Retry on failure since manual restart is refused. This covers transient issues
# such as IMDS warmup, network not fully settled, or temporary API errors that
# outlast the in-binary retry window (~7s of exponential backoff per attempt).
# 3 attempts at 30s intervals covers a ~90s window, sufficient for transient
# infrastructure issues. After 3 failures within 5 minutes, systemd stops
# retrying to avoid hammering on persistent errors (e.g. missing IAM role).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Retry on failure since manual restart is refused. This covers transient issues
# such as IMDS warmup, network not fully settled, or temporary API errors that
# outlast the in-binary retry window (~7s of exponential backoff per attempt).
# 3 attempts at 30s intervals covers a ~90s window, sufficient for transient
# infrastructure issues. After 3 failures within 5 minutes, systemd stops
# retrying to avoid hammering on persistent errors (e.g. missing IAM role).
# Retry transient issues on failure since manual restart is refused.

nit but I don't think this level of detail is needed

Comment thread packages/os/os.spec Outdated
Source123: pluto.service
Source124: bootstrap-commands.service
Source125: whippet.service
Source127: corgid.service
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not Source126?

Comment thread sources/corgid/src/inspector.rs Outdated

const BASE64_CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

fn base64_encode(data: &[u8]) -> String {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we handrolling b64 encode/decode instead of using https://crates.io/crates/base64 ?

Comment thread packages/os/os.spec
Requires: (%{_cross_os}pluto if %{_cross_os}variant-family(aws-k8s))
Requires: (%{_cross_os}shibaken if %{_cross_os}variant-platform(aws))
Requires: (%{_cross_os}cfsignal if %{_cross_os}variant-platform(aws))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't install this on vmware variants, you need to add

Requires: (%{_cross_os}corgid if %{_cross_os}variant-platform(aws))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add this package in the variant package

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been told to add into variant package than here. But I think you are right if the reason is don't install on vmware this line should be better than into variant definition. Thanks!

Comment thread sources/corgid/src/inventory.rs Outdated
use std::fs;
use uuid::Uuid;

/// Host and IMDS metadata for SBOM properties
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only doc comment in the added corgid package. There are almost 0 additional comments in actual logic for corgid. Please add more comments and doc comments to this change.

Add the corgid agent for collecting and sending host vulnerability
scan telemetry to the inspector2-telemetry service. This includes
SIGv4-signed API calls for session management and SBOM submission,
IMDS-based credential retrieval, package inventory collection, and
a systemd service unit for integration with the OS.

Signed-off-by: Jingwei Wang <jweiw@amazon.com>
@sky1122 sky1122 changed the title corgid: add inspector telemetry agent corgid: add inspector agent Apr 21, 2026
@sky1122 sky1122 changed the title corgid: add inspector agent corgid: add upload application-inventory Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants