Ejemplo n.º 1
0
def test_process_json_logging():
    set_cwd(tempfile.mkdtemp())
    cuckoo_create()
    index_yara()
    init_logfile("process-p0.json")

    def process_tasks(instance, maxcount):
        logger("foo bar", action="hello.world", status="success")

    with mock.patch("cuckoo.main.Database"):
        with mock.patch("cuckoo.main.process_tasks") as p1:
            with mock.patch("time.time") as p2:
                p1.side_effect = process_tasks
                p2.return_value = 1484232003
                main.main(
                    ("--cwd", cwd(), "process", "p0"), standalone_mode=False
                )

    assert json.load(open(cwd("log", "process-p0.json"), "rb")) == {
        "asctime": mock.ANY,
        "action": "hello.world",
        "level": "info",
        "message": "foo bar",
        "status": "success",
        "task_id": None,
        "time": 1484232003,
    }
Ejemplo n.º 2
0
def test_process_json_logging():
    set_cwd(tempfile.mkdtemp())
    cuckoo_create()
    index_yara()
    init_logfile("process-p0.json")

    def process_tasks(instance, maxcount):
        logger("foo bar", action="hello.world", status="success")

    with mock.patch("cuckoo.main.Database") as p0:
        with mock.patch("cuckoo.main.process_tasks") as p1:
            with mock.patch("time.time") as p2:
                p1.side_effect = process_tasks
                p2.return_value = 1484232003
                main.main(
                    ("--cwd", cwd(), "process", "p0"), standalone_mode=False
                )

    assert json.load(open(cwd("log", "process-p0.json"), "rb")) == {
        "asctime": mock.ANY,
        "action": "hello.world",
        "level": "info",
        "message": "foo bar",
        "status": "success",
        "task_id": None,
        "time": 1484232003,
    }
Ejemplo n.º 3
0
 def setup(self):
     set_cwd(tempfile.mkdtemp())
     cuckoo_create()
     index_yara()
Ejemplo n.º 4
0
 def setup(self):
     set_cwd(tempfile.mkdtemp())
     cuckoo_create()
     index_yara()