Skip to content
Snippets Groups Projects
adt2amas.cpp 7.46 KiB
#include "translator.hpp"

int main() {
  /* Treasure hunters example */

  cout << "#### \n Treasure hunters\n####" << endl;

  // Nand* TS = new Nand({NodeType::Attack}, "TS");
  // Sand* TF = new Sand({NodeType::Attack}, "TF");
  // And* ST = new And({NodeType::Attack}, "ST");
  // Leaf* b = new Leaf({NodeType::Attack}, "b");
  // Leaf* f = new Leaf({NodeType::Attack}, "f");
  // Or* GA = new Or({NodeType::Attack}, "GA");
  // Leaf* h = new Leaf({NodeType::Attack}, "h");
  // Leaf* e = new Leaf({NodeType::Defence}, "e");
  // Leaf* p = new Leaf({NodeType::Defence}, "p");

  // ADtree* treasure_hunter = new ADtree(TS);
  // treasure_hunter->add_child(TF, TS);
  // treasure_hunter->add_child(p, TS);
  // treasure_hunter->add_child(ST, TF);
  // treasure_hunter->add_child(GA, TF);
  // treasure_hunter->add_child(b, ST);
  // treasure_hunter->add_child(f, ST);
  // treasure_hunter->add_child(h, GA);
  // treasure_hunter->add_child(e, GA);

  // cout << "Tree Treasure hunters: " << endl;
  // cout << treasure_hunter->get_info();

  // cout << "Translation" << endl;
  // Automata* amata = Translator::adt2amas_translate(treasure_hunter);
  // cout << amata->get_info();

  // /* Forestalling a software release example */

  // cout << "#### \n Forestalling\n####" << endl;

  // Sand* FS = new Sand({NodeType::Attack}, "FS");
  // Or* SC = new Or({NodeType::Attack}, "SC");
  // Leaf* icp = new Leaf({NodeType::Attack}, "icp");
  // Leaf* dtm = new Leaf({NodeType::Attack}, "dtm");
  // Sand* BRB = new Sand({NodeType::Attack}, "BRB");
  // Leaf* bp = new Leaf({NodeType::Attack}, "bp");
  // Leaf* psc = new Leaf({NodeType::Attack}, "psc");
  // Snand* NAS = new Snand({NodeType::Attack}, "NAS");
  // Sand* NA = new Sand({NodeType::Attack}, "NA");
  // Leaf* hh = new Leaf({NodeType::Attack}, "hh");
  // Leaf* sb = new Leaf({NodeType::Attack}, "sb");
  // Leaf* heb = new Leaf({NodeType::Attack}, "heb");
  // Leaf* id = new Leaf({NodeType::Defence}, "id");
  // Nand* PRS = new Nand({NodeType::Attack}, "PRS");
  // Sand* PR = new Sand({NodeType::Attack}, "PR");
  // Leaf* hr = new Leaf({NodeType::Attack}, "hr");
  // Leaf* reb = new Leaf({NodeType::Attack}, "reb");
  // Leaf* rfc = new Leaf({NodeType::Attack}, "rfc");
  // Leaf* scr = new Leaf({NodeType::Defence}, "scr");

  // ADtree* forestall = new ADtree(FS);
  // forestall->add_child(SC, FS);
  // forestall->add_child(icp, FS);
  // forestall->add_child(dtm, FS);
  // forestall->add_child(BRB, SC);
  // forestall->add_child(NAS, SC);
  // forestall->add_child(PRS, SC);
  // forestall->add_child(bp, BRB);
  // forestall->add_child(psc, BRB);
  // forestall->add_child(NA, NAS);
  // forestall->add_child(id, NAS);
  // forestall->add_child(hh, NA);
  // forestall->add_child(sb, NA);
  // forestall->add_child(heb, NA);
  // forestall->add_child(PR, PRS);
  // forestall->add_child(scr, PRS);
  // forestall->add_child(hr, PR);
  // forestall->add_child(reb, PR);
  // forestall->add_child(rfc, PR);

  // cout << "Tree Forestalling: " << endl;
  // cout << forestall->get_info();

  // cout << "Translation" << endl;

  // Automata* amata2 = Translator::adt2amas_translate(forestall);
  // cout << amata2->get_info();

  // /* Compromise IoT device */

  // cout << "#### \n Iot-dev\n####" << endl;

  // Sand* CIoTD = new Sand({NodeType::Attack}, "CIoTD");
  // Snand* APNS = new Snand({NodeType::Attack}, "APNS");
  // And* APN = new And({NodeType::Attack}, "APN");
  // Or* CPN = new Or({NodeType::Attack}, "CPN");
  // Sand* AL = new Sand({NodeType::Attack}, "AL");
  // Leaf* flp = new Leaf({NodeType::Attack}, "flp");
  // Leaf* sma = new Leaf({NodeType::Attack}, "sma");
  // Sand* AW = new Sand({NodeType::Attack}, "AW");
  // Leaf* fw = new Leaf({NodeType::Attack}, "fw");
  // Leaf* bwk = new Leaf({NodeType::Attack}, "bwk");
  // Nand* GVC = new Nand({NodeType::Attack}, "GVC");
  // Leaf* gc = new Leaf({NodeType::Attack}, "gc");
  // Leaf* tla = new Leaf({NodeType::Defence}, "tla");
  // Leaf* inc = new Leaf({NodeType::Defence}, "inc");
  // Leaf* esv = new Leaf({NodeType::Attack}, "esv");
  // Leaf* rms = new Leaf({NodeType::Attack}, "rms");

  // ADtree* iot_dev = new ADtree(CIoTD);
  // iot_dev->add_child(APNS, CIoTD);
  // iot_dev->add_child(APN, APNS);
  // iot_dev->add_child(CPN, APN);
  // iot_dev->add_child(AL, CPN);
  // iot_dev->add_child(flp, AL);
  // iot_dev->add_child(sma, AL);
  // iot_dev->add_child(AW, CPN);
  // iot_dev->add_child(fw, AW);
  // iot_dev->add_child(bwk, AW);
  // iot_dev->add_child(GVC, APN);
  // iot_dev->add_child(gc, GVC);
  // iot_dev->add_child(tla, GVC);
  // iot_dev->add_child(inc, APNS);
  // iot_dev->add_child(esv, CIoTD);
  // iot_dev->add_child(rms, CIoTD);

  // cout << "Tree iot_dev: " << endl;
  // cout << iot_dev->get_info();

  // cout << "Translation" << endl;

  // Automata* amata3 = Translator::adt2amas_translate(iot_dev);
  // cout << amata3->get_info();

  // /* Obtain admin privileges */

  // cout << "#### \n Gain-admin\n####" << endl;

  // Or* OAP = new Or({NodeType::Attack}, "OAP");
  // Or* ACLI = new Or({NodeType::Attack}, "ACLI");
  // Leaf* co = new Leaf({NodeType::Attack}, "co");
  // Nand* ECCS = new Nand({NodeType::Attack}, "ECCS");
  // Or* ECC = new Or({NodeType::Attack}, "ECC");
  // Leaf* bcc = new Leaf({NodeType::Attack}, "bcc");
  // Leaf* ccg = new Leaf({NodeType::Attack}, "ccg");
  // scr = new Leaf({NodeType::Defence}, "scr");
  // Or* GSAP = new Or({NodeType::Attack}, "GSAP");
  // Snand* GAPS = new Snand({NodeType::Attack}, "GAPS");
  // Sand* GAP = new Sand({NodeType::Attack}, "GAP");
  // Leaf* opf = new Leaf({NodeType::Attack}, "opf");
  // Leaf* fgp = new Leaf({NodeType::Attack}, "fgp");
  // tla = new Leaf({NodeType::Defence}, "tla");
  // Nand* LSAS = new Nand({NodeType::Attack}, "LSAS");
  // Sand* LSA = new Sand({NodeType::Attack}, "LSA");
  // Leaf* bsa = new Leaf({NodeType::Attack}, "bsa");
  // Leaf* vsa = new Leaf({NodeType::Attack}, "vsa");
  // Leaf* sat = new Leaf({NodeType::Attack}, "sat");
  // Leaf* nv = new Leaf({NodeType::Defence}, "nv");
  // Nand* TSA = new Nand({NodeType::Attack}, "TSA");
  // Leaf* th = new Leaf({NodeType::Attack}, "th");
  // Or* DTH = new Or({NodeType::Defence}, "DTH");
  // Leaf* wd = new Leaf({NodeType::Defence}, "wd");
  // Leaf* efw = new Leaf({NodeType::Defence}, "efw");
  // Leaf* csa = new Leaf({NodeType::Attack}, "csa");

  // ADtree* gain_admin = new ADtree(OAP);
  // gain_admin->add_child(ACLI, OAP);
  // gain_admin->add_child(co, ACLI);
  // gain_admin->add_child(ECCS, ACLI);
  // gain_admin->add_child(ECC, ECCS);
  // gain_admin->add_child(bcc, ECC);
  // gain_admin->add_child(ccg, ECC);
  // gain_admin->add_child(scr, ECCS);
  // gain_admin->add_child(GSAP, OAP);
  // gain_admin->add_child(GAPS, GSAP);
  // gain_admin->add_child(GAP, GAPS);
  // gain_admin->add_child(opf, GAP);
  // gain_admin->add_child(fgp, GAP);
  // gain_admin->add_child(tla, GAPS);
  // gain_admin->add_child(LSAS, GSAP);
  // gain_admin->add_child(LSA, LSAS);
  // gain_admin->add_child(bsa, LSA);
  // gain_admin->add_child(vsa, LSA);
  // gain_admin->add_child(sat, LSA);
  // gain_admin->add_child(nv, LSAS);
  // gain_admin->add_child(TSA, GSAP);
  // gain_admin->add_child(th, TSA);
  // gain_admin->add_child(DTH, TSA);
  // gain_admin->add_child(wd, DTH);
  // gain_admin->add_child(efw, DTH);
  // gain_admin->add_child(csa, GSAP);

  // cout << "Tree gain-admin " << endl;
  // cout << gain_admin->get_info();

  // cout << "Translation" << endl;

  // Automata* amata4 = Translator::adt2amas_translate(gain_admin);
  // cout << amata4->get_info();

  return 0;
}