Commit Graph

190 Commits

Author SHA1 Message Date
Chris Capurso
69411d7925 VAULT-30108: Include User-Agent header in audit requests by default (#28596)
* include user-agent header in audit by default

* add user-agent audit tests

* update audit default headers docs

* add changelog entry

* remove temp changes from TestAuditedHeadersConfig_ApplyConfig

* more TestAuditedHeadersConfig_ApplyConfig fixes

* add some test comments

* verify type assertions in TestAudit_Headers

* more type assertion checks
2024-10-07 10:02:17 -04:00
Peter Wilson
322cb27395 Audit: always use derived context for audit logging, increase timeout to 10s (#28286)
* always use derived context for audit logging, increase timeout to 10secs max

* improve go doc

* changelog
2024-09-05 16:34:18 +01:00
Peter Wilson
3be1719c71 add auth and secret block to response test for hmac (#28283) 2024-09-05 12:26:53 +01:00
Peter Wilson
a7026acef9 remove multierror package - from entry formatter (#28253) 2024-09-03 12:00:15 +01:00
JMGoldsmith
9ba5437ab5 adding some code (#28236) 2024-08-30 17:19:25 +01:00
Peter Wilson
d219fc5002 treat all errors as part of the same variadic set of arguments (#28102) 2024-08-16 14:28:05 +00:00
Peter Wilson
b0616065c5 Audit: logging and improvements (#28056)
* Add trace logging to context creation during log req/resp. Improve context sensitivity of sink nodes (file, socket), update eventlogger to include context info in error

* changelog

* Queue for the lock but check context immediately

* fix race in test
2024-08-12 18:36:13 +01:00
Peter Wilson
a19195c901 unexport as much as possible in the audit package (#28039) 2024-08-09 17:03:29 +01:00
Peter Wilson
d824e572be merge two consecutive if checks, update comments (#27963) 2024-08-05 13:54:37 +00:00
Peter Wilson
2dbb3d4dcb Audit: rewrite audit entry formatting to improve performance (#27952)
* rewrite audit entry formatting to improve performance
2024-08-02 19:04:39 +01:00
Peter Wilson
c555503f39 Audit: Test fixes and improvements (#27934)
* update tests/fix tests
2024-08-01 13:57:04 +00:00
Peter Wilson
aeae52fc4f Audit: Use existing cloned object for hashing (don't re-clone) (#27913)
* unexport hashstructure funcs

* don't re-copy/clone LogInput fields when this object belongs to the pipeline
2024-07-31 10:47:10 +01:00
Peter Wilson
4f6c215a65 unexport hashstructure funcs (#27911) 2024-07-30 15:31:59 +01:00
Peter Wilson
6ec5fa00e1 Remove multi-errors and update expected error msg in tests (#27861) 2024-07-24 23:07:37 +01:00
Peter Wilson
69c0433f9f Audit: optional logger for sinks will log on errors when context is done (#27859)
* Added optional logger for sink nodes (supplied by backends) will log on errors when context is also done

* changelog
2024-07-24 22:57:15 +01:00
Peter Wilson
39b99b2e05 Audit: log 'warnings' from eventlogger even if audit is deemed a success (#27809)
* make sure we still log underyling pipeline errors even if audit is deemed a success

* changelog
2024-07-19 11:12:51 +01:00
Peter Wilson
4078417016 Audit: check if context is already cancelled when assessing viability for audit (#27531)
* check if context is already cancelled when assessing viability for audit

* changelog
2024-06-18 18:57:18 +00:00
Peter Wilson
961442c959 VAULT-23334: CE changes to support exclusion in audit (#26615)
* CE changes to support exclusion in audit

* Add an external test for audit exclusion

---------

Co-authored-by: Kuba Wieczorek <kuba.wieczorek@hashicorp.com>
2024-06-11 08:40:18 +01:00
Peter Wilson
3f11c24c13 VAULT-23335: Audit - Exclusion Docs (Draft) (#26696)
* Added exclusion draft docs

* added message to link exported types RequestEntry and ResponseEntry to website docs

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* `an` => `a`

* quotes

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/enterprise/audit/exclusion.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/partials/audit-options-common.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* JSON {} 'objects'

* condition is optional

* Update website/content/docs/enterprise/audit/exclusion.mdx

---------

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>
2024-06-11 08:39:54 +01:00
Peter Wilson
60cb7a9230 increase the time on a context check for audit related tests (#27049) 2024-05-15 16:52:07 +00:00
Peter Wilson
ecc46a4a4d Order fields (#26966) 2024-05-13 13:32:02 +01:00
Peter Wilson
d66461ef07 VAULT-26466: audit - include correlation ID headers by default (#26777)
* Include correlation ID header by default for audit

* changelog

* casing adjustment
2024-05-08 12:36:00 +01:00
Peter Wilson
cbda3fddb9 use timeout (5s) (#26803) 2024-05-03 10:39:48 +00:00
Peter Wilson
22b53ed099 VAULT-24945: audit - add context timeout to audit request (#26616)
* add context timeout to audit request

* Ensure 'minimum' timeout for contexts when attempting to send audit entries to the broker
2024-04-30 18:03:18 +01:00
Peter Wilson
555d29427a move entry formatter config to its own file (#26576) 2024-04-22 15:50:57 +00:00
Peter Wilson
1d67c3f3b4 Audit: move validation of audit related options for Enterprise/CE to audit package (#26575)
* move option validation for enterprise options to audit package from vault package

* remove commented lines

* remove blank line
2024-04-22 15:39:52 +00:00
Peter Wilson
29969a9d40 start removing magic strings for audit types (#26549) 2024-04-19 16:33:54 +00:00
Peter Wilson
244b4998a0 Update metric labeler for CE/Ent (#26537) 2024-04-19 13:26:15 +00:00
Peter Wilson
16cd58d478 Remove unused and redundant call to validate options (#26533) 2024-04-19 09:21:15 +00:00
Peter Wilson
7c9e4f39b6 headers test tweaks (#26532) 2024-04-19 08:34:20 +00:00
Peter Wilson
fde8ace212 parallelize other tests (#26494) 2024-04-18 13:25:43 +00:00
Peter Wilson
8bee54c89d VAULT-24452: audit refactor (#26460)
* Refactor audit code into audit package
* remove builtin/audit
* removed unrequired files
2024-04-18 08:25:04 +01:00
Peter Wilson
38a78697c2 move noop audit to audit package (#26448) 2024-04-16 19:09:11 +01:00
Peter Wilson
c96c1efcea Don't wrap error from filter field validation (#26362) 2024-04-11 10:52:07 +00:00
Peter Wilson
3dc16db87e VAULT-24798: audit - improve error messages (#26312)
* audit: remove 'op' from error messages and do some clean up

* Allow early error checking to be concerned with vault/Core vs. audit
2024-04-11 09:09:32 +01:00
Peter Wilson
e0a905e8f8 VAULT-25710: Audit - enforce header formatter requirement in EntryFormatter (#26239)
* Check Enterprise unseal order for audit funcs, enforce header formatter in audit entry formatter node
* ApplyConfig return empty headers (but never nil) when nil/empty supplied
* Add NoopHeaderFormatter and remove builtin audit testHeaderFormatters
2024-04-03 10:53:34 +01:00
Peter Wilson
5a1d20bd35 Audit: Timestamps on sink entries should match the creation time of the audit event (#26088)
* Sync timestamps in sinks to the creation time of the audit entry (event)

* changelog
2024-03-22 13:26:55 +00:00
Peter Wilson
5f1193b2bb refactored audit package (#25879) 2024-03-12 10:09:37 +00:00
Peter Wilson
67c16342d8 VAULT-24013: Audit regression attempting to recover from panic (#25605)
* Add Logger to BackendConfig

* EntryFormatter use logger and recover panics

* Added TODO to consider

* Add 'name' to entry formatter

* Add test for the panic

* Fix NoopAudit with update params

* emit counter metric even when 0

* Fix vault package tests

* changelog

* Remove old comment during test writing
2024-02-26 10:33:30 +00:00
Peter Wilson
290df86e6d Removed unused code (#25513) 2024-02-20 10:38:43 +00:00
Peter Wilson
808cdfc2d2 Audit: some refactoring out of types.go (#25511)
* some refactoring out of types.go

* tests for metrics tag, parallelize other tests
2024-02-20 09:56:35 +00:00
Peter Wilson
83986f342b Audit: Extracted SSCT related auditing code to formatter node (#25443)
* Removed unneeded header tracking in log request/log response of audit broker, moved SSCT overwrite to entry formatter

* added changelog
2024-02-15 20:02:58 +00:00
Josh Black
fa13dbd381 add gosimport to make fmt and run it (#25383)
* add gosimport to make fmt and run it

* move installation to tools.sh

* correct weird spacing issue

* Update Makefile

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>

* fix a weird issue

---------

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
2024-02-13 14:07:02 -08:00
Kuba Wieczorek
a1295a54e8 [VAULT-23467] Validate audit filter option against filter selectors referencing unsupported fields (#25012)
* Validate audit filter option against filter selectors referencing unsupported fields

* Test updates due to filter validation

* Test all properties of the log input bexpr datum struct in filters

* Remove redundant cloning of the client in external tests for audit filtering

* TestAuditFilteringFilterForUnsupportedField now also tests the same behaviour with skip_test option set to true

* Add filter validation test cases to unit tests for audit backends

---------

Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>
2024-01-23 21:54:01 +00:00
Peter Wilson
2c3d0d8887 updates to tidy up audit code (#24976)
* updates to tidy up audit code

* updated error message in test
2024-01-22 13:55:15 +00:00
Peter Wilson
cfa37138b9 VAULT-23122: Audit fix for 'log_raw' issue (#24968)
* Fix for log_raw issue on audit

* Updates and test change

* changelog

* Update test now that the original event won't have the formatted data
2024-01-22 12:03:08 +00:00
Scott Miller
9bb4f9e996 Re-process .well-known redirects with a recursive handler call rather than a 302 redirect (#24890)
* Re-process .well-known redirects with a recursive handler call rather than a 302 redirect

* Track when the RequestURI mismatches path (in a redirect) and add it to the audit log

* call cancelFunc
2024-01-19 09:59:58 -06:00
Peter Wilson
ff0d1ff4c9 Audit: Entry formatting is the only supported way to do audit (#24867)
* removed 'writer' related code as we only do formatting within the eventlogger

* re-added ported test elide list responses
2024-01-15 21:04:21 +00:00
Peter Wilson
31baa89f75 audit: entry_formatter update to ensure no race detection issues (#24811)
* audit: entry_formatter update to ensure no race detection issues
* in progress with looking at a clone method for LogInput
* Tidy up LogInput Clone method
* less memory allocation
* fix hmac key clone
2024-01-12 14:47:29 +00:00
Peter Wilson
ebf627ceed VAULT-23050: Remove undocumented feature flag to disable audit eventlogger (#24764)
* Work towards removing the feature flag that disabled eventlogger for audit events

* Removed audited headers from LogRequest and LogResponse and clean up

* make clear we don't use a method param, and comment tweak

* Moved BenchmarkAuditFile_request to audit_broker_test and renamed. Clean up

* fixed calls from tests to Factory's

* waffling godoc for a ported and tweaked test

* Remove duplicate code from previous merges, remove uneeded code

* Refactor file audit backend tests

---------

Co-authored-by: Kuba Wieczorek <kuba.wieczorek@hashicorp.com>
2024-01-11 11:30:36 +00:00