]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15144 - Add Audit Logs Housekeeping Policy Setting
authorBelen Pruvost <belen.pruvost@sonarsource.com>
Wed, 21 Jul 2021 13:39:20 +0000 (15:39 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 27 Jul 2021 20:03:03 +0000 (20:03 +0000)
server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/UserNewValue.java
server/sonar-web/src/main/js/apps/audit-logs/components/AuditAppRenderer.tsx
server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/__snapshots__/AuditApp-test.tsx.snap
server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/__snapshots__/AuditAppRenderer-test.tsx.snap
server/sonar-web/src/main/js/apps/audit-logs/utils.ts
sonar-core/src/main/java/org/sonar/core/config/Frequency.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/config/PurgeConstants.java
sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java
sonar-core/src/main/resources/org/sonar/l10n/core.properties
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java

index c14fad1e4bb2b9a3142fc4804c6e95d73ef4474e..00b41a82462a0588cb7a3b909adef2ad81d3d5db 100644 (file)
@@ -101,7 +101,7 @@ public class UserNewValue implements NewValue {
   }
 
   @CheckForNull
-  public boolean isActive() {
+  public Boolean isActive() {
     return this.isActive;
   }
 
@@ -126,17 +126,17 @@ public class UserNewValue implements NewValue {
   }
 
   @CheckForNull
-  public boolean isLocal() {
+  public Boolean isLocal() {
     return this.local;
   }
 
   @CheckForNull
-  public boolean isOnboarded() {
+  public Boolean isOnboarded() {
     return this.onboarded;
   }
 
   @CheckForNull
-  public boolean isRoot() {
+  public Boolean isRoot() {
     return this.root;
   }
 
index f4dbb7d14903bf4a57584384fa3c91295490a023..31a2a546614faabf066b88c0768cd027d3a8d3d0 100644 (file)
@@ -85,7 +85,7 @@ export default function AuditAppRenderer(props: AuditAppRendererProps) {
           id="audit_logs.page.description.2"
           defaultMessage={translate('audit_logs.page.description.2')}
           values={{
-            housekeeping: translate('audit_logs.houskeeping_policy', housekeepingPolicy),
+            housekeeping: translate('audit_logs.housekeeping_policy', housekeepingPolicy),
             link: (
               <Link to={{ pathname: '/admin/settings', query: { category: 'housekeeping' } }}>
                 {translate('audit_logs.page.description.link')}
index 6958c37fd2acd9aa425564c066c03643e10d7037..7520c26fee4f1a21d60bdee2c48f20bb992f2b94 100644 (file)
@@ -6,7 +6,7 @@ exports[`should render correctly 1`] = `
   handleDateSelection={[Function]}
   handleOptionSelection={[Function]}
   handleStartDownload={[Function]}
-  housekeepingPolicy="monthly"
+  housekeepingPolicy="Monthly"
   selection="today"
 />
 `;
index 703fa50eae2d514f2ced14c460da7db8c69a94ff..ca6ddeeace776a15c29fb2e176dd8ba1fc908731 100644 (file)
@@ -1,6 +1,6 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
-exports[`should render correctly for monthly housekeeping policy 1`] = `
+exports[`should render correctly for Monthly housekeeping policy 1`] = `
 <div
   className="page page-limited"
   id="marketplace-page"
@@ -32,7 +32,7 @@ exports[`should render correctly for monthly housekeeping policy 1`] = `
       id="audit_logs.page.description.2"
       values={
         Object {
-          "housekeeping": "audit_logs.houskeeping_policy.monthly",
+          "housekeeping": "audit_logs.housekeeping_policy.Monthly",
           "link": <Link
             onlyActiveOnIndex={false}
             style={Object {}}
@@ -124,7 +124,7 @@ exports[`should render correctly for monthly housekeeping policy 1`] = `
 </div>
 `;
 
-exports[`should render correctly for trimestrial housekeeping policy 1`] = `
+exports[`should render correctly for Trimestrial housekeeping policy 1`] = `
 <div
   className="page page-limited"
   id="marketplace-page"
@@ -156,7 +156,7 @@ exports[`should render correctly for trimestrial housekeeping policy 1`] = `
       id="audit_logs.page.description.2"
       values={
         Object {
-          "housekeeping": "audit_logs.houskeeping_policy.trimestrial",
+          "housekeeping": "audit_logs.housekeeping_policy.Trimestrial",
           "link": <Link
             onlyActiveOnIndex={false}
             style={Object {}}
@@ -260,7 +260,7 @@ exports[`should render correctly for trimestrial housekeeping policy 1`] = `
 </div>
 `;
 
-exports[`should render correctly for weekly housekeeping policy 1`] = `
+exports[`should render correctly for Weekly housekeeping policy 1`] = `
 <div
   className="page page-limited"
   id="marketplace-page"
@@ -292,7 +292,7 @@ exports[`should render correctly for weekly housekeeping policy 1`] = `
       id="audit_logs.page.description.2"
       values={
         Object {
-          "housekeeping": "audit_logs.houskeeping_policy.weekly",
+          "housekeeping": "audit_logs.housekeeping_policy.Weekly",
           "link": <Link
             onlyActiveOnIndex={false}
             style={Object {}}
@@ -372,7 +372,7 @@ exports[`should render correctly for weekly housekeeping policy 1`] = `
 </div>
 `;
 
-exports[`should render correctly for yearly housekeeping policy 1`] = `
+exports[`should render correctly for Yearly housekeeping policy 1`] = `
 <div
   className="page page-limited"
   id="marketplace-page"
@@ -404,7 +404,7 @@ exports[`should render correctly for yearly housekeeping policy 1`] = `
       id="audit_logs.page.description.2"
       values={
         Object {
-          "housekeeping": "audit_logs.houskeeping_policy.yearly",
+          "housekeeping": "audit_logs.housekeeping_policy.Yearly",
           "link": <Link
             onlyActiveOnIndex={false}
             style={Object {}}
index f77590b1a69a3036ab6e53efebead118c723817a..47676bccb00d6775fa971efaf962764d7370e09a 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 export enum HousekeepingPolicy {
-  Weekly = 'weekly',
-  Monthly = 'monthly',
-  Trimestrial = 'trimestrial',
-  Yearly = 'yearly'
+  Weekly = 'Weekly',
+  Monthly = 'Monthly',
+  Trimestrial = 'Trimestrial',
+  Yearly = 'Yearly'
 }
 
 export enum RangeOption {
diff --git a/sonar-core/src/main/java/org/sonar/core/config/Frequency.java b/sonar-core/src/main/java/org/sonar/core/config/Frequency.java
new file mode 100644 (file)
index 0000000..4fc9ee4
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.core.config;
+
+public enum Frequency {
+  WEEKLY("Weekly", 7),
+  MONTHLY("Monthly", 30),
+  TRIMESTRIAL("Trimestrial", 90),
+  YEARLY("Yearly", 365);
+
+  final String description;
+  final int days;
+
+  public String getDescription() {
+    return this.description;
+  }
+
+  Frequency(String description, int days) {
+    this.description = description;
+    this.days = days;
+  }
+}
index aac3805f42aaaa18a33f6ddf4e7c0da686a4ea63..1bacc141d4065c4cb26989bbd376a301803872f8 100644 (file)
@@ -29,4 +29,5 @@ public interface PurgeConstants {
   String DAYS_BEFORE_DELETING_CLOSED_ISSUES = "sonar.dbcleaner.daysBeforeDeletingClosedIssues";
   String DAYS_BEFORE_DELETING_INACTIVE_BRANCHES_AND_PRS = "sonar.dbcleaner.daysBeforeDeletingInactiveBranchesAndPRs";
   String BRANCHES_TO_KEEP_WHEN_INACTIVE = "sonar.dbcleaner.branchesToKeepWhenInactive";
+  String AUDIT_HOUSEKEEPING_FREQUENCY = "sonar.dbcleaner.auditHousekeeping";
 }
index d4f18cd4e51cf18e5080187d4e1a8a0bd35bc8fa..125dff773070630a3e666da9aca253b8bb5c9ccf 100644 (file)
@@ -26,8 +26,10 @@ import org.sonar.api.config.PropertyDefinition;
 import org.sonar.api.resources.Qualifiers;
 
 import static java.util.Arrays.asList;
+import static org.sonar.core.config.Frequency.MONTHLY;
 
 public final class PurgeProperties {
+  public static final String DEFAULT_FREQUENCY = MONTHLY.getDescription();
 
   private PurgeProperties() {
   }
index 39fd1247b93ceeb68a88df79a689c14e2a4f5614..4b4bb3eaa3e75086be148746fff9681051fa1ff1 100644 (file)
@@ -693,19 +693,19 @@ sessions.log_in=Log in
 #------------------------------------------------------------------------------
 
 audit_logs.page=Audit Logs
-audit_logs.page.description.1=Audit logs help Administrators keep control and traceability of security related changes performed on the platform. 
+audit_logs.page.description.1=Audit Logs help Administrators keep control and traceability of security related changes performed on the platform. 
 audit_logs.page.description.2=Your instance is set to keep audit logs for {housekeeping}. You can change the number of days by updating your {link}. 
 audit_logs.page.description.link=housekeeping policy
 
-audit_logs.houskeeping_policy.weekly=7 days
-audit_logs.houskeeping_policy.monthly=30 days
-audit_logs.houskeeping_policy.trimestrial=90 days
-audit_logs.houskeeping_policy.yearly=one year
+audit_logs.housekeeping_policy.Weekly=7 days
+audit_logs.housekeeping_policy.Monthly=30 days
+audit_logs.housekeeping_policy.Trimestrial=90 days
+audit_logs.housekeeping_policy.Yearly=one year
 
-audit_logs.download=Download audit logs
+audit_logs.download=Download Audit Logs
 audit_logs.download_start.try_again=Try Again
 audit_logs.download_start.sentence.1=Your download should start shortly. For longer periods this might take some time.
-audit_logs.download_start.sentence.2=If the download doesn’t start after a few seconds, contact your administrator.
+audit_logs.download_start.sentence.2=If the download doesn’t start after a few seconds, try to reduce the period for which you are fetching audit logs.
 audit_logs.download_start.sentence.3=Change your selection above to download additional audit logs.
 
 audit_logs.range_option.today=Today
@@ -1300,6 +1300,7 @@ property.category.scm=SCM
 property.category.housekeeping=Housekeeping
 property.category.housekeeping.general=General
 property.category.housekeeping.branchesAndPullRequests=Branches and Pull Requests
+property.category.housekeeping.auditLogs=Audit Logs
 
 
 #------------------------------------------------------------------------------
index 9911d89b275c5ff98d92f087b55315b7a01c56cf..15a845721ff5e3b329c3d728387a144367755f53 100644 (file)
@@ -65,6 +65,10 @@ public interface CoreProperties {
    * @since 8.1
    */
   String CATEGORY_HOUSEKEEPING = "housekeeping";
+  /**
+   * @since 9.1
+   */
+  String CATEGORY_AUDIT_LOGS = "auditLogs";
 
   /**
    * @since 6.6