Skip to main content

Rule packages

Manage rule packages

Rule packages combine one or more rules created by someone and hosted on an external server. These rule packages can be added to mosparo and are automatically updated at regular intervals. A checksum is created and checked when the rule package is updated to ensure the integrity of the rule packages.

To add a new rule package, you need to know the URL of the rule package. You can also specify a factor with which the rule package can be strengthened or weakened.

After a rule package is added, you can view the rules contained in the rule package. However, you cannot edit or delete the rules in the rules package.

Format of rule packages

Saving the rule package

A rule package consists of a JSON file, which is available for download on a web server. The JSON file must conform to the rule package and rules pattern. The schema for the rule package and the rules are available in the specifications repository.

In addition to the JSON file, you must store the checksum of the JSON file on the same web server at the same address. The SHA256 hash of the file must be created and saved with the same file name but with the suffix ".sha256".

Example

Address of the rule package (entered in mosparo)
https://example.com/ruleset.json

Checksum address:
https://example.com/ruleset.json.sha256

Structure of a rule package

The JSON structure of the rule package is built as a JSON object. The object has the following properties:

PropertyTypeDescription
lastUpdatedAtDateTimeIndicates when the rule package was last modified. This value is used to decide whether mosparo needs to update the rule package or if the latest version is already available.
refreshIntervalIntegerDefines the time in seconds when mosparo is allowed to retrieve the rule package again. mosparo stores the rule package in a cache and the rule package is downloaded again only after this time.
rulesArrayIs an array that contains all rules as a JSON object

Building a rule

A rule's JSON object consists of the following properties:

PropertyTypeDescription
uuidUUIDA unique identification number of the rule
nameStringName of the rule
descriptionStringDescription of the rule
typeStringType of rule (for example: word or user-agent)
itemsArrayArray with all rule item
spamRatingFactorFloatRating factor of the rule to strengthen or weaken the rule items. A value greater than 1.0 strengthens the items, and a value less than 1.0 weakens the items.

Structure of a rule item

The JSON object of a rule item consists of the following properties:

PropertyTypeDescription
uuidUUIDA unique identification number of the rule item
typeStringDefines the type of rule (for example: text or regex)
valueStringThe actual value of the item
ratingFloatDefines the spam value of the item. This value is multiplied by the spam score to give the submission score.