From a70251f0784d00edaf4da62436c10ab31dbb977e Mon Sep 17 00:00:00 2001 From: smriti Date: Fri, 27 Sep 2024 23:14:32 +0530 Subject: [PATCH 1/2] Added audit event for user name change --- app/helpers/vite_helper.rb | 2 ++ doc/user/compliance/audit_event_types.md | 1 + ee/app/services/ee/users/update_service.rb | 3 +++ ee/config/audit_events/types/user_name_updated.yml | 9 +++++++++ ee/spec/services/ee/users/update_service_spec.rb | 14 ++++++++++++++ 5 files changed, 29 insertions(+) create mode 100644 ee/config/audit_events/types/user_name_updated.yml diff --git a/app/helpers/vite_helper.rb b/app/helpers/vite_helper.rb index f0a0436839e793..f70be673f358cd 100644 --- a/app/helpers/vite_helper.rb +++ b/app/helpers/vite_helper.rb @@ -38,6 +38,8 @@ def universal_stylesheet_link_tag(path, **options) options[:host] = URI::HTTP.build(host: ViteRuby.config.host, port: ViteRuby.config.port).to_s end + options[:extname] = false + stylesheet_link_tag( ViteRuby.instance.manifest.path_for("stylesheets/styles.#{path}.scss", type: :stylesheet), **options diff --git a/doc/user/compliance/audit_event_types.md b/doc/user/compliance/audit_event_types.md index fe2530c8bd4ad5..665048ac18f34d 100644 --- a/doc/user/compliance/audit_event_types.md +++ b/doc/user/compliance/audit_event_types.md @@ -581,6 +581,7 @@ Audit event types belong to the following product categories. | [`user_admin_status_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65168) | Adds an audit event when a user is either made an administrator, or removed as an administrator | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [14.1](https://gitlab.com/gitlab-org/gitlab/-/issues/323905) | User | | [`user_auditor_status_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/136456) | Adds an audit event when a user is either made an auditor, or removed as an auditor | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [16.6](https://gitlab.com/gitlab-org/gitlab/-/issues/430235) | User | | [`user_email_address_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/2103) | Adds an audit event when a user updates their email address | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [10.1](https://gitlab.com/gitlab-org/gitlab-ee/issues/1370) | User | +| [`user_name_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/106086) | Event triggered on updating a user's name | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [17.5](https://gitlab.com/gitlab-org/gitlab/-/issues/486532) | User | | [`user_profile_visiblity_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129149) | Triggered when user toggles private profile user setting | **{dotted-circle}** No | **{check-circle}** Yes | GitLab [16.3](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129149) | User | | [`user_username_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/106086) | Event triggered on updating a user's username | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [15.7](https://gitlab.com/gitlab-org/gitlab/-/issues/369329) | User | diff --git a/ee/app/services/ee/users/update_service.rb b/ee/app/services/ee/users/update_service.rb index 2f7d64296ce186..5795fe08ff3a92 100644 --- a/ee/app/services/ee/users/update_service.rb +++ b/ee/app/services/ee/users/update_service.rb @@ -31,6 +31,9 @@ def notify_success(user_exists) audit_changes(:username, as: 'username', event_type: 'user_username_updated') + audit_changes(:name, as: 'name', + event_type: 'user_name_updated') + audit_changes(:admin, as: 'admin status', event_type: 'user_admin_status_updated') diff --git a/ee/config/audit_events/types/user_name_updated.yml b/ee/config/audit_events/types/user_name_updated.yml new file mode 100644 index 00000000000000..c1ea13bf3a45a5 --- /dev/null +++ b/ee/config/audit_events/types/user_name_updated.yml @@ -0,0 +1,9 @@ +name: user_name_updated +description: Event triggered on updating a user's name +introduced_by_issue: https://gitlab.com/gitlab-org/gitlab/-/issues/486532 +introduced_by_mr: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/106086 +milestone: '17.5' +feature_category: user_profile +saved_to_database: true +streamed: true +scope: [User] diff --git a/ee/spec/services/ee/users/update_service_spec.rb b/ee/spec/services/ee/users/update_service_spec.rb index 7812e5506ffac9..568e52736c2daa 100644 --- a/ee/spec/services/ee/users/update_service_spec.rb +++ b/ee/spec/services/ee/users/update_service_spec.rb @@ -169,6 +169,20 @@ expect(AuditEvent.last.present.action).to eq(expected_message) end end + + context 'updating name' do + it 'logs audit event' do + previous_name = user.name + new_name = 'my_new_name' + expected_message = "Changed name from #{previous_name} to #{new_name}" + + expect do + update_user_as_self(user, name: new_name) + end.to change { AuditEvent.count }.by(1) + + expect(AuditEvent.last.present.action).to eq(expected_message) + end + end end end -- GitLab From 7c615f253bbfc9c3e708a203ccb10b1638ff49df Mon Sep 17 00:00:00 2001 From: smriti Date: Tue, 1 Oct 2024 17:28:37 +0530 Subject: [PATCH 2/2] Updated MR link to correct one Updated MR link to correct one --- doc/user/compliance/audit_event_types.md | 2 +- ee/config/audit_events/types/user_name_updated.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/user/compliance/audit_event_types.md b/doc/user/compliance/audit_event_types.md index 665048ac18f34d..b2ee7b3390fd76 100644 --- a/doc/user/compliance/audit_event_types.md +++ b/doc/user/compliance/audit_event_types.md @@ -581,7 +581,7 @@ Audit event types belong to the following product categories. | [`user_admin_status_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65168) | Adds an audit event when a user is either made an administrator, or removed as an administrator | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [14.1](https://gitlab.com/gitlab-org/gitlab/-/issues/323905) | User | | [`user_auditor_status_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/136456) | Adds an audit event when a user is either made an auditor, or removed as an auditor | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [16.6](https://gitlab.com/gitlab-org/gitlab/-/issues/430235) | User | | [`user_email_address_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/2103) | Adds an audit event when a user updates their email address | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [10.1](https://gitlab.com/gitlab-org/gitlab-ee/issues/1370) | User | -| [`user_name_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/106086) | Event triggered on updating a user's name | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [17.5](https://gitlab.com/gitlab-org/gitlab/-/issues/486532) | User | +| [`user_name_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/167484) | Event triggered on updating a user's name | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [17.5](https://gitlab.com/gitlab-org/gitlab/-/issues/486532) | User | | [`user_profile_visiblity_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129149) | Triggered when user toggles private profile user setting | **{dotted-circle}** No | **{check-circle}** Yes | GitLab [16.3](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129149) | User | | [`user_username_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/106086) | Event triggered on updating a user's username | **{check-circle}** Yes | **{check-circle}** Yes | GitLab [15.7](https://gitlab.com/gitlab-org/gitlab/-/issues/369329) | User | diff --git a/ee/config/audit_events/types/user_name_updated.yml b/ee/config/audit_events/types/user_name_updated.yml index c1ea13bf3a45a5..c91ec97bad8073 100644 --- a/ee/config/audit_events/types/user_name_updated.yml +++ b/ee/config/audit_events/types/user_name_updated.yml @@ -1,7 +1,7 @@ name: user_name_updated description: Event triggered on updating a user's name introduced_by_issue: https://gitlab.com/gitlab-org/gitlab/-/issues/486532 -introduced_by_mr: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/106086 +introduced_by_mr: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/167484 milestone: '17.5' feature_category: user_profile saved_to_database: true -- GitLab