Skip to content

Refactor entity_path from AuditEvent details

Tan Le requested to merge 220324-add-entity-path-to-audit-events into master

What does this MR do?

This MR adds a entity_path column to AuditEvent and persists the value of details[:entity_path] to the entity_path column when an AuditEvent is created.

We plan to stop writing this piece of information in details in upcoming releases.

Relates to #220324 (closed)

Database

Migrate

== 20200716044023 AddEntityPathToAuditEvents: migrating =======================                                                                                                                                                                                                                                                               
-- add_column(:audit_events, :entity_path, :text)                                                                                                                                                                                                                                                                                             
   -> 0.0066s                                                                                                                                                                                                                                                                                                                                 
== 20200716044023 AddEntityPathToAuditEvents: migrated (0.0177s) ==============    

== 20200716120419 AddTextLimitOnEntityPathToAuditEvents: migrating ============
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE audit_events\nADD CONSTRAINT check_492aaa021d\nCHECK ( char_length(entity_path) <= 5500 )\nNOT VALID;\n")
   -> 0.0013s
-- execute("ALTER TABLE audit_events VALIDATE CONSTRAINT check_492aaa021d;")
   -> 0.0011s
== 20200716120419 AddTextLimitOnEntityPathToAuditEvents: migrated (0.0114s) ===                                                                                                                                                                                                                                                           

Rollback

== 20200716120419 AddTextLimitOnEntityPathToAuditEvents: reverting ============
-- execute("ALTER TABLE audit_events\nDROP CONSTRAINT IF EXISTS check_492aaa021d\n")
   -> 0.0007s
== 20200716120419 AddTextLimitOnEntityPathToAuditEvents: reverted (0.0065s) ===

== 20200716044023 AddEntityPathToAuditEvents: reverting =======================                                                                                                                                                                                                                                                               
-- remove_column(:audit_events, :entity_path)                                                                                                                                                                                                                                                                                                 
   -> 0.0014s                                                                                                                                                                                                                                                                                                                                 
== 20200716044023 AddEntityPathToAuditEvents: reverted (0.0103s) ==============

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Peter Leitzen

Merge request reports

Loading