Skip to content

Write a new Rule in PacBot

KanchanaAradhya edited this page Jan 8, 2019 · 41 revisions

PacBot user has to perform below steps to write new rule.

  1. Create Rule class using any editor

  2. Configure Policy/Rule from PacBot Admin page

  3. Visualize Rule compliance using PacBot generic Dashboards

Troubleshooting : If you are not able to see the rule result then go to troubleshoot page

Create Rule Class

Create Federated Custom Rule in PacBot

To create federated custom rule in pacbot follow below steps.

Step 1:

Go to Eclipse(Package Explorer)-->Right click-->New-->Maven-->Maven Project

Step 2:

Add below dependencies in your pom.xml

1.Add the batch common dependency

2.Rule engine dependency

Step 3:

1.Create a java class and extend the BaseRule class from the batch commons

2.Override the execute and getHelpText methods

3.Add the class annotation as @PacmanRule with its key,description as shown below

4.Add your business logic inside the execute()

Step 4:

Have RuleExecutor.main method from the rule-engine in your main method for local execution to test your code as shown

Step 5:

Go to Debug configuration-->Java Application-->New-->give class name-->select project-->select the class as shown

Step 6:

Go to Debug configuration-->Java Application-->select the class you mentioned earlier-->click environment tab--enter the BASE_AWS_ACCOUNT and ES_URI as shown

NOTE : BASE_AWS_ACCOUNT is required in the env only when you describing the client in your code,otherwise can't create the client exception will come. ES_URI is to get the inventory and to post the issues

Step 7:

Go to Eclipse now-->debug configuration-->Java Application-->Select the class which you wanted to test-->add the arguments as shown below-->apply-->debug

Main Method Test

Visualize Rule compliance using PacBot generic Dashboards

Dashboard 1:

Go to compliance overview and search for the rule which you have created by its display name or ruleId

Dashboard 2:

Go to policy violation and search for the rule where you can see the open issue details

Click on any of the issue id, then you will go to policy violation details page

Dashboard 3:

Go to policy knowledge base and search for the rule.

Click on the rule you selected, it will take you to the policy details page where you can see, rule description, resolution details

Clone this wiki locally