Fire an audit even when the agent configuration file changes
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Release notes
Problem to solve
As a compliance manager, I want to ensure that all the agent to Kubernetes connections follow our standards and no changes go unnoticed, so I can ensure compliance.
As the agent for Kubernetes allows access to a cluster from projects and groups that the agent is shared with, while Kubernetes RBAC can be used extensively to restrict access in-cluster, even extending the scope of access is interesting from a compliance standpoint.
Proposal
Fire an audit event whenever an agent config file changes
Intended users
Feature Usage Metrics
No new metrics
Does this feature require an audit event?
No
Implementation Plan
Prerequisits:
Rails Internal API Updates
- Update
POST internal/kubernetes/agent_configuration:- Add support for:
- Commit SHA of the agent configuration file.
- Add support for:
Rails Changes
-
Tiering: this must be implemented in the
EEcode as GitLab Premium and GitLab Ultimate features only. The API code must still accept all the fields even in GitLab Free because KAS is NOT aware of GitLab tiers. -
Trigger Audit Event:
- Use the
POST internal/kubernetes/agent_configurationendpoint as the trigger to track changes and fire audit events. - This endpoint is invoked by KAS whenever changes to the agent configuration file are detected (via Gitaly).
- Use the
-
Helper Function:
- Add a helper in
agent_helpers.rbto:-
Track Changes:
- Use the received commit SHA to detect changes.
- Record the last known commit in the agent table.
-
Fire Audit Events:
- If a new commit is detected, update the agent table and fire an audit event with the old and new commit SHAs.
-
Track Changes:
- The helper is always called, even if no changes occur, so ensure audit events are only fired when necessary.
- Add a helper in
KAS Changes (done)
- (done)
Send the commit SHA of the agent configuration file in the agent configuration module server code.
Impact
- Fire audit events the first time when the agent table fields are still
NULL. We don't need backfills.