Esempio n. 1
0
def test_pivot_time(data_providers):
    """Function_docstring."""
    providers = data_providers.values()
    end = datetime.utcnow()
    start = end - timedelta(1)
    timespan = TimeSpan(start=start, end=end)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore", category=UserWarning)
        pivot = Pivot(providers=providers, timespan=timespan)
    check.equal(pivot.start, start)
    check.equal(pivot.end, end)

    end = end - timedelta(1)
    start = start - timedelta(1)
    # Test different ways of setting the time
    timespan = TimeSpan(start=start, end=end)
    pivot.timespan = timespan
    check.equal(pivot.start, start)
    check.equal(pivot.end, end)

    pivot.timespan = _TimeObj(start=timespan.start, end=timespan.end)
    check.equal(pivot.start, start)
    check.equal(pivot.end, end)

    pivot.set_timespan(timespan)
    check.equal(pivot.start, start)
    check.equal(pivot.end, end)

    pivot.set_timespan(start=timespan.start, end=timespan.end)
    check.equal(pivot.start, start)
    check.equal(pivot.end, end)

    # Make sure the values provided to queries match.
    _fake_provider_connected(data_providers["az_sent_prov"])

    query = entities.Host.AzureSentinel.SecurityEvent_list_host_processes(
        host_name="test", print=True)
    check.is_in(start.isoformat(), query)
    check.is_in(end.isoformat(), query)
Esempio n. 2
0
def test_pivot_time(data_providers):
    """Function_docstring."""
    providers = data_providers.values()
    end = datetime.utcnow()
    start = end - timedelta(1)
    timespan = TimeSpan(start=start, end=end)
    pivot = Pivot(providers=providers, timespan=timespan)
    check.equal(pivot.start, start)
    check.equal(pivot.end, end)

    end = end - timedelta(1)
    start = start - timedelta(1)
    timespan = TimeSpan(start=start, end=end)
    pivot.timespan = timespan
    check.equal(pivot.start, start)
    check.equal(pivot.end, end)

    _fake_provider_connected(data_providers["az_sent_prov"])

    query = entities.Host.AzureSentinel.list_host_processes(host_name="test",
                                                            print_query=True)
    check.is_in(start.isoformat(), query)
    check.is_in(end.isoformat(), query)