262f2dd76cd516d0be4a73e87e72a39938a18795,poseidon/poseidonStorage/poseidonStorage.py,db_collection_query,on_get,#db_collection_query#Any#Any#Any#Any#Any#,155

Before Change


    def on_get(self, req, resp, database, collection, query_str):
        try:
            query = urllib.unquote(query_str).decode("utf8")
            query = ast.literal_eval(query_str)
            cursor = self.client[database][collection].find(query)
            ret = ""
            for doc in cursor:
                ret += json.dumps(doc)

After Change


            query = bson.BSON.decode(query_str)
            cursor = self.client[database][collection].find(query)
            doc_dict = {}
            if cursor.count() == 0:
                ret["count"] = cursor.count()
                ret["docs"] = "Valid query performed, no docs found."
            else:
                for doc in cursor:
                    doc_dict[doc["node_ip"]] = doc
                ret["docs"] = doc_dict
                ret["count"] = cursor.count()
            ret = json.dumps(ret)
        except:
            ret["count"] = -1
            ret["docs"] = "Error on query."
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: CyberReboot/poseidon
Commit Name: 262f2dd76cd516d0be4a73e87e72a39938a18795
Time: 2016-08-10
Author: tlanham@cs.stanford.edu
File Name: poseidon/poseidonStorage/poseidonStorage.py
Class Name: db_collection_query
Method Name: on_get


Project Name: CyberReboot/poseidon
Commit Name: 262f2dd76cd516d0be4a73e87e72a39938a18795
Time: 2016-08-10
Author: tlanham@cs.stanford.edu
File Name: poseidon/poseidonStorage/poseidonStorage.py
Class Name: db_add_one_doc
Method Name: on_get


Project Name: CyberReboot/poseidon
Commit Name: ec8602f95ff5916925c54a9adfc867112b2d5b70
Time: 2016-08-09
Author: tlanham@cs.stanford.edu
File Name: poseidon/poseidonStorage/poseidonStorage.py
Class Name: db_add_one_doc
Method Name: on_get