Beispiel #1
0
  def BuildHashFromNotification(notification):
    """Navigate to the most appropriate location for this navigation."""
    h = {}

    # Still display if subject doesn't get set, this will appear in the GUI with
    # a target of "None"
    urn = "/"
    if notification.subject is not None:
      urn = notification.subject

    # General Host information
    if notification.type == "Discovery":
      path = rdfvalue.RDFURN(urn)
      components = path.Path().split("/")[1:]
      h["c"] = components[0]
      h["main"] = "HostInformation"

    elif notification.type == "DownloadFile":
      h["aff4_path"] = notification.subject
      h["main"] = "DownloadFile"

    elif notification.type == "ViewObject":
      path = rdfvalue.RDFURN(urn)
      components = path.Path().split("/")[1:]
      if len(components) == 2 and components[0] == "hunts":
        h["hunt_id"] = notification.subject
        h["main"] = "ManageHunts"
      elif len(components) == 2 and components[0] == "cron":
        h["cron_job_urn"] = notification.subject
        h["main"] = "ManageCron"
      elif len(components) == 3 and components[1] == "flows":
        h["flow"] = notification.subject
        h["c"] = components[0]
        h["main"] = "ManageFlows"
      else:
        h["c"] = components[0]
        h["aff4_path"] = notification.subject
        h["t"] = renderers.DeriveIDFromPath("/".join(components[1:-1]))
        h["main"] = "VirtualFileSystemView"

    # Error with a flow
    elif notification.type == "FlowStatus":
      path = rdfvalue.RDFURN(urn)
      components = path.Path().split("/")[1:]
      h["flow"] = notification.source
      h["c"] = components[0]
      h["main"] = "ManageFlows"

    elif notification.type == "GrantAccess":
      h["main"] = "GrantAccess"
      h["acl"] = notification.subject

    return urllib.urlencode(
        dict([(x, utils.SmartStr(y)) for x, y in h.items()]))
Beispiel #2
0
  def Layout(self, request, response):
    client, rest = self.proxy.Split(2)
    if aff4_grr.VFSGRRClient.CLIENT_ID_RE.match(client):
      h = dict(
          main="VirtualFileSystemView",
          c=client,
          tab="AFF4Stats",
          t=renderers.DeriveIDFromPath(rest))
      self.href = urllib.urlencode(sorted(h.items()))

    super(RDFURNRenderer, self).Layout(request, response)
Beispiel #3
0
    def Layout(self, request, response):
        if not self.proxy:
            return

        aff4_path = request.REQ.get("aff4_path", "")
        aff4_path = rdfvalue.RDFURN(aff4_path)
        self.basename = self.proxy.RelativeName(aff4_path) or self.proxy
        self.aff4_path = self.proxy
        self.tree_node_id = renderers.DeriveIDFromPath("/".join(
            self.aff4_path.Split()[1:]))

        return super(SubjectRenderer, self).Layout(request, response)
Beispiel #4
0
  def Layout(self, request, response):
    """Render the toolbar."""
    self.state["client_id"] = client_id = request.REQ.get("client_id")
    self.state["aff4_path"] = aff4_path = request.REQ.get(
        "aff4_path", client_id)

    client_urn = rdf_client.ClientURN(client_id)

    self.paths = [("/", client_urn, "_", 0)]
    for path in rdfvalue.RDFURN(aff4_path).Split()[1:]:
      previous = self.paths[-1]
      fullpath = previous[1].Add(path)

      self.paths.append((path, fullpath,
                         renderers.DeriveIDFromPath(
                             fullpath.RelativeName(client_urn)),
                         previous[3] + 1))

    response = super(Toolbar, self).Layout(request, response)
    return self.CallJavascript(response, "Toolbar.Layout",
                               aff4_path=utils.SmartUnicode(aff4_path),
                               paths=self.paths)