diff --git a/cuckoo/apps/apps.py b/cuckoo/apps/apps.py index 6ab50d8af..f4919cf78 100644 --- a/cuckoo/apps/apps.py +++ b/cuckoo/apps/apps.py @@ -57,6 +57,7 @@ def fetch_community(branch="master", force=False, filepath=None): folders = { "modules/signatures": "signatures", "data/monitor": "monitor", + "data/yara": "yara", "agent": "agent", "analyzer": "analyzer", } @@ -91,6 +92,9 @@ def fetch_community(branch="master", force=False, filepath=None): t.makelink(member, filepath) continue + if not os.path.exists(os.path.dirname(filepath)): + os.makedirs(os.path.dirname(filepath)) + log.debug("Extracted %s..", member.name[len(name_start)+1:]) open(filepath, "wb").write(t.extractfile(member).read()) diff --git a/tests/test_community.py b/tests/test_community.py index 7202bc9d7..aebd99fd6 100644 --- a/tests/test_community.py +++ b/tests/test_community.py @@ -1,4 +1,4 @@ -# Copyright (C) 2016 Cuckoo Foundation. +# Copyright (C) 2016-2017 Cuckoo Foundation. # This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org # See the file 'docs/LICENSE' for copying permission. @@ -34,6 +34,10 @@ def test_extract(): open(b, "wb").write("b") t.add(b, "community-master/data/monitor/b.txt") + y = tempfile.mktemp() + open(y, "wb").write("y") + t.add(y, "community-master/data/yara/binaries/y.yar") + c = tempfile.mktemp() open(c, "wb").write("c") t.add(c, "community-master/agent/c.txt") @@ -55,6 +59,7 @@ def test_extract(): assert open(cwd("signatures", "a.txt"), "rb").read() == "a" assert open(cwd("monitor", "b.txt"), "rb").read() == "b" + assert open(cwd("yara", "binaries", "y.yar"), "rb").read() == "y" assert open(cwd("agent", "c.txt"), "rb").read() == "c" assert open(cwd("analyzer", "dir1", "d.txt"), "rb").read() == "d" assert open(cwd("analyzer", "dir2", "dir3", "e.txt"), "rb").read() == "e"