Documentation
¶
Overview ¶
Package tasks provides tasks for submitting orphan resources discovered by Inventory as findings to the Open Delivery Gear API.
The flow for submitting findings to the Delivery Service API is as follows.
1. Fetch orphan resources from Inventory
Get the orphan resources from Inventory first, then convert them to findings, which the Delivery Service understands.
2. Wipe out old/previous findings for the artefact type
We need to delete the old/previous findings for the artefact type associated with the component name and version. This ensures no old entries exist in the database, since the Delivery Service does not have a retention mechanism for cleaning up such findings.
Also, we need to delete old/previous runtime artefacts for each finding.
3. Submit the orphan resources from step 1
The latest orphan resources fetched from step 1 are submitted to the Delivery Service API.
4. Create runtime artefacts, so that findings can be evaluated and compliance issues created or updated for them.
If we have no orphan resources to report, then we don't report anything to the remote API.
Index ¶
- Constants
- Variables
- func FetchResourcesFromDB(ctx context.Context, db *bun.DB, query string, dest any) error
- func HandleReportOrphanPublicAddressGCP(ctx context.Context, t *asynq.Task) error
- func HandleReportOrphanVirtualMachinesAWS(ctx context.Context, t *asynq.Task) error
- func HandleReportOrphanVirtualMachinesAzure(ctx context.Context, t *asynq.Task) error
- func HandleReportOrphanVirtualMachinesGCP(ctx context.Context, t *asynq.Task) error
- func HandleReportOrphanVirtualMachinesOpenStack(ctx context.Context, t *asynq.Task) error
- func MaybeSkipRetry(err error) error
- type Payload
Constants ¶
const TaskReportOrphanPublicAddressGCP = "odg:task:report-orphan-ip-addresses-gcp"
TaskReportOrphanPublicAddressGCP is the name of the task, which reports orphan GCP public IP addresses as findings.
const TaskReportOrphanVirtualMachinesAWS = "odg:task:report-orphan-vms-aws"
TaskReportOrphanVirtualMachinesAWS is the name of the task, which reports orphan AWS EC2 Instances as findings.
const TaskReportOrphanVirtualMachinesAzure = "odg:task:report-orphan-vms-az"
TaskReportOrphanVirtualMachinesAzure is the name of the task, which reports orphan Azure Virtual Machines as findings.
const TaskReportOrphanVirtualMachinesGCP = "odg:task:report-orphan-vms-gcp"
TaskReportOrphanVirtualMachinesGCP is the name of the task, which reports orphan GCP Virtual Machines as findings.
const TaskReportOrphanVirtualMachinesOpenStack = "odg:task:report-orphan-vms-openstack"
TaskReportOrphanVirtualMachinesOpenStack is the name of the task, which reports orphan OpenStack Virtual Machines as findings.
Variables ¶
var ErrNoComponentName = errors.New("no component name specified")
ErrNoComponentName is an error, which is returned by task handlers, which expect an OCM component name to be specified as part of the payload, but none was provided.
var ErrNoPayload = errors.New("no payload specified")
ErrNoPayload is an error, which is returned by task handlers, which expect a payload, but none was provided.
var ErrNoQuery = errors.New("no query specified")
ErrNoQuery is an error, which is returned by task handlers, which expect a query to be provided as part of the payload, but none was provided.
Functions ¶
func FetchResourcesFromDB ¶
FetchResourcesFromDB fetches the resources from the database using the given query into the given dest value.
func HandleReportOrphanPublicAddressGCP ¶
HandleReportOrphanPublicAddressGCP is a handler, which reports orphan GCP public IP addresses as findings.
func HandleReportOrphanVirtualMachinesAWS ¶
HandleReportOrphanVirtualMachinesAWS is a handler, which reports orphan AWS virtual machines as findings.
func HandleReportOrphanVirtualMachinesAzure ¶
HandleReportOrphanVirtualMachinesAzure is a handler, which reports orphan Azure virtual machines as findings.
func HandleReportOrphanVirtualMachinesGCP ¶
HandleReportOrphanVirtualMachinesGCP is a handler, which reports orphan GCP virtual machines as findings.
func HandleReportOrphanVirtualMachinesOpenStack ¶ added in v0.1.6
HandleReportOrphanVirtualMachinesOpenStack is a handler, which reports orphan OpenStack virtual machines as findings.
func MaybeSkipRetry ¶
MaybeSkipRetry wraps known API errors with asynq.SkipRetry, so that the tasks which these errors originate from won't be retried.
Types ¶
type Payload ¶
type Payload struct {
// Query represents the SQL query to use when fetching orphan resources.
Query string `yaml:"query" json:"query"`
// ComponentName specifies the name of the OCM component with which to
// associate the submitted findings.
ComponentName string `yaml:"component_name" json:"component_name"`
// ComponentVersion specifies the version of the OCM component with
// which to associate the submitted findings.
ComponentVersion string `yaml:"component_version" json:"component_version"`
}
Payload represents the payload expected by tasks which report orphan resources to the Open Delivery Gear API.
func DecodePayload ¶
DecodePayload decodes the payload for the given asynq.Task.