From 2a368e2b61e0bf5a46b758df7da77181faf8af01 Mon Sep 17 00:00:00 2001 From: Serena Fang Date: Wed, 24 Apr 2024 22:53:22 -0500 Subject: [PATCH 1/2] Add enable pre receive secret detection checkbox to project repository settings page --- .../_pre_receive_secret_detection.html.haml | 11 +++++++++++ .../pre_receive_secret_detection/_show.html.haml | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 app/views/projects/pre_receive_secret_detection/_pre_receive_secret_detection.html.haml create mode 100644 app/views/projects/pre_receive_secret_detection/_show.html.haml diff --git a/app/views/projects/pre_receive_secret_detection/_pre_receive_secret_detection.html.haml b/app/views/projects/pre_receive_secret_detection/_pre_receive_secret_detection.html.haml new file mode 100644 index 00000000000000..69c0145df83f36 --- /dev/null +++ b/app/views/projects/pre_receive_secret_detection/_pre_receive_secret_detection.html.haml @@ -0,0 +1,11 @@ +- terms_link_start = ''.html_safe + += gitlab_ui_form_for @project, url: general_admin_application_settings_path(anchor: 'js-secret-detection-settings'), html: { class: 'fieldset-form', id: 'secret-detection-settings' } do |f| + %fieldset + .form-group + = f.fields_for :security_setting do |project_security_setting| + = project_security_setting.label :pre_receive_secret_detection_enabled, s_('ProjectSettings|Pre-receive secret detection'), class: 'label-bold' + %span.form-text.gl-mt-0.gl-mb-3#pre_receive_secret_detection-help + = _('Prevent secrets such as keys and API tokens from being committed to any repository in this GitLab project.') + = project_security_setting.gitlab_ui_checkbox_component :pre_receive_secret_detection_enabled, _('Enable pre-receive secret detection'), help_text: _("Enable pre-receive secret detection in this project. When you enable this feature, you accept the %{link_start}GitLab Testing Agreement%{link_end}.").html_safe % { link_start: terms_link_start, link_end: ''.html_safe } + = f.submit _('Save changes'), pajamas_button: true diff --git a/app/views/projects/pre_receive_secret_detection/_show.html.haml b/app/views/projects/pre_receive_secret_detection/_show.html.haml new file mode 100644 index 00000000000000..37e46d881e712f --- /dev/null +++ b/app/views/projects/pre_receive_secret_detection/_show.html.haml @@ -0,0 +1,16 @@ +- expanded = expanded_by_default? + +%section.settings.no-animate#pre-receive-secret-detection{ class: ('expanded' if expanded) } + .settings-header + %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _('Pre-receive secret detection') + = render Pajamas::ButtonComponent.new(button_options: { class: 'js-settings-toggle' }) do + = expanded ? _('Collapse') : _('Expand') + %p.gl-text-secondary + = s_('ProjectSettings|Manage secret detection behavior for this project.') + + .settings-content + - url = namespace_project_settings_repository_path(@project.namespace, @project) + = gitlab_ui_form_for @project, url: url, method: :put, html: { multipart: true, class: "issue-settings-form js-issue-settings-form" }, authenticity_token: true do |f| + %input{ name: 'update_section', type: 'hidden', value: 'js-issue-settings' } + = render 'projects/pre_receive_secret_detection/pre_receive_secret_detection', f: f + -- GitLab From c81c1855c700cb2fa4bf1453775ebe674dee91bb Mon Sep 17 00:00:00 2001 From: Serena Fang Date: Wed, 24 Apr 2024 22:54:37 -0500 Subject: [PATCH 2/2] Run gettext regenerate --- locale/gitlab.pot | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 5685389087fd42..58282a676b0232 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -19689,6 +19689,12 @@ msgstr "" msgid "Enable or disable version check and Service Ping." msgstr "" +msgid "Enable pre-receive secret detection" +msgstr "" + +msgid "Enable pre-receive secret detection in this project. When you enable this feature, you accept the %{link_start}GitLab Testing Agreement%{link_end}." +msgstr "" + msgid "Enable rate limiting for requests to the specified paths" msgstr "" @@ -38523,6 +38529,9 @@ msgstr "" msgid "Pre-defined push rules" msgstr "" +msgid "Pre-receive secret detection" +msgstr "" + msgid "Pre-receive secret detection skipped via" msgstr "" @@ -38778,6 +38787,9 @@ msgstr "" msgid "Prevent secrets such as keys and API tokens from being committed to any repository in this GitLab instance." msgstr "" +msgid "Prevent secrets such as keys and API tokens from being committed to any repository in this GitLab project." +msgstr "" + msgid "Prevent users from changing their profile name" msgstr "" @@ -40473,6 +40485,9 @@ msgstr "" msgid "ProjectSettings|Manage machine learning models." msgstr "" +msgid "ProjectSettings|Manage secret detection behavior for this project." +msgstr "" + msgid "ProjectSettings|Manage who can see the project in the public access directory." msgstr "" @@ -40551,6 +40566,9 @@ msgstr "" msgid "ProjectSettings|Pages for project documentation." msgstr "" +msgid "ProjectSettings|Pre-receive secret detection" +msgstr "" + msgid "ProjectSettings|Prevents direct linking to potentially sensitive media files" msgstr "" -- GitLab