Пример #1
0
from grr_response_server.rdfvalues import flow_runner as rdf_flow_runner
from grr_response_server.rdfvalues import objects as rdf_objects
from grr.test_lib import acl_test_lib
from grr.test_lib import action_mocks
from grr.test_lib import artifact_test_lib as ar_test_lib
from grr.test_lib import hunt_test_lib
from grr.test_lib import test_lib
from grr.test_lib import vfs_test_lib

flags.DEFINE_string(
    "chrome_driver_path", None,
    "Path to the chrome driver binary. If not set, webdriver "
    "will search on PATH for the binary.")

flags.DEFINE_bool(
    "use_headless_chrome", False, "If set, run Chrome driver in "
    "headless mode. Useful when running tests in a window-manager-less "
    "environment.")

flags.DEFINE_bool(
    "disable_chrome_sandboxing", False,
    "Whether to disable chrome sandboxing (e.g when running in a Docker "
    "container).")

# A increasing sequence of times.
TIME_0 = test_lib.FIXED_TIME
TIME_1 = TIME_0 + rdfvalue.Duration("1d")
TIME_2 = TIME_1 + rdfvalue.Duration("1d")


def DateString(t):
    return t.Format("%Y-%m-%d")
Пример #2
0
from __future__ import unicode_literals

import pdb

# pylint: disable=unused-import
from grr_response_client import client_plugins
# pylint: enable=unused-import

from grr_response_client import client_startup
from grr_response_client import fleetspeak_client
from grr_response_client import installer
from grr_response_core import config
from grr_response_core.config import contexts
from grr_response_core.lib import flags

flags.DEFINE_bool("install", False, "Specify this to install the client.")

flags.DEFINE_bool(
    "break_on_start", False,
    "If True break into a pdb shell immediately on startup. This"
    " can be used for debugging the client manually.")


def main(unused_args):
    config.CONFIG.AddContext(
        contexts.CLIENT_CONTEXT,
        "Context applied when we run the client process.")

    client_startup.ClientInit()

    if flags.FLAGS.install:
Пример #3
0
from grr_response_client import client_startup
from grr_response_client import comms
from grr_response_client import vfs
from grr_response_core import config
from grr_response_core.config import contexts
from grr_response_core.lib import flags
from grr_response_core.lib.rdfvalues import crypto as rdf_crypto
from grr_response_core.lib.rdfvalues import paths as rdf_paths

flags.DEFINE_integer("nrclients", 1, "Number of clients to start")

flags.DEFINE_string(
    "cert_file", "", "Path to a file that stores all certificates for"
    "the client pool.")

flags.DEFINE_bool("enroll_only", False,
                  "If specified, the script will enroll all clients and exit.")

flags.DEFINE_bool(
    "fast_poll", False,
    "If specified, every client in the pool will work in the "
    "fast poll mode. This is useful for benchmarks, as in fast "
    "poll mode the timeouts are predictable and benchmarks "
    "results are more stable.")


class PoolGRRClient(threading.Thread):
  """A GRR client for running in pool mode."""

  def __init__(self, ca_cert=None, private_key=None, fast_poll=False):
    """Constructor."""
    super(PoolGRRClient, self).__init__()
Пример #4
0
flags.DEFINE_string("client_id", "", "Id for client to run tests against.")

flags.DEFINE_list(
    "whitelisted_tests", [],
    "(Optional) comma-separated list of tests to run (skipping all others).")

flags.DEFINE_list(
    "blacklisted_tests", [],
    "(Optional) comma-separated list of tests to skip. Trumps "
    "--whitelisted_tests if there are any conflicts.")

# We use a logging Filter to exclude noisy unwanted log output.
flags.DEFINE_list("filenames_excluded_from_log", ["connectionpool.py"],
                  "Files whose log messages won't get printed.")

flags.DEFINE_bool("upload_test_binaries", True,
                  "Whether to upload executables needed by some e2e tests.")

flags.DEFINE_list(
    "ignore_test_context", False,
    "When set, run_end_to_end_tests doesn't load the config with a "
    "default 'Test Context' added.")


class E2ELogFilter(logging.Filter):
    """Logging filter that excludes log messages for particular files."""
    def filter(self, record):
        return record.filename not in flags.FLAGS.filenames_excluded_from_log


def main(argv):
    del argv  # Unused.
Пример #5
0
    # pylint: disable=g-import-not-at-top
    import fuse
    # pylint: enable=g-import-not-at-top
except (EnvironmentError, ImportError):
    # We check for ImportErrors and EnvironmentErrors since submit checks throw an
    # EnvironmentError when fuse isn't installed.
    fuse = None

flags.DEFINE_string("aff4path", "/",
                    "Path in AFF4 to use as the root of the filesystem.")

flags.DEFINE_string("mountpoint", None,
                    "Path to point at which the system should be mounted.")

flags.DEFINE_bool(
    "background", False,
    "Whether or not to run the filesystem in the background,"
    " not viewing debug information.")

flags.DEFINE_float("timeout", 30,
                   "How long to poll a flow for before giving up.")

flags.DEFINE_integer(
    "max_age_before_refresh", 60 * 5,
    "Measured in seconds. Do a client-side update if it's"
    " been this long since we last did one.")

flags.DEFINE_bool(
    "ignore_cache", False, "Disables cache completely. Takes priority over"
    " refresh_policy.")

flags.DEFINE_enum("refresh_policy",
Пример #6
0
from grr_response_client import comms
from grr_response_client import vfs
from grr_response_core import config
from grr_response_core.config import contexts
from grr_response_core.lib import flags
from grr_response_core.lib.rdfvalues import crypto as rdf_crypto
from grr_response_core.lib.rdfvalues import paths as rdf_paths

flags.DEFINE_integer("nrclients", 1, "Number of clients to start")

flags.DEFINE_string(
    "cert_file", "", "Path to a file that stores all certificates for"
    "the client pool.")

flags.DEFINE_bool(
    "enroll_only", False,
    "If specified, the script will enroll all clients and exit.")

flags.DEFINE_bool(
    "fast_poll", False,
    "If specified, every client in the pool will work in the "
    "fast poll mode. This is useful for benchmarks, as in fast "
    "poll mode the timeouts are predictable and benchmarks "
    "results are more stable.")

flags.DEFINE_bool(
    "send_foreman_request", False,
    "If specified, every client will send a foreman poll request "
    "right after startup. Useful for testing hunts.")

Пример #7
0
from grr_response_server.hunts import standard
from grr_response_server.rdfvalues import flow_runner as rdf_flow_runner
from grr_response_server.rdfvalues import objects as rdf_objects
from grr.test_lib import acl_test_lib
from grr.test_lib import action_mocks
from grr.test_lib import artifact_test_lib as ar_test_lib
from grr.test_lib import hunt_test_lib
from grr.test_lib import test_lib

flags.DEFINE_string(
    "chrome_driver_path", None,
    "Path to the chrome driver binary. If not set, webdriver "
    "will search on PATH for the binary.")

flags.DEFINE_bool(
    "use_headless_chrome", False, "If set, run Chrome driver in "
    "headless mode. Useful when running tests in a window-manager-less "
    "environment.")

# A increasing sequence of times.
TIME_0 = test_lib.FIXED_TIME
TIME_1 = TIME_0 + rdfvalue.Duration("1d")
TIME_2 = TIME_1 + rdfvalue.Duration("1d")


def DateString(t):
    return t.Format("%Y-%m-%d")


def DateTimeString(t):
    return t.Format("%Y-%m-%d %H:%M:%S")
Пример #8
0
flags.DEFINE_string("reason", None,
                    "Create a default token with this access reason ")

flags.DEFINE_string(
    "code_to_execute", None,
    "If present, no console is started but the code given in "
    "the flag is run instead (comparable to the -c option of "
    "IPython).")

flags.DEFINE_string(
    "command_file", None,
    "If present, no console is started but the code given in "
    "command file is supplied as input instead.")

flags.DEFINE_bool(
    "exit_on_complete", True,
    "If set to False and command_file or code_to_execute is "
    "set we keep the console alive after the code completes.")

flags.DEFINE_version(config_server.VERSION["packageversion"])


def Lister(arg):
    for x in arg:
        print(x)


def GetChildrenList(urn, token=None):
    return list(aff4.FACTORY.Open(urn, token=token).ListChildren())


def main(argv):