Ejemplo n.º 1
0
  public Graph putGraph(Graph graph, QueryParameters digQueryParams) {
    graph = super.putGraph(graph, digQueryParams);
    graph.commitIndex();

    Graph resultGraph = new Graph();

    for (AbstractEdge edge : graph.edgeSet()) {
      if (edge != null && edge.getSourceVertex() != null && edge.getDestinationVertex() != null) {
        AbstractEdge newEdge = createNewWithoutAnnotations(edge);
        replaceAnnotations(newEdge.getAnnotations(), provTC2OpmMapping);
        replaceAnnotations(newEdge.getSourceVertex().getAnnotations(), provTC2OpmMapping);
        replaceAnnotations(newEdge.getDestinationVertex().getAnnotations(), provTC2OpmMapping);
        resultGraph.putVertex(newEdge.getSourceVertex());
        resultGraph.putVertex(newEdge.getDestinationVertex());
        resultGraph.putEdge(newEdge);
      }
    }

    return resultGraph;
  }
Ejemplo n.º 2
0
  public Graph putGraph(Graph graph, QueryParameters digQueryParams) {

    AbstractVertex queriedVertex = null;

    if (digQueryParams != null) {
      queriedVertex = digQueryParams.getVertex();
    }

    Map<AbstractVertex, Set<String>> fileWrittenBy = new HashMap<AbstractVertex, Set<String>>();

    for (AbstractEdge edge : graph.edgeSet()) {
      AbstractEdge newEdge = createNewWithoutAnnotations(edge);
      if (getAnnotationSafe(newEdge.getSourceVertex(), "subtype").equals("file")
          || getAnnotationSafe(newEdge.getDestinationVertex(), "subtype").equals("file")) {
        String operation = getAnnotationSafe(newEdge, "operation");
        if (operation.equals("write")
            || operation.equals("writev")
            || operation.equals("pwrite64")
            || operation.equals("rename_write")
            || operation.equals("link_write")
            || operation.equals("symlink_write")) {
          if (fileWrittenBy.get(newEdge.getSourceVertex()) == null) {
            fileWrittenBy.put(newEdge.getSourceVertex(), new HashSet<String>());
          }
          fileWrittenBy
              .get(newEdge.getSourceVertex())
              .add(getAnnotationSafe(newEdge.getDestinationVertex(), "pid"));
        }
      }
    }

    Graph resultGraph = new Graph();

    for (AbstractEdge edge : graph.edgeSet()) {
      AbstractEdge newEdge = createNewWithoutAnnotations(edge);
      if ((getAnnotationSafe(newEdge, "operation").equals("read")
              || getAnnotationSafe(newEdge, "operation").equals("readv")
              || getAnnotationSafe(newEdge, "operation").equals("pread64"))
          && getAnnotationSafe(newEdge.getDestinationVertex(), "subtype").equals("file")) {
        AbstractVertex vertex = newEdge.getDestinationVertex();
        String path = getAnnotationSafe(vertex, "path");
        if (!pathEqualsVertex(
            path,
            queriedVertex)) { // if file passed as an argument then always log it otherwise check
          // further
          if (isPathInIgnoreFilesPattern(
              path)) { // if file is not in ignore list then always log it otherwise check further
            if ((fileWrittenBy.get(vertex) == null)
                || (fileWrittenBy.get(vertex).size() == 1
                    && fileWrittenBy
                        .get(vertex)
                        .toArray()[0]
                        .equals(getAnnotationSafe(newEdge.getSourceVertex(), "pid")))) {
              continue;
            }
          }
        }
      }

      resultGraph.putVertex(newEdge.getSourceVertex());
      resultGraph.putVertex(newEdge.getDestinationVertex());
      resultGraph.putEdge(newEdge);
    }

    return resultGraph;
  }