dotTest 10.3 - Is it possible to edit a rule.
Hi,
dotTest 10.3 - Is it possible to edit a rule. Similarity to C++test ?
Is it possible to do it from the IDE ?
Thanks In Advanced,
Best Answers
-
Piotr Krukowiecki Posts: 10 ✭✭
Hello,
most of dotTEST rules are NOT RuleWizard rules and can not be edited (except for parametrization/cloning/changing severity etc).
There are some RuleWizard rules though. They can be edited with RuleWizard. There is no support in IDE (Visual Studio). The workflow would be like this:
- download RuleWizard tool from Parasoft Marketplace
- copy original rule from INSTALL_DIR\bin\dottest\dotnet\Rules to user (custom) rules directory
- rename the copied rule, edit it with RuleWizard and update it's rule id and make modifications you want
- enable new rule id in a test configuration
6 -
mrybak Posts: 5 ✭
Hi @elch,
As Piotr wrote, you can edit only a limited set of rules, and if you want to for example add new parameter to rule please refer to his answer, as he described it accurately.If you want to modify data passed to rule parameters, you can do it in 3 ways.
- by DTP - you can create/edit test configurations on DTP, where you are provided with GUI.
- by editing test configuration manually - can be done even in notepad, but it's prone to mistakes. I'd suggest you to do it only if you're familiar with dotTEST and rules parameters.
- by Test Configuration Editor (since dotTEST 10.4) - it's similar to DTP, but offline, available from Visual Studio plugin.
5 -
Piotr Krukowiecki Posts: 10 ✭✭
I got an error when tried to edit a rule from 10.3.3. dotTest. The Error was Unknown rule type .NET.
Which rule have you tried to open? I opened one rule from each directory without any errors.
I'm assuming you are opening the rules on Windows, and you start RuleWizard using ParasoftRuleWizard.bat
How can I link between rule name in report , for example SEC.... to the name of rules files ?
You can search .xml files in the bin\dottest\dotnet\Rules dir.
For example searching for "SEC.ASNRF" returns following entry:
<rule header="Inspect static fields that are not readonly and consider making them readonly" id="ASNRF" impl="SEC.ASNRF" quickfix="false" scope="line" severity="4"> <file path="security\Security-10_StaticReadOnly.rule"/> </rule>
The
<file path="..."
is the actual implementation file of the rule "SEC.ASNRF"5 -
Piotr Krukowiecki Posts: 10 ✭✭
I can not find in my version 10.3.3 the rule SEC.LGE-2 ? very wiered.
Any suggestions ? BTW can I edit it ?Unfortunately, SEC.LGE is not a RuleWizard rule so it can not be edited.
5 -
Piotr Krukowiecki Posts: 10 ✭✭
Easiest way is to configure it using DTP, or edit it in Parasoft plugin for Visual Studio - starting with version 10.4.0 there is a graphical editor for test configurations.
Editing properties file with text editor is also possible and generally setting "rule_id=true" should enable rule with "rule_id" id. There are some additional settings required - you can use TestConfigTemplate.properties as a base for your config (or some other builtin test config as well).
But much harder if the rule is parametrized and you want to change the parameters. In that case, it's much butter to use DTP or VS plugin.
5 -
Piotr Krukowiecki Posts: 10 ✭✭
I'm sorry, I don't know why it does not work. It should. Could you please contact our support for more detailed investigation?
5
Answers
Hi @elch,
Could you please clarify what do you mean as "editing"? Do you mean rule parametrization, cloning/renaming rules, creating new ones or changing behavior of current ones?
Hi @mrybak
Thanks
Hi @Piotr Krukowiecki
Thanks for the detailed answer.
I downloaded the latest Rule wizard application 10.3.4.
I got an error when tried to edit a rule from 10.3.3. dotTest. The Error was Unknown rule type .NET.
Thanks
Hi @Piotr Krukowiecki
Thanks on your support.
Ok , Rule wizard is operating , it was missing some files.
I can browse the xml files.
I can not find in my version 10.3.3 the rule SEC.LGE-2 ? very wiered.
Any suggestions ? BTW can I edit it ?
Thanks
Hi @Piotr Krukowiecki
We had some issues with this rule as it raising an error that catch has no logger operation inside the catch.
we have Serilog logger , the rule does not recognize such logger. the logger has different logger methods , such as logger
So Do you think setting up a new rule can resolve this issue ?
thanks
Hi @Piotr Krukowiecki
I want to edit SEC.LGE rule because it is raising a lot of false alarms on missing logger.
We are using for example Serilog logger , It seems the scan does not recognize _logger.Error( ex, "dd") methods in the catch .
Any suggestions how to resolve the issue ?
Thanks
Hi @elch,
please make sure that rule parameters are correctly set up and that the _logger.Error call should be recognized as "log" method based on parameters definition.
If you believe rule parameters are correctly set up, could you please provide compilable/simplified code which shows the problem?
Hi @Piotr Krukowiecki
Can you please tell what are the steps to check if I setup the rule correctly.
I just set it to TRUE in my properties file.
Am i missing something ?
thanks
Hi @Piotr Krukowiecki
OK , got it,
It can be editable except for some rules like SEC.LGE ?
Thanks
Hi @Piotr Krukowiecki
I tried to edit SEC.LGE parametres by editing rule properties.
SEC.LGE.CheckExceptionPassing=true
SEC.LGE.logtypesandmethodes=.[lL]logger;.*
Is it possible to do so in 10.3 or 10.4? I tried in both version and the engine still does not consider loggers such as Serilog _logger.Error( ex, "dd") .
Thanks
Hi @elch
I see a couple things that need to be changed:
1. "[" and "]" must be encoded
2. use ";" as separator
For example to set following two patterns:
1.
Full Type Name Pattern: .[lL]logger.
Method Name Pattern: .Log.
2.
Full Type Name Pattern: SomeOtherFullTypeNamePattern
Method Name Pattern: SomeOtherMethodNamePattern
You should use following entry in .properties file:
SEC.LGE.LogTypesAndMethods=.*%5BlL%5Dlogger.*;.*MethodName.*;SomeOtherFullTypeNamePattern;SomeOtherMethodNamePattern
(that should be one line of course)
PS. Are you sure your pattern should be "[lL]logger" ? That will match "Ilogger" and "Llogger" (case sensitive).
Hi @Piotr Krukowiecki
Thanks on your answers, Yes you are correct it should be: .[lL]og.
My log syntax is:
catch(
exception ex)
{
_logger.Error( ex, "there was an error.....", );
return Something();
}
I am trying to suppress by rule parameters this validation.
Any suggestions.
Thanks
What is the type of _logger and what are your SEC.LGE settings?
Hi @Piotr Krukowiecki
My settings are:
SEC.LGE.CheckExceptionPassing=true
SEC.LGE.logtypesandmethodes=.[lL]ogger;.
Please, you didn't answer my question about the type of _logger.
Also, your pattern looks wrong:
1. did you really mean the dot at the beginning?
".[lL]ogger" will not match "Logger" for example (will match xLogger etc)
2. you did not encode the square brackets
Assuming you want to accept types which have "logger" or "Logger" in it's fully qualified name, the regex pattern would be: "[lL]ogger" and in the .properties test configuration you should have following:
Hi @Piotr Krukowiecki
I am sorry on my delay , What do you mean by What is the type of _logger" ?
I tired the above settings and still the rule does not exclude:
_logger.Error( ex, "there was an error.....", );
Any suggestions
Thanks
Hi @Piotr Krukowiecki
After upgrading dotTest 10.4.
Can you please provide for to whom I need to send issues with the rules ?
To support ? mail ?
Thanks