Introduction
Our rules engine provides a powerful tool to help customize your application to your needs. This article will be a one-stop guide to everything drools related to allow you the ability to efficiently self-serve.
What is a rule?
Rules are pieces of knowledge often expresses as "When certain conditions occur, then do some tasks".
These take the following format.
rule <rule_name>
<attribute> <value>
When
<Condition is True>
Then
<Take desired Action>
end
The official Drools documentation recommends avoiding the use of getters inside the when block.
"We recommend using property access (age) over using getters explicitly (getAge()) because of performance enhancements through field indexing."
Writing drools
First, a word of warning.
Alt text: WARNING: The correct functioning of custom Drools code introduced here is the responsibility of the author. Custom code will be ignored by IriusRisk''s migration system, which could lead to errors after upgrading your IriusRisk instance.
Modules
The first step to writing great drools is to start with understanding the modules we place the drools inside. These are more than just names to group rules by as there is Hidden rules logic which depend on correct placement of the drool to obtain the behavior you expect.
We advise beginners to first create a rule inside the rules editor. This is available at Rules > Rules Editor.
A comprehensive guide on the conditions/actions outlined in this are available here. Rules Explanation
From here, we can modify the rule to meet our custom needs inside the drools engine with logic not available inside the rules editor. Simply navigate to Drools & find the rule you created, paying close attention to the module it is in.
More advanced users can create drools from scratch.
Drools |
Rules Editor / Workflow Rules |
Notes |
---|---|---|
|
- |
Included in all the modules. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Packages
Below are the following packages that we can make use of when creating custom drools.
Irius Core:
our domain packages to create Drools
package com.iriusrisk.drools;
-
com.iriusrisk.drools.*
-
com.iriusrisk.factories.*
-
com.iriusrisk.utils.*
-
com.iriusrisk.model.*
-
com.iriusrisk.common.*
-
com.iriusrisk.AccessType.*
Main
This takes knowledge from the project level and produces the actions to create components, import templates etc.
ProjectFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
ProjectCustomFieldFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
Modifiers:
modify($customFieldVar) {setValue(String value)}
ThreatFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QuestionFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Insert:
insertLogical(new QuestionFact(...<<See constructors below>>...));
Constructors |
---|
|
|
|
|
|
|
|
Modify:
modify($questionToAnswer) { setAnswer(boolean value) };
QuestionGroupFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Insert:
insertLogical(new QuestionGroupFact(<<See constructor>>))
Constructor |
---|
|
|
|
|
|
|
Conclusion
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
Insert:
insertLogical(new Conclusion(ConlusionType type, String String id, String text));
- HIDDEN
- ERROR
- ALERT
- WARNING
- INFO
- ADVICE
- POLICY
- MANDATORY
UserEvent
Getters:
Modifier and Type |
Method |
---|---|
|
|
TemplateUniqueId
Insert:
insertLogical(TemplateUniqueId.importTemplate(String String templateUniqueId));
Notification
Insert:
insertLogical(new com.iriusrisk.drools.model.Notification(Notificationtype type, String id, String text));
Notification Types:
- ALERT
- WARNING
- INFO
AssignProjectToBusinessUnitDto
Insert:
insertLogical(new com.iriusrisk.drools.model.project.AssignProjectToBusinessUnitDto(String projectRef, String businessUnitRef));
AssignProjectToUserDto
Insert:
insertLogical(new com.iriusrisk.drools.model.project.AssignProjectToUserDto(String projectRef, String userName));
GenerateReportActionEvent
Insert:
insertLogical(String projectRef, Integer reportTypeValue, String format, String standardId));
insertLogical(String projectRef, Integer reportTypeValue, String format, String standardId));
standardId must be null except for Compliance report
ImportRiskPatternFactory
Insert:
insertLogical(ImportRiskPatternFactory.importSpecificProjectRisk(String libraryRef, String refPattern, String refUseCase, String refRisk, int priority));
ChangeProjectCountermeasureStateFact
Insert:
insertLogical(ChangeProjectCountermeasureStateFact.createImplementation(String uniqueId, Boolean overrideManualActions));
CreateComponentModel
Insert:
insertLogical(new CreateComponentModel(String componentDefinitionRef, String trustZoneUuid, Boolean isPersistent));
this is the end of the Main module drools documentation
Threat Model
This feeds on knowledge at the components and dataflow level and produces the actions to import risk patterns, apply security standards etc.
ProjectFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
ProjectCustomFieldFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
Modifiers:
modify($customFieldVar) {setValue(String value)}
ComponentFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
ComponentDefinitionFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
ComponentQuestionFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Insert:
insertLogical(new ComponentQuestionFact(...<<See constructors below>>...));
Constructors |
---|
|
|
|
|
|
|
|
DataFlowFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
DataFlowAssetFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
TrustZoneFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
SecurityClassificationFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
TagFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
ExternalQuestionFact
Getters:
Type is always ExternalQuestionFact.SUPPLEMENTAL
for main questionnaire questions
Modifier and Type |
Method and Description |
---|---|
|
|
|
|
|
|
Modifiers:
modify($questionToAnswer) { setAnswer(boolean value) };
ComponentQuestionGroupFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Inserters:
insertLogical(new ComponentQuestionGroupFact(<<See constructor>>))
Constructor |
---|
public ComponentQuestionGroupFact(java.lang.String id,
java.lang.String name,
java.lang.String text,
int priority,
java.lang.Boolean singleSelect,
java.lang.Boolean required,
java.lang.String description,
java.lang.String componentReferenceId)
|
Modifiers:
modify($questionToAnswer) { setAnswer(boolean value) };
Conclusion
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
Insert:
insertLogical(new Conclusion(ConclusionType type, String id, String text));
insertLogical(new Conclusion(ConclusionType type, String id, String text, String componentReferenceId));
Conclusion Types
- HIDDEN
- ERROR
- ALERT
- WARNING
- INFO
- ADVICE
- POLICY
- MANDATORY
ImportWholeRiskPatternAwareDto
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
ImportRiskPatternFactory
Inserters:
insertLogical(ImportRiskPatternFactory.importRiskPattern(String targetComponentRef, String libraryRef, String riskPatternRef, int priority));
insertLogical(ImportRiskPatternFactory.importRiskPatternInOrigin(String libraryRef, String productRef, String riskPatternRef, String targetRef, int priority, String dataFlowRef));
insertLogical(ImportRiskPatternFactory.importRiskPatternInDestination(String libraryRef, String productRef, String riskPatternRef, String targetRef, int priority, String dataFlowRef));
insertLogical(ImportRiskPatternFactory.importSpecificRisk(String targetComponentRef, String libraryRef, String refPattern, String refUseCase, String refRisk, int priority));
insertLogical(ImportRiskPatternFactory.importSpecificUseCase(String targetComponentRef, String libraryRef, String refPattern, String refUseCase,
int priority));
ChangeComponentCountermeasureStateFact
Inserters:
insertLogical(ChangeComponentCountermeasureStateFact.createRequirement(String componentReferenceId, String countermeasureUniqueId, Boolean overrideManualActions));
insertLogical(ChangeComponentCountermeasureStateFact.createImplementation(String componentReferenceId, String countermeasureUniqueId, Boolean overrideManualActions));
insertLogical(ChangeComponentCountermeasureStateFact.createImplementation(String countermeasureUniqueId, Boolean overrideManualActions)); // for general product threats
ComponentNotification
Inserters:
insertLogical(new com.iriusrisk.drools.model.ComponentNotification(NotificationType type, String id, String text, String componentRef));
Notification Types
- ALERT
- WARNING
- INFO
RiskMitigationModifier
Inserters:
insertLogical(RiskMitigationModifier.setMitigationValue(String targetComponentRef, String libraryRef, String riskPatternRef, String threatRef, String conuntermeasureRef, String mitigation"));
SecurityStandard
Inserters:
insertLogical(new SecurityStandard(String targetComponentRef, String standardName, String standardRef, boolean overrideCountermeasureManualActions));
Highly recommended to properly notify this action including also this two actions:
insertLogical(new ComponentNotification(NotificationType.INFO, "apply.standard." + standardName, "apply.standard.msg," + standardName, targetComponentRef, true));
insertLogical(new Conclusion(ConclusionType.POLICY, "id-" + standardName, "security.standard.will.apply", targetComponentRef, standardName));
this is the end of the Threat model drools documentation
Threat
This feeds on the same facts as the threat model session plus the threat & countermeasures resulting from the threat model session actions.
ThreatCustomFieldFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Modifiers:
modify($customFieldVar) {setValue(String value)};
CountermeasureCustomFieldFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Modifiers:
modify($customFieldVar) {setValue(String value)};
ThreatFact
Getters:
Modifier and Type |
Method and Description |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CountermeasureFact
Getters:
Modifier and Type |
Method and Description |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Modifiers:
modify($countermeasureVar) {changeState(String state**, String reason, boolean overrideManualActions)};
** The state parameter is case-sensitive and must be indicated as how the state is displayed in the UI selector for countermeasure state.
ThreatCountermeasureFact
Getters:
Modifier and Type |
Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Modifiers:
modify($threatCountermeasureVar) {setMitigationValue(Integer value), setModifiedByRules(true)};
This is now the end of the Threat section
Comments
0 comments
Article is closed for comments.