Пример #1
0
def test_search_auth_set_white1():
    auth_set = AuthSet({"attack-pattern", "doesntexist"}, set())

    results = _get_matching_dir_entries(FS_PATH, auth_set, stat.S_ISDIR)
    assert results == ["attack-pattern"]

    results = _get_matching_dir_entries(FS_PATH, auth_set, stat.S_ISREG)
    assert len(results) == 0
Пример #2
0
def test_search_auth_set_black1():
    auth_set = AuthSet(
        None, {"tool--242f3da3-4425-4d11-8f5c-b842886da966", "doesntexist"})

    results = _get_matching_dir_entries(os.path.join(FS_PATH, "tool"),
                                        auth_set, stat.S_ISDIR)

    assert set(results) == {"tool--03342581-f790-4f03-ba41-e82e67392e23"}
def test_search_auth_set_white_empty():
    auth_set = AuthSet(
        set(),
        set(),
    )

    results = _get_matching_dir_entries(FS_PATH, auth_set, stat.S_ISDIR)

    assert len(results) == 0
Пример #4
0
def test_search_auth_set_white3():
    auth_set = AuthSet({"20170531213258226477", "doesntexist"}, set())

    results = _get_matching_dir_entries(
        os.path.join(FS_PATH, "malware",
                     "malware--6b616fc1-1505-48e3-8b2c-0d19337bff38"),
        auth_set, stat.S_ISREG, ".json")

    assert results == ["20170531213258226477.json"]
Пример #5
0
def test_search_auth_set_black_empty(rel_fs_store):
    # Ensure rel_fs_store fixture has run so that the type directories are
    # predictable (it adds "campaign").
    auth_set = AuthSet(None, set())

    results = _get_matching_dir_entries(FS_PATH, auth_set, stat.S_ISDIR)

    # Should get all dirs
    assert set(results) == {
        "attack-pattern", "campaign", "course-of-action", "identity",
        "indicator", "intrusion-set", "malware", "marking-definition",
        "relationship", "tool"
    }
Пример #6
0
def test_search_auth_set_white2():
    auth_set = AuthSet(
        {
            "malware--6b616fc1-1505-48e3-8b2c-0d19337bff38",
            "malware--92ec0cbd-2c30-44a2-b270-73f4ec949841"
        }, {
            "malware--92ec0cbd-2c30-44a2-b270-73f4ec949841",
            "malware--96b08451-b27a-4ff6-893f-790e26393a8e", "doesntexist"
        })

    results = _get_matching_dir_entries(os.path.join(FS_PATH, "malware"),
                                        auth_set, stat.S_ISDIR)

    assert results == ["malware--6b616fc1-1505-48e3-8b2c-0d19337bff38"]