Пример #1
0
  def Layout(self, request, response):
    """Get available artifact information for display."""
    # Get all artifacts that aren't Bootstrap and aren't the base class.
    self.artifacts = {}
    artifact.LoadArtifactsFromDatastore(token=request.token)
    for name, artifact_val in artifact_lib.ArtifactRegistry.artifacts.items():
      if set(["Bootstrap"]).isdisjoint(artifact_val.labels):
        self.artifacts[name] = artifact_val
    self.labels = artifact_lib.ARTIFACT_LABELS

    # Convert artifacts into a dict usable from javascript.
    artifact_dict = {}
    for artifact_name, artifact_val in self.artifacts.items():
      artifact_dict[artifact_name] = artifact_val.ToExtendedDict()
      processors = []
      for processor in parsers.Parser.GetClassesByArtifact(artifact_name):
        processors.append({"name": processor.__name__,
                           "output_types": processor.output_types,
                           "doc": processor.GetDescription()})
      artifact_dict[artifact_name]["processors"] = processors

    # Skip the our parent and call the TypeDescriptorFormRenderer direct.
    response = renderers.TypeDescriptorFormRenderer.Layout(self, request,
                                                           response)
    return self.CallJavascript(response, "ArtifactListRenderer.Layout",
                               prefix=self.prefix,
                               artifacts=artifact_dict,
                               supported_os=artifact_lib.SUPPORTED_OS_LIST,
                               labels=self.labels)
Пример #2
0
    def Render(self, unused_args, token=None):
        """Get available artifact information for rendering."""

        # get custom artifacts from data store
        artifact_urn = rdfvalue.RDFURN("aff4:/artifact_store")
        try:
            collection = aff4.FACTORY.Open(artifact_urn,
                                           aff4_type="RDFValueCollection",
                                           token=token)
        except IOError:
            collection = {}

        custom_artifacts = set()
        for value in collection:
            custom_artifacts.add(value.name)

        # Get all artifacts that aren't Bootstrap and aren't the base class.
        artifacts = {}
        artifact.LoadArtifactsFromDatastore(token=token)

        for name, artifact_val in artifact_lib.ArtifactRegistry.artifacts.items(
        ):
            artifacts[name] = artifact_val

        return self.RenderArtifacts(artifacts,
                                    custom_artifacts=custom_artifacts)
Пример #3
0
 def _GetArtifactFromName(self, name):
   """Get an artifact class from the cache in the flow."""
   if name in artifact_lib.ArtifactRegistry.artifacts:
     return artifact_lib.ArtifactRegistry.artifacts[name]
   else:
     # If we don't have an artifact, things shouldn't have passed validation
     # so we assume its a new one in the datastore.
     artifact.LoadArtifactsFromDatastore(token=self.token)
     if name not in artifact_lib.ArtifactRegistry.artifacts:
       raise RuntimeError("ArtifactCollectorFlow failed due to unknown "
                          "Artifact %s" % name)
     else:
       return artifact_lib.ArtifactRegistry.artifacts[name]
Пример #4
0
    def Render(self, unused_args, token):
        """Get available artifact information for rendering."""

        # get custom artifacts from data store
        artifact_urn = rdfvalue.RDFURN("aff4:/artifact_store")
        try:
            collection = aff4.FACTORY.Open(artifact_urn,
                                           aff4_type="RDFValueCollection",
                                           token=token)
        except IOError:
            collection = {}

        custom_artifacts = set([])
        for value in collection:
            custom_artifacts.add(value.name)

        # Get all artifacts that aren't Bootstrap and aren't the base class.
        artifacts = {}
        artifact.LoadArtifactsFromDatastore(token=token)

        for name, artifact_val in artifact_lib.ArtifactRegistry.artifacts.items(
        ):
            artifacts[name] = artifact_val

        # Convert artifacts into a dict usable from javascript.
        artifact_dict = {}
        for artifact_name, artifact_val in artifacts.items():
            processors = []
            for processor in parsers.Parser.GetClassesByArtifact(
                    artifact_name):
                processors.append({
                    "name": processor.__name__,
                    "output_types": processor.output_types,
                    "doc": processor.GetDescription()
                })
            is_custom = artifact_name in custom_artifacts
            artifact_dict[artifact_name] = {
                "artifact": artifact_val.ToExtendedDict(),
                "processors": processors,
                "custom": is_custom
            }

        return artifact_dict