195 Commits

Author SHA1 Message Date
Vault Automation
2ef4c50221
Add audit log entries for new token type (#12747) (#12908)
* Add audit log entries for enterprise JWT token fields



* Reduce enterprise token field comment detail

- simplify enterprise token comments in sdk/logical/request.go
- remove verbose wording about issuer/audience/authorization semantics



* Fix TestAudit_JWT_DelegationToken permission denied error

The test was failing with 'permission denied' when using a delegation token
(JWT with act claim) to access cubbyhole. The root causes were:

1. RAR (Rich Authorization Request) check: The JWT contained
   'authorization_details' constraints that only allowed access to
   'secret/data/users/alice' and 'secret/data/config/general', but the
   test was attempting to access 'cubbyhole/test'. The RAR check in
   PerformRARCheck() was correctly denying this mismatch.

2. Missing entity policies for actor ACL: For delegation tokens, the
   actor's ACL is built solely from entity identity policies (not token
   policies like 'default'). Without explicit policies on the actor
   entity, the delegation ACL intersection check would fail.

Fixes:
- Removed 'authorization_details' from the test JWT since the test is
  about verifying audit log entries for delegation tokens, not RAR
  constraints
- Added 'default' policy to both subject and actor entities to ensure
  both ACLs allow cubbyhole access for the delegation token intersection
- Updated test assertions to match the simplified JWT (removed
  authorization_details verification)



* Use require.NoError instead of t.Fatalf for error check



* Add explicit checks for auth field presence before type assertion

Adds separate checks to verify the 'auth' and 'metadata' fields exist in
the map before attempting type assertion, preventing potential panics
and improving test clarity.



* test: tighten request metadata merge assertions



* test: simplify enterprise metadata assertions



* test: split enterprise metadata merge coverage



* style: apply gofumpt to entry formatter tests



* test: add godoc for enterprise token metadata test



---------

Co-authored-by: Bianca <48203644+biazmoreira@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-11 19:21:10 +01:00
Vault Automation
c6170d36a8
Add the ability for a plugin to specify extra fields for auditing purposes (#11018) (#12167)
* Add the ability to specify extra audit only fields from a plugin

* Add extra auditing fields within the PKI OCSP handler

* Add missing copywrite headers

* Format OCSP dates when non-zero, otherwise specify not set to be clear

* Feedback 2: Only set time fields if not zero instead of non-parsable string

* Serialize JSON fields in SDK response struct

* Perform renames based on RFC feedback

* Resolve OpenAPI test failure

* add cl

Co-authored-by: Steven Clark <steven.clark@hashicorp.com>
2026-02-04 15:41:54 +00:00
Vault Automation
0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00
Scott Miller
63ba96c988
Add additional validations to the destination and properties of file audit sinks (#31211)
* Add additional validations to the destination and properties of file audit sinks

* changelog

* docs

* Revert "docs"

This reverts commit c2e8f7608ede78adf96726100013a45831712e13.
2025-07-08 13:33:26 -05:00
co63oc
c95f3cb47f
Fix (#29797)
Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
2025-04-08 14:00:08 -04:00
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