Java 类org.neo4j.graphdb.Node 实例源码

项目:flight-management-system-java    文件:Depart.java   
public void insertBd() {
    Result res;
    try (Transaction tx = db.beginTx()) {
        Node depart = db.createNode(Main.Tables.Depart);
        depart.setProperty("numero",numero);
        depart.setProperty("date",date);
        res = db.execute("MATCH (a:Avion), (d:Depart) WHERE a.numero="+avion+" AND d.numero="+numero+" CREATE (a)-[:Affecter]->(d)");
        res = db.execute("MATCH (v:Vol), (d:Depart) WHERE v.numero="+vol+" AND d.numero="+numero+" CREATE (v)-[:Constituer]->(d)");
        for (int i=0; i<passagers.size(); i++) {

            res = db.execute("MATCH (p:Passagers), (d:Depart) WHERE p.cin='"+passagers.get(i)+"' AND d.numero="+numero+" CREATE (p)-[:Enregistrer]->(d)");
        }
        for (int i=0; i<personnels.size(); i++) {
            res = db.execute("MATCH (p:Passagers), (d:Depart) WHERE p.cin='"+personnels.get(i)+"' AND d.numero="+numero+" CREATE (p)-[:Enregistrer]->(d)");
        }
        tx.success();
    }
     //res = db.execute("MATCH (d:Depart{date:'"+date+"'}), (p:Passager{cin:'"+passagers.get(0)+"'}) CREATE (p)-[r:Enregistrer]->(d)");
}
项目:neo4j-versioner-core    文件:Diff.java   
@Procedure(value = "graph.versioner.diff.from.current", mode = DEFAULT)
@Description("graph.versioner.diff.from.current(state) - Get a list of differences that must be applied to the given state in order to become the current entity state")
public Stream<DiffOutput> diffFromCurrent(
        @Name("state") Node state) {

    Optional<Node> currentState = Optional.ofNullable(state.getSingleRelationship(RelationshipType.withName(Utility.HAS_STATE_TYPE), Direction.INCOMING))
            .map(Relationship::getStartNode).map(entity -> entity.getSingleRelationship(RelationshipType.withName(Utility.CURRENT_TYPE), Direction.OUTGOING))
            .map(Relationship::getEndNode);

    Stream<DiffOutput> result = Stream.empty();

    if(currentState.isPresent() && !currentState.equals(Optional.of(state))){
        result = diffBetweenStates(Optional.of(state), currentState);
    }

    return result;
}
项目:neo4j-versioner-core    文件:Diff.java   
/**
 * It returns a {@link Stream<DiffOutput>} by the given nodes
 *
 * @param from
 * @param to
 * @return a {@link Stream<DiffOutput>}
 */
private Stream<DiffOutput> diffBetweenStates(Optional<Node> from, Optional<Node> to) {
    List<DiffOutput> diffs = new ArrayList<>();

    Map<String, Object> propertiesFrom = from.map(Node::getAllProperties).orElse(Collections.emptyMap());
    Map<String, Object> propertiesTo = to.map(Node::getAllProperties).orElse(Collections.emptyMap());

    //Getting updated and removed properties
    propertiesFrom.forEach((key, value) -> {
        Optional<Object> foundValue = Optional.ofNullable(propertiesTo.get(key));
        String operation = foundValue.map(val -> compareObj(val, value) ? "" : Utility.DIFF_OPERATION_UPDATE).orElse(Utility.DIFF_OPERATION_REMOVE);
        if(!operation.isEmpty()){
            diffs.add(new DiffOutput(operation, key, value, foundValue.orElse(null)));
        }
    });

    //Getting added properties
    propertiesTo.forEach((key, value) -> {
        if(!propertiesFrom.containsKey(key)) {
            diffs.add(new DiffOutput(Utility.DIFF_OPERATION_ADD, key, null, value));
        }
    });

    return diffs.stream().sorted((a, b) -> Integer.compare(Utility.DIFF_OPERATIONS_SORTING.indexOf(a.operation), Utility.DIFF_OPERATIONS_SORTING.indexOf(b.operation)));
}
项目:EvilCoder    文件:Traversals.java   
public static List<Pair<Long, String>> getIdAndCodeOfChildrenConnectedBy(
        Node node, String edgeType)
{
    List<Pair<Long, String>> retval = new LinkedList<Pair<Long, String>>();
    List<Node> children = getChildrenConnectedBy(node, edgeType);

    for (Node childNode : children)
    {
        String childCode = childNode.getProperty(NodeKeys.CODE).toString();
        Pair<Long, String> pair = new Pair<Long, String>(childNode.getId(),
                childCode);
        retval.add(pair);
    }

    return retval;
}
项目:EvilCoder    文件:Traversals.java   
public static List<Node> getParentsConnectedBy(Node node, String edgeType)
{
    List<Node> retval = new LinkedList<Node>();

    long nodeId = node.getId();

    Iterable<Relationship> rels = node.getRelationships();
    for (Relationship rel : rels)
    {
        if (!rel.getType().name().equals(edgeType))
            continue;
        Node parentNode = rel.getStartNode();
        if (parentNode.getId() == nodeId)
            continue;

        retval.add(parentNode);
    }
    return retval;
}
项目:instacart    文件:Evaluations.java   
static HashMap<String, Object> all( List<Node> lastOrdered, List<Node> predicted) {
    HashMap<String, Object> evaluations = new HashMap<>();
    ArrayList<Node> intersection = new ArrayList<>(lastOrdered);
    intersection.retainAll(predicted);

    Double precision = (double)intersection.size()/predicted.size();
    Double recall = (double) intersection.size()/lastOrdered.size();
    Double f1 = 2 * precision * recall / (precision + recall);

    evaluations.put("intersection", intersection);
    evaluations.put("precision", precision);
    evaluations.put("recall", recall);
    evaluations.put("f1", f1);

    return evaluations;
}
项目:EvilCoder    文件:Traversals.java   
public static List<Node> getCallsToForFunction(String source,
            long functionId)
    {
        List<Node> retval = new LinkedList<Node>();
// JANNIK
        String my = source;
        my = my.replace("*", "\\*");
        my = my.replace("(", "\\(");
        my = my.replace(")", "\\)");
        my = my.replace("-", "\\-");
        my = my.replace(" ", "\\ ");

        String query = String.format("%s:Callee AND %s:%s AND %s:%s", NodeKeys.TYPE, NodeKeys.FUNCTION_ID, functionId, NodeKeys.CODE, my);

        IndexHits<Node> hits = Neo4JDBInterface.queryIndex(query);
        for (Node n : hits)
        {
            List<Node> parents = getParentsConnectedBy(n, "IS_AST_PARENT");
            retval.add(parents.get(0));
        }
        return retval;
    }
项目:EvilCoder    文件:Traversals.java   
public static DDG getDDGForFunction(Node funcNode)
{
    DDG retval = new DDG();
    for (Node statement : Traversals.getStatementsForFunction(funcNode))
    {
        Iterable<Relationship> rels = statement
                .getRelationships(Direction.OUTGOING);
        long srcId = statement.getId();

        for (Relationship rel : rels)
        {
            if (!rel.getType().toString().equals(EdgeTypes.REACHES))
                continue;
            long dstId = rel.getEndNode().getId();
            String symbol = rel.getProperty("var").toString();
            retval.add(srcId, dstId, symbol);
        }

    }
    return retval;
}
项目:EvilCoder    文件:Remove_duplicated_edges.java   
public static void remove_duplicated_edges_in_function(Joern_db joern_db, Long func_id)
    {
     System.out.print("remove_duplicated_edges_in_function: ");
     System.out.println(func_id);

    List<Node> Ns = Pipeline.v(func_id).functionToStatements().to_list();
//    Ns = Ns[0]

    Long counter = new Long(0);
    Long of = new Long(Ns.size());
      for(Node n : Ns)
       {
        counter += 1;
        System.out.println(counter.toString() + " of " + of.toString());
        remove_duplicated_edges_of_node(joern_db, n.getId());
       }
    }
项目:EvilCoder    文件:Remove_duplicated_edges.java   
public static void main(String[] args) throws Exception
   {
     if(args.length != 1)
      {
       System.out.println("[/] Usage: <func_name>\n");
       System.exit(1);
      }
   String func_name = args[0];

   Joern_db joern_db = new Joern_db();
    joern_db.initialize();

   List<Node> hits = Joern_db.get_calls_to(func_name);
     for(Node h : hits)
      {
       remove_duplicated_edges_in_function(joern_db, (Long)h.getProperty("functionId"));
      }
//    remove_duplicated_edges();
    joern_db.g.commit();
   }
项目:EvilCoder    文件:Find_data_paths.java   
public static HashSet<Long> find_inflow_nodes_with_path_length(Joern_db joern_db, Long node_id, Long path_length, HashSet<Long> nodes_in_step_before)
{
ArrayList<Long> start_nodes = new ArrayList(nodes_in_step_before);
  if(!nodes_in_step_before.contains(node_id))
   {
    start_nodes.add(node_id);
   }
List<Node> nodes = Pipeline.v(start_nodes).in("CFG_EDGE").to_list();

HashSet<Long> new_node_ids = new HashSet();
  for(Node n : nodes)
   {
   Long id = n.getId();
     if(!nodes_in_step_before.contains(id))
      {
       new_node_ids.add(id);
      }
   }
 return new_node_ids;
}
项目:EvilCoder    文件:Find_data_paths.java   
public static void print_path(Joern_db joern_db, List<Long> path, List<String> var_names)
{
  for(int i=0, i_end=path.size(); i<i_end; ++i)
   {
   Long p = path.get(i);
   Node node = (Node)(Pipeline.v(p).to_list().get(0));
     if(node.hasProperty("code"))
      {
       System.out.println(p.toString() + "\t" + (String)(node.getProperty("code")));
      }
     else
      {
       System.out.println(p.toString());
      }
     if(var_names != null && i < path.size()-1)
      {
       System.out.println("\t" + var_names.get(i));
      }
   }
}
项目:EvilCoder    文件:Find_all_function_pointers.java   
public static void fill_externally_defined_functions(Joern_db joern_db)
   {
// completeType    extern void ( )
// baseType        extern void
// type            Decl
// identifier      extern_func
    if(externally_defined_functions != null) return;

    externally_defined_functions = new HashSet<>();
//    decls = joern_db.runGremlinQuery("queryNodeIndex('type:Decl').filter{it.completeType.startsWith('extern') && it.completeType.endsWith(')')}.identifier")
//    decls = joern_db.runGremlinQuery("g.V.filter{it.type == 'Decl' && it.completeType.startsWith('extern') && it.completeType.endsWith(')')}.identifier")

   List<Node> decl_nodes = Joern_db.queryNodeIndex("type:Decl");
     for(Node d : decl_nodes)
      {
      String completeType = (String)d.getProperty("completeType");
        if(completeType.startsWith("extern") && completeType.endsWith(")"))
         {
         String identifier = (String)d.getProperty("identifier");
          externally_defined_functions.add(identifier);
         }
      }
   }
项目:EvilCoder    文件:Find_all_function_pointers.java   
public static HashSet<String> find_all_func_names(Joern_db joern_db) throws Exception
{
 fill_glibc_function_names();
 fill_externally_defined_functions(joern_db);

HashSet<String> all_funcs = new HashSet(glibc_function_names);
  for(String it : externally_defined_functions) all_funcs.add(it);

 // get all function-defs, extract their names
List<Node> func_defs = joern_db.queryNodeIndex("type:FunctionDef");
  for(Node n : func_defs)
   {
   String code = (String)n.getProperty("code");
   String[] splitters = code.split(" ", -1);
    all_funcs.add(splitters[0]);
   }

 return all_funcs;
}
项目:rule_matcher    文件:Matcher.java   
@Procedure(name = "com.maxdemarzi.match.user", mode = Mode.READ)
@Description("CALL com.maxdemarzi.match.user(username) - find matching rules")
public Stream<NodeResult> matchUser(@Name("username") String username) throws IOException {
    // We start by finding the user
    Node user = db.findNode(Labels.User, "username", username);
    if (user != null) {
        // Gather all of their attributes in to a Set
        Set<Node> userAttributes = new HashSet<>();
        Collection<String> attributes = new HashSet<>();

        for (Relationship r : user.getRelationships(Direction.OUTGOING, RelationshipTypes.HAS)) {
            userAttributes.add(r.getEndNode());
            attributes.add((String)r.getEndNode().getProperty("id"));
        }
        // Find the rules
        Set<Node> rules = findRules(attributes, userAttributes);
        return rules.stream().map(NodeResult::new);
    }

    return null;
}
项目:EvilCoder    文件:Function_sets_parameter.java   
public static List<Long> retval_of_func(Joern_db joern_db, Long func_id)
    {
    List<Node> returns = Joern_db.queryNodeIndex("type:ReturnStatement AND functionId:" + func_id.toString());
//    print returns
    List<Long> candidates = new ArrayList<>();
      for(Node r : returns)
       {
       List<Node> ret_children = Pipeline.v(r.getId()).children().to_list();
        for(Node c : ret_children)
         {
          System.out.println("ret_child: " + new Long(c.getId()).toString());
          candidates.add(c.getId());
//            get_rhs_val(c)
         }
       }
     return candidates;
    }
项目:EvilCoder    文件:Function_sets_parameter.java   
public static String get_parameter_type(Joern_db joern_db, Long call_id, Long ith_argument)
{
List<Node> t = Pipeline.v(call_id).functionToStatements().has("type", "Parameter").has("childNum", ith_argument.toString()).children().has("type", "ParameterType").to_list();
Set<String> codes = new HashSet<>();
  for(Node n : t)
   {
    codes.add((String)(n.getProperty("code")));
   }
  if(codes.size() == 1)
   {
    return codes.iterator().next().trim();
   }
  else
   {
    return "";
   }
}
项目:instacart    文件:Predictions.java   
static ArrayList<Node> alternatingOrder (Node order) {
    ArrayList<Node> products = new ArrayList<>();
    Relationship prevRel = order.getSingleRelationship(RelationshipTypes.PREV, Direction.OUTGOING);
    if (prevRel != null) {
        Node prevOrder = prevRel.getEndNode();
        prevRel = prevOrder.getSingleRelationship(RelationshipTypes.PREV, Direction.OUTGOING);
        if (prevRel != null) {
            prevOrder = prevRel.getEndNode();
            for (Relationship r1 : prevOrder.getRelationships(Direction.OUTGOING, RelationshipTypes.HAS)) {
                Node product = r1.getEndNode();
                products.add(product);
            }
        }
    }
    return products;
}
项目:rule_matcher    文件:Matcher.java   
@Procedure(name = "com.maxdemarzi.match.attributes", mode = Mode.READ)
@Description("CALL com.maxdemarzi.match.attributes([attributes]) - find matching rules")
public Stream<NodeResult> matchAttributes(@Name("attributes") List<String> attributes) throws IOException {

    // We will gather all of the attribute nodes in to a Set
    Set<Node> userAttributes = new HashSet<>();

    // We start by finding the attributes
    for (String id : attributes) {
        Node attribute = db.findNode(Labels.Attribute, "id", id);
        if (attribute != null) {
            userAttributes.add(attribute);
        }
    }
    // Find the rules
    Set<Node> rules = findRules(attributes, userAttributes);
    return rules.stream().map(NodeResult::new);
}
项目:EvilCoder    文件:Pipeline.java   
public Pipeline functionToStatements()
{
 return (Pipeline)(this.transform(
          new PipeFunction<Neo4j2Vertex,List<Neo4j2Vertex>>()
           {
            public List<Neo4j2Vertex> compute(Neo4j2Vertex it)
             {
             List<Node> tmp = Joern_db.queryNodeIndex("isCFGNode:True AND functionId:" + it.getId().toString());
             List<Neo4j2Vertex> ret = new ArrayList<>();
               for(Node n : tmp)
                {
                 ret.add(new Neo4j2Vertex(n, Joern_db.g) );
                }
              return ret;
             }
           }
        ).scatter());
}
项目:EvilCoder    文件:Location.java   
public static String get_function_name_for_node_id(Joern_db joern_db, Long node_id) throws Exception
    {
    Long cur_id = node_id;
    Long func_id = null;
      while(true)
       {
        func_id = (Long)(((Node)(Pipeline.v(cur_id).to_list().get(0))).getProperty("functionId"));
         if(func_id != null)
          {
           break;
          }
        cur_id = get_general_parent(joern_db, cur_id);
//        print "cur_id:", cur_id
       }
    String func_name = (String)(((Node)(Pipeline.v(func_id).to_list().get(0))).getProperty("name"));
     return func_name;
    }
项目:EvilCoder    文件:Location.java   
public static String get_location_for_node_id(Joern_db joern_db, Long node_id) throws Exception
    {
    Long cur_id = node_id;
    String location = null;
      while(true)
       {
       List<Node> nodes = Pipeline.v(cur_id).to_list();
       Node first = nodes.get(0);
         if(first.hasProperty("location"))
          {
           location = (String)(first.getProperty("location"));
           break;
          }
        cur_id = get_general_parent(joern_db, cur_id);
//        print "cur_id:", cur_id
       }
     return location;
    }
项目:neo4j-versioner-sql    文件:Init.java   
@Procedure(value = "sql.versioner.init", mode = Mode.WRITE)
@Description("sql.versioner.init(dbname, hostname, port, database, username, password) - Initialize a Database Version with its schemas, tables and relative columns.")
public Stream<NodeOutput> init(
        @Name("dbName") String dbName,
        @Name("hostname") String hostname,
        @Name("port") Long port,
        @Name("database") String databaseName,
        @Name("username") String username,
        @Name("password") String password){

    DatabaseImporter databaseImporter = DatabaseImporterFactory.getSQLDatabase(dbName);
    databaseImporter.connect(hostname, port, databaseName, username, password);

    Database database = loadDatabaseFromDBMS(databaseImporter);

    databaseImporter.disconnect();

    Neo4jPersistence persistence = new Neo4jPersistence(db, log);
    Node databaseNode = persistence.persist(database);

    return Stream.of(new NodeOutput(databaseNode));
}
项目:kowalski    文件:GraphDatabaseOperations.java   
public void mergeArtifact(org.eclipse.aether.artifact.Artifact artifactModel) {
    this.artifactCache.getOrPut(artifactModel, () -> {
        String cypherQuery = "MERGE (artifact:ARTIFACT {groupId: {groupId}, artifactId: {artifactId}, version: {version}, extension: {extension}, hash: {hash}%s}) RETURN artifact";
        Map<String, Object> parameters = new HashMap<>();
        parameters.put("groupId", artifactModel.getGroupId());
        parameters.put("artifactId", artifactModel.getArtifactId());
        parameters.put("version", artifactModel.getVersion());
        parameters.put("extension", artifactModel.getExtension());
        if (!artifactModel.getClassifier().isEmpty()) {
            cypherQuery = String.format(cypherQuery, ", classifier: {classifier}%s");
            parameters.put("classifier", artifactModel.getClassifier());
        }
        parameters.put("hash", this.hash(parameters.values().toArray(new String[0])));
        cypherQuery = String.format(cypherQuery, "");
        try (Result result = this.graphDatabaseService.execute(cypherQuery, parameters)) {
            return result.<Node>columnAs("artifact").next();
        }
    });
}
项目:neo4j-ml-procedures    文件:DL4JMLModel.java   
@Override
    List<Node> show() {
        if ( state != State.ready ) throw new IllegalStateException("Model not trained yet");
        List<Node> result = new ArrayList<>();
        int layerCount = model.getnLayers();
        for (Layer layer : model.getLayers()) {
            Node node = node("Layer",
                    "type", layer.type().name(), "index", layer.getIndex(),
                    "pretrainLayer", layer.isPretrainLayer(), "miniBatchSize", layer.getInputMiniBatchSize(),
                    "numParams", layer.numParams());
            if (layer instanceof DenseLayer) {
                DenseLayer dl = (DenseLayer) layer;
                node.addLabel(Label.label("DenseLayer"));
                node.setProperty("activation",dl.getActivationFn().toString()); // todo parameters
                node.setProperty("biasInit",dl.getBiasInit());
                node.setProperty("biasLearningRate",dl.getBiasLearningRate());
                node.setProperty("l1",dl.getL1());
                node.setProperty("l1Bias",dl.getL1Bias());
                node.setProperty("l2",dl.getL2());
                node.setProperty("l2Bias",dl.getL2Bias());
                node.setProperty("distribution",dl.getDist().toString());
                node.setProperty("in",dl.getNIn());
                node.setProperty("out",dl.getNOut());
            }
            result.add(node);
//            layer.preOutput(allOne, Layer.TrainingMode.TEST);
//            layer.p(allOne, Layer.TrainingMode.TEST);
//            layer.activate(allOne, Layer.TrainingMode.TEST);
        }
        return result;
    }
项目:neo4j-versioner-core    文件:Rollback.java   
/**
 * This method returns the first available State node, by a given State node to rollback
 *
 * @param state state to rollback
 * @return the first available rollback node
 */
private Optional<Node> getFirstAvailableRollbackNode(Node state) {
    return StreamSupport.stream(state.getRelationships(RelationshipType.withName(Utility.ROLLBACK_TYPE), Direction.OUTGOING).spliterator(), false).findFirst()
            // Recursive iteration for ROLLBACKed State node
            .map(e -> getFirstAvailableRollbackNode(e.getEndNode()))
            // No ROLLBACK relationship found
            .orElse(StreamSupport.stream(state.getRelationships(RelationshipType.withName(Utility.PREVIOUS_TYPE), Direction.OUTGOING).spliterator(), false)
                    .findFirst().map(Relationship::getEndNode));
}
项目:flight-management-system-java    文件:Naviguant.java   
public void insertBd() {
    super.insertBd();
    try (Transaction tx = db.beginTx()) {
        Node vols = db.createNode(Main.Tables.Naviguant);
        vols.setProperty("cin",super.getCin());
        vols.setProperty("numPassport",super.getNumPassport());
        vols.setProperty("nom",super.getNom());
        vols.setProperty("adresse",super.getAdresse());
        vols.setProperty("telephone",super.getTelephone());
        tx.success();
    }
}
项目:EvilCoder    文件:Traversals.java   
public static List<String> getCodeOfChildrenConnectedBy(Node node,
        String edgeType)
{
    List<String> retval = new LinkedList<String>();

    List<Node> children = getChildrenConnectedBy(node, edgeType);
    for (Node childNode : children)
    {
        String childCode = childNode.getProperty(NodeKeys.CODE).toString();
        retval.add(childCode);
    }
    return retval;
}
项目:power_grid    文件:Energization.java   
@POST
public Response energization(String body, @Context GraphDatabaseService db) throws IOException {
    HashMap input = Validators.getValidEquipmentIds(body);

    Set<Node> startingEquipment = new HashSet<>();
    Set results = new HashSet<>();
    ArrayList<Long> skip = new ArrayList<>();

    try (Transaction tx = db.beginTx()) {
        ((Collection) input.get("ids")).forEach((id) -> startingEquipment.add(db.findNode(Labels.Equipment, "equipment_id", id)));

        if (startingEquipment.isEmpty()) {
            throw Exceptions.equipmentNotFound;
        }

        startingEquipment.forEach(bus -> {
            InitialBranchState.State<Double> ibs;
            ibs = new InitialBranchState.State<>((Double) bus.getProperty("voltage", 999.0), 0.0);
            TraversalDescription td = db.traversalDescription()
                    .depthFirst()
                    .expand(expander, ibs)
                    .uniqueness(Uniqueness.NODE_GLOBAL)
                    .evaluator(evaluator);

            for (org.neo4j.graphdb.Path position : td.traverse(bus)) {
                Node endNode = position.endNode();
                if (!skip.contains(endNode.getId())) {
                    results.add(position.endNode().getProperty("equipment_id"));
                    skip.add(endNode.getId());
                }

                endNode.setProperty("Energized", true);
            }
        });
        tx.success();
    }
    return  Response.ok().entity(objectMapper.writeValueAsString(results)).build();
}
项目:EvilCoder    文件:Traversals.java   
public static String getCalleeFromCall(Long nodeId)
{
    Node node = Neo4JDBInterface.getNodeById(nodeId);
    Iterable<Relationship> rels = node.getRelationships();
    for (Relationship rel : rels)
    {
        if (!rel.getType().name().equals(EdgeTypes.IS_AST_PARENT))
            continue;

        Node endNode = rel.getEndNode();

        if (endNode.getId() == node.getId())
            continue;

        try
        {
            String childNumStr = (String) endNode
                    .getProperty(NodeKeys.CHILD_NUMBER);
            if (childNumStr.equals("0"))
                return endNode.getProperty(NodeKeys.CODE).toString();
        }
        catch (RuntimeException ex)
        {
            return endNode.getProperty(NodeKeys.CODE).toString();
        }
    }
    return "";
}
项目:flight-management-system-java    文件:Pilote.java   
public void insertBd() {
    super.insertBd();
    try (Transaction tx = db.beginTx()) {
        Node vols = db.createNode(Main.Tables.Pilote);
        vols.setProperty("cin",super.getCin());
        vols.setProperty("numPassport",super.getNumPassport());
        vols.setProperty("nom",super.getNom());
        vols.setProperty("adresse",super.getAdresse());
        vols.setProperty("telephone",super.getTelephone());
        tx.success();
    }
}
项目:EvilCoder    文件:ArgumentTainter.java   
private void determineFunctionsToPatch(String source)
{
    List<Node> hits = Traversals.getCallsTo(source);
    for (Node callASTNode : hits)
    {
        Long functionId = Traversals.getFunctionIdFromASTNode(callASTNode);
        functionsToPatch.add(functionId);   
    }

}
项目:EvilCoder    文件:FunctionPatcher.java   
private void determineCallsToPatch(Long funcId)
{
    List<Node> callNodes = Traversals.getCallsToForFunction(sourceToPatch,
            funcId);
    for (Node callNode : callNodes)
    {

        Node parent = Traversals.getStatementForASTNode(callNode);

        statementsToPatch.add(parent);
    }
}
项目:EvilCoder    文件:DDGPatcher.java   
public void patchDDG(DefUseCFG defUseCFG, Long funcId)
{
    Node node = Neo4JDBInterface.getNodeById(funcId);

    DDG oldDDG = Traversals.getDDGForFunction(node);
    DDGCreator ddgCreator = new DDGCreator();
    DDG newDDG = ddgCreator.createForDefUseCFG(defUseCFG);

    diff = oldDDG.difference(newDDG);
}
项目:EvilCoder    文件:DDGPatcher.java   
private void removeOldEdges(DDGDifference diff)
{
    List<DefUseRelation> relsToRemove = diff.getRelsToRemove();

    for (DefUseRelation rel : relsToRemove)
    {
        Node srcStatement = Neo4JDBInterface.getNodeById((Long) rel.src);

        Iterable<Relationship> rels = srcStatement
                .getRelationships(Direction.OUTGOING);

        for (Relationship reachRel : rels)
        {
            if (!reachRel.getType().name().equals(EdgeTypes.REACHES))
                continue;

            if (reachRel.getEndNode().getId() != (Long) rel.dst)
                continue;

            Object var = reachRel.getProperty("var");
            if (var == null || !var.toString().equals(rel.symbol))
                continue;

            Neo4JDBInterface.removeEdge(reachRel.getId());
        }
    }
}
项目:EvilCoder    文件:DefUseCFGPatcher.java   
public void writeChangesToDatabase()
{
    if (defUseCFG == null)
    {
        return;
    }

    for (DefUseLink link : newlyAddedLinks)
    {
        Long fromId = link.statement;
        Long toId = (Long) defUseCFG.getIdForSymbol(link.symbol);

        if (toId == null)
        {
            Map<String, Object> properties = new HashMap<String, Object>();
            Node statementNode = Neo4JDBInterface.getNodeById(link.statement);

            properties.put("functionId", statementNode.getProperty("functionId"));
            properties.put("type", "Symbol");
            properties.put("code", link.symbol);

            Node symbolNode = Neo4JDBInterface.addNode(properties);
            toId = (Long) symbolNode.getId();
        }

        RelationshipType relType = DynamicRelationshipType
                .withName(EdgeTypes.DEF);
        Neo4JDBInterface.addRelationship(fromId, toId, relType, null, true); //JANNIK: added flag
    }


}
项目:EvilCoder    文件:Retrace_arg_till_source.java   
@Override
   public Void call() throws Exception
    {
     System.out.println("STARTING ON " + task_id + ": " + call_id.toString() + ", " + ith_argument.toString());

    Node arg = null;
      while(true)
       {
         try
          {
           arg = Find_data_paths.get_argument_i(joern_db, call_id, ith_argument);
           break;
          }
         catch(Exception e)
          {
           ;
          }
       }
//    print "arg:", arg
    List<String> var_names = Find_data_paths.get_arg_variables(joern_db, arg.getId());
//    print "var_names:", var_names
      for(String v : var_names)
       {
        Find_data_paths.get_defs_of(joern_db, arg.getId(), v, task_id, ergo_set, had_already);
       }

     return null;
    }
项目:EvilCoder    文件:Find_data_paths.java   
public static Node get_argument_i(Joern_db joern_db, Long node_id, Long ith_argument) throws Exception
{
List<Node> it = Pipeline.v(node_id).callToArguments().has("childNum", ith_argument.toString()).to_list();
  if(it.size() != 1)
   {
    throw new Exception("Expected length 1: " + node_id.toString() + " " + ith_argument.toString());
   }
 return it.get(0);
}
项目:flight-management-system-java    文件:Passager.java   
public void insertBd() {
    super.insertBd();
    try (Transaction tx = db.beginTx()) {
        Node vols = db.createNode(Main.Tables.Passager);
        vols.setProperty("cin",super.getCin());
        vols.setProperty("numPassport",super.getNumPassport());
        vols.setProperty("nom",super.getNom());
        vols.setProperty("adresse",super.getAdresse());
        vols.setProperty("telephone",super.getTelephone());
        tx.success();
    }
}
项目:EvilCoder    文件:Find_data_paths.java   
public static Long get_deepest_child_using(Joern_db joern_db, Long node_id, String var_name_together)
   {
   Long deepest = new Long(node_id);
   Long before = new Long(node_id);
     while(true)
      {
      Set<Long> childs = Function_sets_parameter.get_all_children(joern_db, deepest);
//        print "childs:", childs
      Boolean found_other = false;
        for(Long c : childs)
         {
         List<Node> uses = Pipeline.v(c).uses().to_list();
           for(Node u : uses)
            {
            String code = (String)(u.getProperty("code"));
            String u_together = member_to_var_name(Function_sets_parameter.split_into_elements(code));
              if(u_together.equals(var_name_together))
               {
//                  print "new deepest:", c
                deepest = c;
                found_other = true;
                break;
               }
              if(found_other)
               {
                break;
               }
            }
         }
        if(deepest == before)
         {
          break;
         }
        before = deepest;
      }
    return deepest;
   }