"c++" argument not accepting by SonarQube Web API - sonarqube

I have a use case where I upload a C++ quality profile in SonarQube 7.X (LTS version) and then:
Search for it.
Set it as default quality profile.
I have no problem in uploading the quality profile to SonarQube portal.
However, when I try to search for it using the /search API and set it as default using /set_default API, the parameter 'language' does not accept 'c++' value.
It gives response to use 'c++' as language and that I only provided value 'c' as request.
It seems it is unable to process '+' sign in 'c++'.
Is there any alternative for this approach.
(Also, when I do not provide any language while searching for profiles, a 'c++' language profile that I uploaded is received as response to verify that my profile is uploading OK)

+ is a special character in URL meaning a space. If you need to have a literal +, you would probably need to urlencode it as c%2B%2B

Related

How to poll the quality gate execution status?

I would like to poll the quality gate execution status of my SonarQube 6.3 instance using a REST api call. I went through a few api calls, which did not give me the expected results.
I tried to use these urls:
http://localhost:9000/api/resources
http://localhost:9000/api/components
But I always got this response:
{"errors":[{"msg":"Unknown url : /api/resources"}]}
How can I poll the quality gate execution status via REST?
http://localhost:9000/web_api lists the web service endpoints available on your server and provides documentation for each one. In my copy of 6.3, the documentation for "api/resources" says
Removed since 6.3, please use api/components and api/measures instead
You say you've tried http://localhost:9000/api/components and gotten an error. That's because there's not actually a web service there. You'll have to add the qualifier for the service you want, such as /api/components/search, as described in the docs for that set of services: http://localhost:9000/web_api/api/components
In fact there are 5 parts in a correct SonarQube web api url. They can be seen like that domain/api/controller/action?parameters, for example http://localhost:9000/api/components/show?componentKey=blue.
So we have:
domain: which is represented by http://localhost:9000 in the example, it is the address where you can call your SonarQube server
api: which is represented by /api in the example, it is the base path of all web service in SonarQube
controller: which is represented by /components in the example, it represents a pool of web service concerning a given theme (issues, profiles, components, etc.)
action: which is represented by /show in the example, it is a unit action that you can perform through the web service, for example: show, search, list, backup, delete, etc.
parameters: which is represented by ?componentKey=bluein the example, they are not always mandatory but often allow you to specify further information to get more precise results
What you have forgotten here is at means to specify an action.
http://localhost:9000/api/project_analyses/search?project=myProjectname&category=QUALITY_GATE
This query returned the status of my quality gate. Here I have mentioned the project name as myProjectname

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

whatweb doesn't check internal urls except '/' that listed under matches

I am new to whatweb and I want to create my own plugin, I saw many plugins that use md5 on pictures of the website.
For example Moxax-NPort-Device:
{ :md5=>"27829d70bb23c465d86b9c643cf534d3", :url=>"/logo.gif" },
{ :md5=>"2f9af91da3dc3f192e26ac8f42db41bd", :url=>"/logo.gif" },
The problem that I found out is that, whatweb doesn't check those urls, I used wireshark and saw that there are no requests to there, moreover I tried to leave only those checks and whatweb stopped recognize Moxax-NPort-Device.
When I use my own plugin I can check on md5 of '/' but not on '/loginback.jpg' for example.
Thanks
WhatWeb will follow URLs specified with :url within a matching hash when:
Aggressive mode (-a 3) is used and the plugin has already matched.
Aggressive mode (-a 4) is used regardless of whether the plugin has already matched.
By default WhatWeb uses passive mode (-a 1). This does not follow additional URLs.
See the following resources for more information:
https://github.com/urbanadventurer/WhatWeb/wiki/Writing-WhatWeb-Plugins
https://github.com/urbanadventurer/WhatWeb/wiki/How-to-develop-WhatWeb-plugins

Apache JMeter: "Test Script Recorder" - Patterns to include / exclude not actual

In my JMeter application, it seems that my settings for black- and whitelisting of patterns isn't always up-to-date when I start the recording. E.g. I get .gif files back in my recordings list, although i set it in my exclude (blacklist) settings with .*.gif
Also the suggested excludes won't influence the recording.
edit
The problem seem not to be the regexes, but the setting itself. It seems that they aren't always actual. E.g. if I set the default backlist-values via the "suggested excludes" button, the values aren't filtered out in the next recording. It seems to update the black/ whitelist settings not always automatically. Could this be and how can I force the use of the changed lists?
The correct pattern for excluding .gif files should look like .*\.(gif) as URL Patterns to Include/Exclude" inputs expect PCRE (Perl Compatible Regular Expressions)
See Regular Expressions chapter of the JMeter's User Manual for additional information on regular expressions and JMeter's Superpower: The HTTP Proxy Server for some real-life examples.

Gmail contextual gadget: are custom extractors obsolete?

The situation is as follows: there is a gmail contextual gadget, which requires access to two fields simultaneously: MessageID and sender’s email. Standard extractors seem not to support multiple fields, so I use a custom extractor. The problem is, it just doesn’t work.
It seems I do something wrong during extractor upload and registration. So far as I get it, one must (1) upload an extractor using Google Apps Extensions Console (as described here: https://developers.google.com/google-apps/extensions-console/?csw=1#extractor), and then (2) one specifies its url, parameter name, and parameter value in Google Apps Marketplace SDK when configuring gmail contextual gadget (mentioned here https://developers.google.com/apps-marketplace/preparing).
Depending on what I enter on the step (2), the result is either that the contextual gadget never appears at all, or that the contextual gadget is triggered but only one field value is available (namely, the one I specified in ‘parameter name’/’parameter value’)
What am I doing wrong? It seems strange that I specify one parameter name/value in Google Apps Marketplace SDK when there are in fact several parameters. Is there another way to register a custom extractor? Or are custom extractors obsolete, being substituted by something newer?
With google contextual gadgets you may use multiple fields. I got it working a few days ago:
After you've enabled the Universal Extensions and COB extensions accordings to this document
Add each extractor you want separately.
For each extractor:
On the extractor url it's the google.com:xxxxxExtractor url
For the gadget URL use your gadgets URL
I got it working by leaving the Extractor param name empty as well as the Extractor param value, because my use case has no need for them at the moment
UPDATE
Afterwards I had to use the Extractor param name and Extractor param value, they have the small caveat that if you specify them for ONE extractor you have to specify them for ALL of them. As well as using the Output Fields as the Param Name indicated in the table here. I only used a single param name for each extractor.
In your gadget.xml
Add a comma separated entry for each extractor url you're adding in the developers console.
<Require feature="google.contentmatch">
<Param name="extractors">google.com:XXXXExtractor,google.com:YYYYExtractor</Param>
</Require>
Remember to make sure you're using the same Gadget Url for every extractor entry and to append nogadgetcache=1 in the Gmail window in order to debug the behavior.
Remember to also enable access to the newly extracted field in your domain's console in the Data Access area of the app. New fields will require new permissions and they won't work unless specifically allowed.
I never got a custom extractor to work that would output more than one value to gadget for old marketplace. Secondly, I never got a custom extractor to work at all for new marketplace.
You could try to parse the message ID from window URL and still filter on the sender's email. but I honestly never tried this approach.

Resources