Exemplo n.º 1
0
 def test_star_new(self):
     filepath = Files.temp_put("""
     virtualbox.virtualbox.machines = cuckoo2, cuckoo3
     virtualbox.cuckoo2.ip = 192.168.56.102
     virtualbox.cuckoo3.ip = 192.168.56.103
     virtualbox.notexistingvm.ip = 1.2.3.4
     """)
     assert read_kv_conf(filepath) == {
         "virtualbox": {
             "virtualbox": {
                 "machines": [
                     "cuckoo2",
                     "cuckoo3",
                 ],
             },
             "cuckoo2": {
                 "ip": "192.168.56.102",
             },
             "cuckoo3": {
                 "ip": "192.168.56.103",
             },
             "notexistingvm": {
                 "ip": "1.2.3.4",
             },
         },
     }
Exemplo n.º 2
0
 def test_star_new(self):
     filepath = Files.temp_put("""
     virtualbox.virtualbox.machines = cuckoo2, cuckoo3
     virtualbox.cuckoo2.ip = 192.168.56.102
     virtualbox.cuckoo3.ip = 192.168.56.103
     virtualbox.notexistingvm.ip = 1.2.3.4
     """)
     assert read_kv_conf(filepath) == {
         "virtualbox": {
             "virtualbox": {
                 "machines": [
                     "cuckoo2", "cuckoo3",
                 ],
             },
             "cuckoo2": {
                 "ip": "192.168.56.102",
             },
             "cuckoo3": {
                 "ip": "192.168.56.103",
             },
             "notexistingvm": {
                 "ip": "1.2.3.4",
             },
         },
     }
Exemplo n.º 3
0
 def test_star_existing(self):
     filepath = Files.temp_put("""
     virtualbox.cuckoo1.resultserver_port = 1234
     """)
     assert read_kv_conf(filepath) == {
         "virtualbox": {
             "cuckoo1": {
                 "resultserver_port": 1234,
             },
         },
     }
Exemplo n.º 4
0
 def test_star_existing(self):
     filepath = Files.temp_put("""
     virtualbox.cuckoo1.resultserver_port = 1234
     """)
     assert read_kv_conf(filepath) == {
         "virtualbox": {
             "cuckoo1": {
                 "resultserver_port": 1234,
             },
         },
     }
Exemplo n.º 5
0
def init(ctx, conf):
    """Initializes Cuckoo and its configuration."""
    if conf and os.path.exists(conf):
        cfg = read_kv_conf(conf)
    else:
        cfg = None

    # If this is a new install, also apply the provided configuration.
    cuckoo_init(logging.INFO, ctx.parent, cfg)

    # If this is an existing install, overwrite the supervisord.conf
    # configuration file (if needed) as well as the Cuckoo configuration.
    write_supervisor_conf(ctx.parent.user or getuser())
    write_cuckoo_conf(cfg)
Exemplo n.º 6
0
def init(ctx, conf):
    """Initializes Cuckoo and its configuration."""
    if conf and os.path.exists(conf):
        cfg = read_kv_conf(conf)
    else:
        cfg = None

    # If this is a new install, also apply the provided configuration.
    cuckoo_init(logging.INFO, ctx.parent, cfg)

    # If this is an existing install, overwrite the supervisord.conf
    # configuration file (if needed) as well as the Cuckoo configuration.
    write_supervisor_conf(ctx.parent.user or getuser())
    write_cuckoo_conf(cfg)
Exemplo n.º 7
0
 def test_success(self):
     filepath = Files.temp_put("""
     cuckoo.cuckoo.version_check = off
     auxiliary.sniffer.enabled = no
     """)
     assert read_kv_conf(filepath) == {
         "cuckoo": {
             "cuckoo": {
                 "version_check": False,
             },
         },
         "auxiliary": {
             "sniffer": {
                 "enabled": False,
             },
         },
     }
Exemplo n.º 8
0
 def test_success(self):
     filepath = Files.temp_put("""
     cuckoo.cuckoo.version_check = off
     auxiliary.sniffer.enabled = no
     """)
     assert read_kv_conf(filepath) == {
         "cuckoo": {
             "cuckoo": {
                 "version_check": False,
             },
         },
         "auxiliary": {
             "sniffer": {
                 "enabled": False,
             },
         },
     }
Exemplo n.º 9
0
 def test_fail3(self):
     filepath = Files.temp_put("cuckoo.cuckoo.version_check = foo")
     with pytest.raises(CuckooConfigurationError) as e:
         read_kv_conf(filepath)
     e.match("Invalid flat configuration entry")
Exemplo n.º 10
0
 def test_fail2(self):
     filepath = Files.temp_put("a.b.c : d")
     with pytest.raises(CuckooConfigurationError) as e:
         read_kv_conf(filepath)
     e.match("missing .* character")
Exemplo n.º 11
0
 def test_fail1(self):
     filepath = Files.temp_put("a = b")
     with pytest.raises(CuckooConfigurationError) as e:
         read_kv_conf(filepath)
     e.match("Invalid configuration entry")
Exemplo n.º 12
0
 def test_fail3(self):
     filepath = Files.temp_put("cuckoo.cuckoo.version_check = foo")
     with pytest.raises(CuckooConfigurationError) as e:
         read_kv_conf(filepath)
     e.match("Invalid flat configuration entry")
Exemplo n.º 13
0
 def test_fail2(self):
     filepath = Files.temp_put("a.b.c : d")
     with pytest.raises(CuckooConfigurationError) as e:
         read_kv_conf(filepath)
     e.match("missing .* character")
Exemplo n.º 14
0
 def test_fail1(self):
     filepath = Files.temp_put("a = b")
     with pytest.raises(CuckooConfigurationError) as e:
         read_kv_conf(filepath)
     e.match("Invalid configuration entry")