Skip to content

6. Add DeploymentPolicy

CortexVacua edited this page Apr 10, 2022 · 2 revisions

Assuming that an attack type has multiple MTDSolutions associated with it, you might want to add a DeploymentPolicy, which tells the framework which MTDSolution to deploy.
Such a DeploymentPolicy is easy to add. You just need to specify a script which tells the framework what MTDSolution to deploy. MTDSolutions are identified by their Priority value. The script you specify as a deployment policy should write an int representing the Priority value to stdout and then flush stdout, which would look something like this in a python program:

import sys
import os


def main():
    sys.stdout.write('2')
    sys.stdout.flush()
    sys.exit()


if __name__ == '__main__':
    main()

Of course you would implement some logic by which it is decided which value should be written to stdout.

To then add the DeploymentPolicy, you simply add the DeploymentPolicy to the attack type as follows in the config file:

    {
      "Type": "Test",
      "MTDSolutions": [
        {
          "Priority": 1,
          "ScriptName": "Test.py",
          "AbsolutePath": "/home/",
          "RunWithPrefix": "python3"
        },
        {
          "Priority": 2,
          "ScriptName": "Test2.py",
          "AbsolutePath": "/home/",
          "RunWithPrefix": "python3"
        }
      ],
      "DeploymentPolicy": {
        "ScriptName" : "TestRule.py",
        "AbsolutePath" : "/home/",
        "RunWithPrefix": "python3"
      }
    }