From ee231271cf60272f2e10dc6eeba37e0cc852e49a Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 27 Jun 2013 15:12:25 +0200 Subject: [PATCH] SONAR-4397 Minor label changes and default groups for dryrun and scan --- .../resources/org/sonar/l10n/core.properties | 10 +++--- .../sonar/batch/bootstrap/BatchSettings.java | 2 +- .../org/sonar/batch/scan/ModuleSettings.java | 2 +- .../org/sonar/core/persistence/rows-h2.sql | 9 ++---- .../controllers/batch_bootstrap_controller.rb | 32 +++++++++---------- 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index f34e77b5cb7..4e3eeafbdd5 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -2208,10 +2208,10 @@ global_permissions.profileadmin=Quality Profile Administration global_permissions.profileadmin.desc=Ability to perform any action on the quality profiles. global_permissions.sharedashboard=Dashboard Sharing global_permissions.sharedashboard.desc=Ability to share dashboards that any user will be able to follow. -global_permissions.scan=Ability to execute some Sonar analysis -global_permissions.scan.desc=Permission required to execute a Sonar analysis. This permission allows to get all settings (even the secured ones like scm account password, jira account password, ...) required to execute all Sonar plugins. -global_permissions.dryrun=Ability to execute some local (dry run) Sonar analysis -global_permissions.dryrun.desc=Permission required to execute a local (dry run) Sonar analysis without pushing the results to the Sonar server. This permission allows to get all settings required to execute all Sonar plugins except the secured one like scm account password, jira account password... This permission is required for instance to execute a local Sonar analysis in Sonar Eclipse. +global_permissions.scan=SonarQube analysis execution +global_permissions.scan.desc=Ability to execute SonarQube analyses. This permission allows to get all settings (even the secured ones like scm account password, jira account password, ...) required to execute all SonarQube plugins. +global_permissions.dryrun=Local (dry run) SonarQube analysis execution +global_permissions.dryrun.desc=Ability to execute local (dry run) SonarQube analyses without pushing the results to the SonarQube server. This permission allows to get all settings required to execute all SonarQube plugins except the secured one like scm account password, jira account password, ... This permission is required for instance to execute a local SonarQube analysis in SonarQube Eclipse. #------------------------------------------------------------------------------ # @@ -2245,4 +2245,4 @@ errors.is_not_valid={0} is not valid # HELP # #------------------------------------------------------------------------------ -markdown.helplink=Markdown Help \ No newline at end of file +markdown.helplink=Markdown Help diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchSettings.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchSettings.java index fc2faf0a343..c4fc318d3fe 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchSettings.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchSettings.java @@ -140,7 +140,7 @@ public class BatchSettings extends Settings { protected void doOnGetProperties(String key) { if (dryRun && key.endsWith(".secured") && !key.contains(".license")) { throw new SonarException("Access to the secured property '" + key - + "' is not possible in local (dry run) SonarQube analysis. The SonarQube plugin accessing to this property must be deactivated in dry run mode."); + + "' is not possible in local (dry run) SonarQube analysis. The SonarQube plugin which requires this property must be deactivated in dry run mode."); } } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java index bae7e8e69ff..0b37d00077c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java @@ -114,7 +114,7 @@ public class ModuleSettings extends Settings { protected void doOnGetProperties(String key) { if (this.dryRun && key.endsWith(".secured") && !key.contains(".license")) { throw new SonarException("Access to the secured property '" + key - + "' is not possible in local (dry run) SonarQube analysis. The SonarQube plugin accessing to this property must be deactivated in dry run mode."); + + "' is not possible in local (dry run) SonarQube analysis. The SonarQube plugin which requires this property must be deactivated in dry run mode."); } } } diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index 4d643553f1e..1aa4cda1fef 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -7,12 +7,9 @@ ALTER TABLE GROUPS ALTER COLUMN ID RESTART WITH 3; INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (1, 1, null, 'admin'); INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (2, 1, null, 'profileadmin'); INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (3, 1, null, 'sharedashboard'); -INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (4, 1, null, 'scan'); -INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (5, null, null, 'scan'); -INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (6, 1, null, 'dryrun'); -INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (7, 2, null, 'dryrun'); -INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (8, null, null, 'dryrun'); -ALTER TABLE GROUP_ROLES ALTER COLUMN ID RESTART WITH 9; +INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (4, null, null, 'scan'); +INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (5, null, null, 'dryrun'); +ALTER TABLE GROUP_ROLES ALTER COLUMN ID RESTART WITH 6; INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 1); INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 2); diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb index 6c2f9c93084..4c6de01d129 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb @@ -27,14 +27,14 @@ class BatchBootstrapController < Api::ApiController # GET /batch_bootstrap/db?project= def db has_dryrun_role = has_role?(:dryrun) - return render_unauthorized("You're not authorized to execute a dry run analysis. Please contact your Sonar administrator.") if !has_dryrun_role + return render_unauthorized("You're not authorized to execute a dry run analysis. Please contact your SonarQube administrator.") if !has_dryrun_role project = load_project() - return render_unauthorized("You're not authorized to access to project '" + project.name + "', please contact your Sonar administrator") if project && !has_role?(:user, project) + return render_unauthorized("You're not authorized to access to project '" + project.name + "', please contact your SonarQube administrator") if project && !has_role?(:user, project) db_content = java_facade.createDatabaseForDryRun(project ? project.id : nil) send_data String.from_java_bytes(db_content) end - + # GET /batch_bootstrap/properties?[project=][&dryRun=true|false] def properties dryRun = params[:dryRun].present? && params[:dryRun] == "true" @@ -43,22 +43,22 @@ class BatchBootstrapController < Api::ApiController return render_unauthorized("You're not authorized to execute any SonarQube analysis. Please contact your SonarQube administrator.") if (!has_dryrun_role && !has_scan_role) return render_unauthorized("You're only authorized to execute a local (dry run) SonarQube analysis without pushing the results to the SonarQube server. Please contact your SonarQube administrator.") if (!dryRun && !has_scan_role) - + keys=Set.new properties=[] - + # project properties root_project = load_project() - return render_unauthorized("You're not authorized to access to project '" + root_project.name + "', please contact your Sonar administrator") if root_project && !has_role?(:scan) && !has_role?(:user, root_project) - + return render_unauthorized("You're not authorized to access to project '" + root_project.name + "', please contact your SonarQube administrator") if root_project && !has_role?(:scan) && !has_role?(:user, root_project) + if root_project - # bottom-up projects - projects=[root_project].concat(root_project.ancestor_projects) - projects.each do |project| - Property.find(:all, :conditions => ['resource_id=? and user_id is null', project.id]).each do |prop| - properties< ['resource_id=? and user_id is null', project.id]).each do |prop| + properties< JSON(json_properties) @@ -82,7 +82,7 @@ class BatchBootstrapController < Api::ApiController end private - + def render_unauthorized(message, status=403) respond_to do |format| format.json { render :text => message, :status => status } -- 2.39.5