コード例 #1
0
ファイル: metrics_test.py プロジェクト: wxh0000mm/grr
 def testCounterRegistration(self):
     with self.SetUpStatsCollector(
             default_stats_collector.DefaultStatsCollector()):
         metrics.Counter("cfoo")
     self.assertIsNotNone(self.collector.GetMetricMetadata("cfoo"))
コード例 #2
0
ファイル: metrics_test.py プロジェクト: wxh0000mm/grr
 def testCounterIncrement(self):
     with self.SetUpStatsCollector(
             default_stats_collector.DefaultStatsCollector()):
         counter = metrics.Counter("cfoo", fields=[("bar", str)])
     with self.assertStatsCounterDelta(1, counter, fields=["baz"]):
         counter.Increment(fields=["baz"])
コード例 #3
0
from grr_response_core.lib.rdfvalues import protodict as rdf_protodict
from grr_response_core.lib.util import compatibility
from grr_response_core.stats import metrics
from grr_response_server import access_control
from grr_response_server import action_registry
from grr_response_server import data_store
from grr_response_server import data_store_utils
from grr_response_server import fleetspeak_utils
from grr_response_server import flow
from grr_response_server import flow_responses
from grr_response_server import hunt
from grr_response_server import notification as notification_lib
from grr_response_server.rdfvalues import flow_objects as rdf_flow_objects
from grr_response_server.rdfvalues import objects as rdf_objects

FLOW_STARTS = metrics.Counter("flow_starts", fields=[("flow", str)])
FLOW_ERRORS = metrics.Counter("flow_errors", fields=[("flow", str)])
FLOW_COMPLETIONS = metrics.Counter("flow_completions", fields=[("flow", str)])
GRR_WORKER_STATES_RUN = metrics.Counter("grr_worker_states_run")
HUNT_OUTPUT_PLUGIN_ERRORS = metrics.Counter(
    "hunt_output_plugin_errors", fields=[("plugin", str)])
HUNT_RESULTS_RAN_THROUGH_PLUGIN = metrics.Counter(
    "hunt_results_ran_through_plugin", fields=[("plugin", str)])


class Error(Exception):
  """Base class for this package's exceptions."""


class FlowError(Error):
  """A generic flow error."""
コード例 #4
0
from typing import Sequence

from grr_response_core.lib import rdfvalue
from grr_response_core.lib import registry
from grr_response_core.lib import type_info
from grr_response_core.lib.util import compatibility
from grr_response_core.lib.util import random
from grr_response_core.stats import metrics
from grr_response_server import access_control
from grr_response_server import data_store
from grr_response_server.databases import db
from grr_response_server.rdfvalues import flow_objects as rdf_flow_objects
from grr_response_server.rdfvalues import flow_runner as rdf_flow_runner


GRR_FLOW_INVALID_FLOW_COUNT = metrics.Counter("grr_flow_invalid_flow_count")


class Error(Exception):
  """Base class for this package's exceptions."""


class CanNotStartFlowWithExistingIdError(Error):
  """Raises by StartFlow when trying to start a flow with an exising id."""

  def __init__(self, client_id, flow_id):
    message = ("Flow %s already exists on the client %s." %
               (client_id, flow_id))
    super().__init__(message)

    self.client_id = client_id
コード例 #5
0
ファイル: administrative.py プロジェクト: wxh0000mm/grr
from grr_response_core.lib.util import precondition
from grr_response_core.stats import metrics
from grr_response_proto import flows_pb2
from grr_response_server import data_store
from grr_response_server import email_alerts
from grr_response_server import events
from grr_response_server import flow_base
from grr_response_server import hunt
from grr_response_server import message_handlers
from grr_response_server import server_stubs
from grr_response_server import signed_binary_utils
from grr_response_server.databases import db
from grr_response_server.flows.general import discovery
from grr_response_server.rdfvalues import flow_objects as rdf_flow_objects

GRR_CLIENT_CRASHES = metrics.Counter("grr_client_crashes")


def WriteAllCrashDetails(client_id, crash_details, flow_session_id=None):
    """Updates the last crash attribute of the client."""
    try:
        data_store.REL_DB.WriteClientCrashInfo(client_id, crash_details)
    except db.UnknownClientError:
        pass

    if not flow_session_id:
        return

    flow_id = flow_session_id.Basename()
    data_store.REL_DB.UpdateFlow(client_id,
                                 flow_id,
コード例 #6
0
from grr_response_core.lib.rdfvalues import client_network as rdf_client_network
from grr_response_core.lib.rdfvalues import flows as rdf_flows
from grr_response_core.lib.util import collection
from grr_response_core.lib.util import random
from grr_response_core.stats import metrics
from grr_response_server import communicator
from grr_response_server import data_store
from grr_response_server import events
from grr_response_server import message_handlers
from grr_response_server import worker_lib
from grr_response_server.databases import db
from grr_response_server.flows.general import transfer
from grr_response_server.rdfvalues import flow_objects as rdf_flow_objects
from grr_response_server.rdfvalues import objects as rdf_objects

CLIENT_PINGS_BY_LABEL = metrics.Counter("client_pings_by_label",
                                        fields=[("label", str)])
FRONTEND_ACTIVE_COUNT = metrics.Gauge("frontend_active_count",
                                      int,
                                      fields=[("source", str)])
FRONTEND_MAX_ACTIVE_COUNT = metrics.Gauge("frontend_max_active_count", int)
FRONTEND_HTTP_REQUESTS = metrics.Counter("frontend_http_requests",
                                         fields=[("action", str),
                                                 ("protocol", str)])
FRONTEND_IN_BYTES = metrics.Counter("frontend_in_bytes",
                                    fields=[("source", str)])
FRONTEND_OUT_BYTES = metrics.Counter("frontend_out_bytes",
                                     fields=[("source", str)])
FRONTEND_REQUEST_COUNT = metrics.Counter("frontend_request_count",
                                         fields=[("source", str)])
FRONTEND_INACTIVE_REQUEST_COUNT = metrics.Counter(
    "frontend_inactive_request_count", fields=[("source", str)])
コード例 #7
0
from grr_response_core.lib.util import precondition
from grr_response_core.stats import metrics
from grr_response_server import access_control
from grr_response_server import data_store
from grr_response_server.databases import db
from grr_response_server.gui import api_call_handler_base
from grr_response_server.gui import api_call_router
from grr_response_server.gui import api_call_router_without_checks
from grr_response_server.gui import approval_checks
from grr_response_server.gui.api_plugins import flow as api_flow
from grr_response_server.gui.api_plugins import user as api_user
from grr_response_server.gui.api_plugins import yara as api_yara
from grr_response_server.rdfvalues import objects as rdf_objects


APPROVAL_SEARCHES = metrics.Counter(
    "approval_searches", fields=[("reason_presence", str), ("source", str)])


class AccessChecker(object):
  """Relational DB-based access checker implementation."""

  APPROVAL_CACHE_TIME = 60

  def __init__(self):
    self.acl_cache = utils.AgeBasedCache(
        max_size=10000, max_age=self.APPROVAL_CACHE_TIME)

  def _CheckAccess(self, username, subject_id, approval_type):
    """Checks access to a given subject by a given user."""
    precondition.AssertType(subject_id, Text)