remove/delete existing from sonarqube - sonarqube

I am new to sonarqube and was able diable/deactivate default rules that comes with sonar. However I would like to know if there is a way to delete/remove default rules from sonar ?

yes of course you can disable some rules and change the level (major, minor etc) in the admin console of your sonarqube and you can use a custom quality profile with a selected rules to analyse you project
http://docs.sonarqube.org/plugins/servlet/mobile#content/view/6964603

Log in as Admin.
Through Quality profile we will be able to activate and deactivate the default rules.
3.Ability to create a new profile with specific rules and scan the project with this new profile.

The following worked for me:
Log in as admin
Set another profile as default, i.e. not the one you want to remove.
Now the non-default profile will be deletable.

Related

How to prevent SonarQube not check specific vulnerability

I have some code that want to SonarQube not check this vulnerability while every deployment.
Any method for add rule for not check X type vulnerability with some error text ?
I found an answer and want to inform for who need answer
https://sqa.stackexchange.com/questions/24734/how-to-deactivate-a-rule-in-sonarqube
Need to copy existing SonarQube built-in profile and deactivate/add new rule in new profile,
after that go to project settings and change Quality Profile.

Apply custom permission template automatically for sonarqube new project report using sonar-runner

How to configure sonar.projectKey under sonar-project.properties so that we can get apply custom permission template for new project report automatically.
Does anyone try that?
I was trying all type of combination with project key in sonarqube permission template and sonar-runner properties file. But couldn't achieve the result.
Does sonar permission template really support this from sonar-runner.
Below are screenshot attached to the link for my use case:
I have created mfg-desktop permission template and there is also present a default template provided by sonar
When I checked under project permission, I found that default permission template is getting applied in each time
There's nothing to do on the sonar-project.properties side.
As described in the docs, set up your permission template with a project key pattern regular expression. All new projects with keys that match the regex will have that permission template applied.
For example, if in the "Manufacturing Group" template I set my Project Key Pattern to:
mfg-*
and analyze a new project with a key of mfg-extrusion, then the "Manufacturing Group" template will be applied. And when I analyze front-office-billing for the first time, it will not.
Create a new permission Template and assign the regex to the Project Key Pattern.
For example:
Regex :
(prod)-\w+
It will apply the template to the new projects created with Project Key starting with 'prod-'. Sonar needs the key of the new projects to 'fully' match the regex of the permission template key. Using * might not work.
Then link the desired permissions of the users/group on the template. Also make sure the Global Permissions for the users/group are also set appropriately else permissions wont work.
Additional Info: All projects will still be visible to all users. Make your project 'Private' to make it visible only to the required group.
This works on CE v7.6

Why property "sonar.profile" marked as deprecated?

I am looking for a Sonar Property to attach the quality profile during the build. In previous versions of Sonar there was a property -Dsonar.profile which is deprecated now. Can anyone please help me to get the property to attach the quality profile at runtime.
I am using Sonar version 4.5.7. Any help is highly appreciated.
Thanks,
Sanjiv
It has been marked as deprecated with no replacement.
Quoting page http://docs.sonarqube.org/display/SONARQUBE43/Analysis+Parameters :
Note that only parameters set through the UI are stored in the
database. For example, if you override the sonar.profile parameter via
command line for a specific project, it will not be stored in the
database. Local analyses in Eclipse, for example, would still be run
against the default quality profile.
And the latest version of the same page http://docs.sonarqube.org/display/SONAR/Analysis+Parameters has link to ticket about deprecation that contains other details - https://jira.sonarsource.com/browse/SONAR-5370
In other words - profile should be configured via UI or using web services.

Can anyone help me in exporting Sonarqube rules which are Inactive using Web API?

I'm currently using SonarQube v5.6 and I'm trying to export the list of the rules that are inactive.
We can take "BackUp" of the rules that are active through the UI, but I'm trying to do this using Web API supported by Sonarqube on command line.
For Example:
I'm trying to export the rules which are not active in sonarqube:
http://$sonarqubeServer/coding_rules#qprofile=$key|activation=false
Can anyone please help me how to go about this ?
SonarQube Web API is pretty well documented (accessible from the footer of your server). api/rules offers api/rules/search which takes a bunch of parameters, including:
activation - Filter rules that are activated or deactivated on the selected Quality profile. Ignored if the parameter 'qprofile' is not
set.
qprofile - Key of Quality profile to filter on. Used only if the parameter 'activation' is set.
Bottom line, this request in the UI:
https://sonarqube.com/coding_rules#activation=false|qprofile=js-sonar-way-56838
Is equivalent to this Web API request:
https://sonarqube.com/api/rules/search?activation=no&qprofile=js-sonar-way-56838

How to hide TeamCity configuration for selected users?

I have one TeamCity project Dac.Test that contains 3 configurations: DEV, QA, PROD.
Also I have some users associated with their Roles. Is this possible to hide / show certains configurations for selected users or groups?
For example: Users associated with group: Testers can see QA configuration, but not PROD and DEV.
There is no way of managing user permissions per-build, this is available on a project level only. You could create a sub-project in the Dac.Test project to cater for this
If you're looking for a way of stopping people from mistakenly running this build, the following approach will work.
This method uses a prompt box that will pop up after you click the run button, it also needs input from the user confirming that they mean to run the build.
No one can run this build by accident
Go to your build configuration in the TeamCity UI
From here, go to Edit Configuration Settings --> Parameters --> Add new parameter
Enter something like 'Confirmation' as the parameter name
Then beside 'Spec:', click the 'Edit...' button
Set up the parameter as shown in the following screenshot:
You will now be prompted and asked for confirmation when you click the run button. The user will have to enter 'YES' in the prompt box that appears, any other value will stop the user from building:
This is best accomplished by using TeamCity's built-in role management. Roles allow you to set fine-grained permissions for users and groups. One potential issue, however, is that roles are scoped to projects (not build configurations). You'll need to create a separate Dac.Test QA project+configuration and provide your Testers the necessary privileges there. You'll also need to make sure that they are stripped of all privileges for the Dac.Test project.

Resources