Audit grpc requests #1184

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-node:feat/op_logging into master 2024-09-04 19:51:09 +00:00

Added config option to enable audit event logging, SIGHUP supported.

Audit logs for all handlers have the same structure: operation (grpc handler), object (containerID, treeID, objectID, nodeID, ownerID; it depends on handler), subject (client's public key), success (true or false).

Added config option to enable audit event logging, SIGHUP supported. Audit logs for all handlers have the same structure: operation (grpc handler), object (containerID, treeID, objectID, nodeID, ownerID; it depends on handler), subject (client's public key), success (true or false).
dstepanov-yadro force-pushed feat/op_logging from e7650d0be6 to efeb766356 2024-06-18 10:56:32 +00:00 Compare
dstepanov-yadro force-pushed feat/op_logging from efeb766356 to a11b93df64 2024-06-18 11:41:26 +00:00 Compare
dstepanov-yadro changed title from WIP: Audit grpc requests to Audit grpc requests 2024-06-18 11:55:58 +00:00
dstepanov-yadro requested review from storage-core-committers 2024-06-18 11:57:05 +00:00
dstepanov-yadro requested review from storage-core-developers 2024-06-18 11:57:16 +00:00
fyrchik reviewed 2024-06-18 12:43:12 +00:00
@ -0,0 +24,4 @@
func LogRequestWithKey(log *logger.Logger, operation string, key []byte, target Target, status bool) {
object, subject := NotDefined, NotDefined
publicKey := crypto.UnmarshalPublicKey(key)
Owner

keys.NewPublicKeyFromBytes does essentially the same and returns keys.PublicKey type. Why not use it?

`keys.NewPublicKeyFromBytes` does essentially the same and returns `keys.PublicKey` type. Why not use it?
Author
Member
  1. This method is used for signature verification (see frostfs-api-go).

  2. frostfs-crypto looks closer to frosfst-node than neo-go.

  3. This method is simpler: it returns public key or nil.

1. This method is used for signature verification (see `frostfs-api-go`). 2. `frostfs-crypto` looks closer to `frosfst-node` than `neo-go`. 3. This method is simpler: it returns public key or nil.
fyrchik marked this conversation as resolved
@ -0,0 +26,4 @@
func TargetFromRefs[T any](refs []*T, model ModelType[T]) Target {
if len(refs) == 0 {
return &stringTarget{s: NotDefined}
Owner

Why does String method have pointer receiver? We could save an allocation here with type stringTarget string, as I understand it is only used as nice stringer.

Why does `String` method have pointer receiver? We could save an allocation here with `type stringTarget string`, as I understand it is only used as nice stringer.
Author
Member

Fixed

Fixed
fyrchik marked this conversation as resolved
@ -0,0 +73,4 @@
if len(v) == 0 {
sb.WriteString(Empty)
} else {
sb.WriteString(string(v))
Owner

string(v) seems unnecessary, v is already string, no?

`string(v)` seems unnecessary, `v` is already string, no?
Author
Member

Fixed

Fixed
fyrchik marked this conversation as resolved
dstepanov-yadro force-pushed feat/op_logging from a11b93df64 to 462539b94f 2024-06-18 12:58:51 +00:00 Compare
acid-ant reviewed 2024-06-19 10:03:34 +00:00
@ -0,0 +145,4 @@
a.failed = true
}
a.objectID = resp.GetBody().GetObjectID()
audit.LogRequestWithKey(a.log, objectGRPC.ObjectService_Put_FullMethodName, a.key,
Member

How about to use string constant here as it is done for tracing:
objectGRPC.ObjectService_Put_FullMethodName -> putv2.streamer.CloseAndRecv.
And do the same for auditPutStream.Send().

How about to use string constant here as it is done for `tracing`: `objectGRPC.ObjectService_Put_FullMethodName` -> `putv2.streamer.CloseAndRecv`. And do the same for `auditPutStream.Send()`.
Author
Member

I didn't get the idea...

I didn't get the idea...
Member

Instead of logging with the same value for operation (CloseAndRecv and Send are using objectGRPC.ObjectService_Put_FullMethodName constant) use putv2.streamer.CloseAndRecv and putv2.streamer.Send, for example.

Instead of logging with the same value for `operation` (`CloseAndRecv` and `Send` are using `objectGRPC.ObjectService_Put_FullMethodName` constant) use `putv2.streamer.CloseAndRecv` and `putv2.streamer.Send`, for example.
Author
Member

Send logs only on an error, when CloseAndRecv will not call. So log will containe only one log record.

`Send` logs only on an error, when `CloseAndRecv` will not call. So log will containe only one log record.
acid-ant marked this conversation as resolved
fyrchik approved these changes 2024-06-19 11:39:48 +00:00
aarifullin approved these changes 2024-06-19 12:49:10 +00:00
acid-ant approved these changes 2024-06-19 13:04:25 +00:00
dstepanov-yadro force-pushed feat/op_logging from 462539b94f to fd28461def 2024-06-19 13:06:33 +00:00 Compare
fyrchik merged commit fd28461def into master 2024-06-19 17:18:13 +00:00
fyrchik referenced this pull request from a commit 2024-06-19 17:18:16 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#1184
No description provided.