Skip to content

Implement audit backend for Splunk.#167

Merged
Gerrit91 merged 10 commits intomasterfrom
audit-splunk
May 12, 2025
Merged

Implement audit backend for Splunk.#167
Gerrit91 merged 10 commits intomasterfrom
audit-splunk

Conversation

@Gerrit91
Copy link
Copy Markdown
Contributor

@Gerrit91 Gerrit91 commented Feb 12, 2025

Description

I tested this locally against the official splunk container image: https://hub.docker.com/r/splunk/splunk.

2025-02-12-123632_hyprshot

@Gerrit91 Gerrit91 marked this pull request as ready for review April 29, 2025 13:58
@Gerrit91 Gerrit91 requested a review from a team as a code owner April 29, 2025 13:58
@Gerrit91
Copy link
Copy Markdown
Contributor Author

Seems like it works.

@Gerrit91 Gerrit91 requested a review from vknabel April 30, 2025 06:09
Comment on lines +15 to +23
// Async indexes audit traces asynchronously if set to true. if this functionality is implemented depends on the audit backend implementation.
// If this is set to true it can occur that audit traces get lost in case the backend is not available for receiving the trace.
Async bool
// AsyncRetry defines the amount of attempts to retry sending an audit trace to a backend in case it failed.
AsyncRetry int
// AsyncBackoff defines the backoff after a failed attempt to index an audit trace to a backend.
AsyncBackoff time.Duration
// AsyncTimeout sets a timeout for indexing a trace for the backend.
AsyncTimeout time.Duration
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.

These configs are declared for all auditing providers, but are only implemented for splunk.
Either these should be moved to the SplunkConfig or a different solution should be considered.

What if we'd create an asyncAuditing which would then only implement the async mechanism while forwarding the index requests to the actual/wrapped backend?

// would be used like this:
splunk, err := auditing.Splunk(...)
if err != nil {
  return nil, err
}
asyncAuditing := auditing.Async(auditing.AsyncConfig{Retry: 1, /*...*/}, splunk)
return asyncAuditing, nil

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.

Yes, sounds good. I wanted to keep it small as first attempt and don't generalize it, but it certainly much cleaner to do it like this. I'll give that a try.


ctx, cancel := context.WithTimeout(context.Background(), a.asyncTimeout)

req, err := http.NewRequestWithContext(ctx, http.MethodPost, a.endpoint+"/services/collector", bytes.NewBuffer(e))
Copy link
Copy Markdown
Contributor

@vknabel vknabel May 8, 2025

Choose a reason for hiding this comment

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

Is there any actual difference between the core of this for loop and the non-async variant?
This could be extracted into one function which could receive a context. In case of extracting the async mechanism this is of course obsolete.

@Gerrit91 Gerrit91 requested a review from vknabel May 12, 2025 08:00
Co-authored-by: Valentin Knabel <valentin.knabel@x-cellent.com>
@Gerrit91 Gerrit91 merged commit f40817e into master May 12, 2025
2 checks passed
@Gerrit91 Gerrit91 deleted the audit-splunk branch May 12, 2025 11:42
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.

2 participants