digest generates a hash of the log entry that can be used to detect duplicates
(entry LogEntry, orgID *uuid.UUID, userID *uuid.UUID)
| 221 | // digest generates a hash of the log entry |
| 222 | // that can be used to detect duplicates |
| 223 | func digest(entry LogEntry, orgID *uuid.UUID, userID *uuid.UUID) (*cr_v1.Hash, error) { |
| 224 | var err error |
| 225 | toHash := struct { |
| 226 | ActionType string |
| 227 | TargetType TargetType |
| 228 | TargetID *uuid.UUID |
| 229 | Info json.RawMessage |
| 230 | OrgID *uuid.UUID |
| 231 | UserID *uuid.UUID |
| 232 | }{ |
| 233 | OrgID: orgID, |
| 234 | UserID: userID, |
| 235 | ActionType: entry.ActionType(), |
| 236 | TargetType: entry.TargetType(), |
| 237 | TargetID: entry.TargetID(), |
| 238 | } |
| 239 | |
| 240 | toHash.Info, err = entry.ActionInfo() |
| 241 | if err != nil { |
| 242 | return nil, err |
| 243 | } |
| 244 | |
| 245 | data, err := json.Marshal(toHash) |
| 246 | if err != nil { |
| 247 | return nil, err |
| 248 | } |
| 249 | |
| 250 | h, _, err := cr_v1.SHA256(bytes.NewBuffer(data)) |
| 251 | if err != nil { |
| 252 | return nil, err |
| 253 | } |
| 254 | |
| 255 | return &h, nil |
| 256 | } |
| 257 | |
| 258 | // GetActorIdentifier returns the actor identifier for audit log descriptions. |
| 259 | // It prioritizes ActorName, then ActorEmail, and finally falls back to system@chainloop.dev. |
no test coverage detected