Commit Graph

39 Commits

Author SHA1 Message Date
Tim Allclair 2a8bc69060 Initialize the AuditEvent with the AuditContext (#113611)
* Initialize the AuditEvent with the AuditContext

* Squash: Address PR feedback

* Squash: address PR feedback

Kubernetes-commit: 2b03f04ce589a57cf80b2153c7e5056c53c374d3
2023-07-03 18:28:13 +00:00
Tim Allclair bd7c7f52c2 Consolidate AuditContext
Kubernetes-commit: f1d684b7b60b39b7dc1eb4156307c593f0ba74e1
2022-07-12 11:53:57 -07:00
Tim Allclair 8a252ba686 More useful audit error logs
Kubernetes-commit: 8924d0e8b6d185eef8794f9144c321e2f4a0adae
2022-08-04 15:17:13 -07:00
scott 91c6c18439 Fix issue that Audit Server could not correctly encode DeleteOption
Kubernetes-commit: 286a67d78c5be2b9ee39ed9fe26aa5a232058832
2022-05-18 20:23:16 +08:00
Tim Allclair 1e36b0a9fb Don't add audit annotations directly to the audit event
Kubernetes-commit: bdebc62d49293a0fbbd7e0d95bfd94b1ce21015c
2022-03-28 11:38:38 -07:00
Tim Allclair 95587e321e Audit annotations mutex
Kubernetes-commit: c3a68d5de83116289799571de57ace47cd950364
2022-03-28 17:21:14 +00:00
uhari03 ba2b9977b2 Issue 105353: Add messages+details to audit logs response (#105415)
Kubernetes-commit: 016b96ca3896d27b37c5b2d6e223fb3320a0fdec
2022-02-23 17:53:33 -08:00
Abu Kashem fea88b8efd drop managed fields from audit entries
drop the managed fields of the objects from the audit entries when we
are logging request and response bodies.

Kubernetes-commit: bbc59348318c29199e23b27981fb56436ac68705
2020-10-12 13:18:59 -04:00
njuptlzf dd5fc094cd Use objGV instead of gvk.GroupVersion
Kubernetes-commit: 15c4d579f08335f33555d3cab5eff41c74e671b9
2021-06-02 14:27:30 +08:00
njuptlzf 790f5a21a7 Fix auditing failed of request: encoding failed
Kubernetes-commit: 329f7d55d1344f728e28ce49728234f9f8f4c5d3
2021-05-17 02:31:08 +08:00
Abu Kashem f1a76db888 apiserver: manage audit ID associated with a request
Manage the audit ID early in the request handling logic so that it can
be used by different layers to improve correlation.
- If the caller does not specify a value for Audit-ID in the request
  header, we generate a new audit ID
- If a user specified Audit-ID is too large, we truncate it
- We echo the Audit-ID value to the caller via the response
  Header 'Audit-ID'

Kubernetes-commit: 31653bacb9b979ee2f878ebece7e25f79d3f9aa6
2021-03-02 19:22:39 -05:00
Abu Kashem 50cce843c9 Take into account latency incurred in server filters
apiserver_request_duration_seconds does not take into account the
time a request spends in the server filters. If a filter takes longer
then the latency incurred will not be reflected in the apiserver
latency metrics.

For example, the amount of time a request spends in priority and
fairness machineries or in shuffle queues will not be accounted for.

- Add a server filter that attaches request received timestamp to the
request context very early in in the handler chain (as soon as
net/http hands over control to us).
- Use the above received timestamp in the apiserver latency metrics
apiserver_request_duration_seconds.
- Use the above received timestamp in the audit layer to set
RequestReceivedTimestamp.

Kubernetes-commit: d74ab9e1a4929be208d4529fd12b76d3fcd5d546
2020-09-18 16:46:07 -04:00
Davanum Srinivas 5879417a28 switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
Monis Khan 1873d19869 Allow handlers early in the request chain to set audit annotations
This change adds the generic ability for request handlers that run
before WithAudit to set annotations in the audit.Event.Annotations
map.

Note that this change does not use this capability yet. Determining
which handlers should set audit annotations and what keys and values
should be used requires further discussion (this data will become
part of our public API).

Signed-off-by: Monis Khan <mok@vmware.com>

Kubernetes-commit: 0bc62112adf270ef4efada37286319c229324c7b
2020-03-19 20:02:37 -04:00
Mike Danese 44b9fc84ab migrate callers to g/g/uuid
Kubernetes-commit: a4ca9e6c93e45b4a97e7d04df37362299088f64a
2019-11-04 23:15:20 -08:00
Jordan Liggitt a653e5ab1a Export UserInfo conversion, use authnv1.UserInfo in audit
Kubernetes-commit: 0e787a4b78a849fa66a02126721dd185e7c00955
2019-09-09 08:54:54 -04:00
Haowei Cai 70c200c6a0 audit & admission: associate annotation with audit level
Kubernetes-commit: 318226f3403f56aaf796af3f439c13674aa2b7ab
2019-05-31 15:36:29 -07:00
leigh capili 7762f62741 Refactor loops over SupportedMediaTypes() where mediaType is used to match a single SerializerInfo{}
We have an existing helper function for this:  runtime.SerializerInfoForMediaType()

This is common prep-work for encoding runtime.Objects into JSON/YAML for transmission over the wire or writing to ComponentConfigs.

Kubernetes-commit: 47e52d2981dc2a5c5950042f50688cf24dd92eda
2019-04-04 19:01:01 -06:00
David Eads 22712db708 make audit metadata work for custom resources
Kubernetes-commit: 9d41c0099adc9a9328209075421eb42681bd4b09
2019-02-26 14:37:58 -05:00
Davanum Srinivas 2710b17b80 Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135

Kubernetes-commit: 954996e231074dc7429f7be1256a579bedd8344c
2018-11-09 13:49:10 -05:00
Christoph Blecker 92e87e143a Update gofmt for go1.11
Kubernetes-commit: 97b2992dc191a357e2167eff5035ce26237a4799
2018-10-05 12:59:38 -07:00
xuzhonghu 895382e183 limit User-Agent max length 1024 and add ...TRUNCATED suffix
Kubernetes-commit: f0b1f1c2f67877ddb2eceac5eb7c9c4ea22b4b6b
2018-06-20 11:15:09 +08:00
xuzhonghu c739da1f02 logging user-agent in audit
Kubernetes-commit: d066d547cce64a4f02bb05d718bc53fe71d06ad3
2018-06-06 10:53:03 +08:00
Cao Shufeng 69b26e07a7 avoid duplicate status in audit events
Fixes: https://github.com/kubernetes/kubernetes/issues/60108

Kubernetes-commit: 4d20c38c337525f8105969a582ce421f52d09c8e
2018-04-25 10:13:51 +08:00
hzxuzhonghu 7fb69020af fix typo and remove inaccurate TODO
Kubernetes-commit: d94925af8854031f1548466c655afd3119613785
2018-02-23 09:27:37 +08:00
Cao Shufeng 8af8554968 add Annotations to audit event
Kubernetes-commit: 97b0d99a33d71250bc7f967135c435e62343d9b8
2018-01-08 12:00:33 +08:00
Cao Shufeng 2a2505e824 remove duplicated import
Kubernetes-commit: 4e7398b67b12390486012dd6f9d708dd64f961f3
2018-01-11 19:15:11 +08:00
Cao Shufeng f7e881914a support micro time for advanced audit
Kubernetes-commit: 817bc6954ca9af02013fd8f492f8ef865c217b0d
2017-09-25 11:56:30 +08:00
Cao Shufeng d781318aca audit real impersonated user info
Log the newest impersonated user info in the second audit event. This
will help users to debug rbac problems.

Kubernetes-commit: 1c3dc52531b7761921c8855cafc58b669da111f1
2017-09-03 14:04:13 +00:00
Cao Shufeng 9ab155429e Split APIVersion into APIGroup and APIVersion in audit events
audit.Event.ObjectRef.APIVersion currently holds both the the API group and
version, separated by a /. This change break these out into separate fields.

This is part of:
https://github.com/kubernetes/kubernetes/issues/48561

Kubernetes-commit: c57eebfe2f8d36361d510f0afd926777a44cccd2
2017-09-01 16:38:54 +00:00
Cao Shufeng d248b52a81 Fix Audit-ID header key
Now http header key "Audit-ID" doesn't have effect, because golang
automaticly transforms "Audit-ID" into "Audit-Id". This change use
http.Header.Get() function to canonicalize "Audit-ID" to "Audit-Id".

Kubernetes-commit: f21bc7bb9a82378e8b24f72c66dfd23bc8113f20
2017-07-06 23:56:07 +00:00
Cao Shufeng af4570c690 update events' ResponseStatus at Metadata level
ResponseStatus is populated in MetadataLevel, so we also update it in
MetadataLevel.

Kubernetes-commit: b6abcacb38d5da7c70ea9f3e6f673c8beeb90092
2017-07-04 08:39:44 +00:00
Chao Xu 8be42ee0d0 run hack/update-all
Kubernetes-commit: 60604f8818aecbc9c3736fbc32747cc0a535bc80
2017-06-28 00:14:31 +00:00
Chao Xu 81b7aaaa7d run root-rewrite-import-client-go-api-types
Kubernetes-commit: f2d3220a11111f86b2f481e70e3c1ca4f5896f44
2017-06-28 00:14:31 +00:00
Tim St. Clair 64014c6e25 audit: Fill in full ObjectRef, include in LevelMetadata
Kubernetes-commit: 28beb4572e676b9073f400fb6ccf2720381a41d0
2017-06-14 20:44:08 +00:00
Dr. Stefan Schimanski 8b776edc46 audit: fill in sub-resource
Kubernetes-commit: 019003b9266872f912b188708583141a34561007
2017-06-13 20:47:29 +00:00
Tim St. Clair 8ff532a4cb Implement audit policy logic
Kubernetes-commit: a5de309ee261aea15bb1cc12647b32640c2ac196
2017-06-13 20:47:28 +00:00
Tim St. Clair dac438aa53 Update existing code for audit API changes
Kubernetes-commit: 4c54970d31f0e35f21247514fb946081e6ee0be5
2017-06-13 20:47:28 +00:00
Dr. Stefan Schimanski f7d766d92d audit: add audit event to the context and fill in handlers
Kubernetes-commit: 0b5bcb021932355b3ff7c2b45fb579f4adad84bf
2017-06-13 20:47:28 +00:00