Exemple #1
0
    def add_file(self):
        """Adds a new File

        Create a new File from the form passed in the ``POST`` data. Each file
        should be passed in the ``files`` parameter. Multiple files can be
        added in one request.
        The file body will be stored as an AttachedFile object.

        :<file form parameter: Field containing file(s) to store
        :<unzip form parameter ([true|false]): Uncompress archive and add files
        separately
        """
        files = save_uploaded_files()

        return render_json(files)
Exemple #2
0
    def add_file(self):
        """Adds a new File

        Create a new File from the form passed in the ``POST`` data. Each file
        should be passed in the ``files`` parameter. Multiple files can be
        added in one request.
        The file body will be stored as an AttachedFile object.

        :<file form parameter: Field containing file(s) to store
        :<unzip form parameter ([true|false]): Uncompress archive and add files
        separately
        """
        files = save_uploaded_files()

        return render_json(files)
Exemple #3
0
    def run(self, id):
        """Runs a One-Shot Analytics

        Asynchronously runs a One-Shot Analytics against a given observable.
        Returns an ``AnalyticsResults`` instance, which can then be used to fetch
        the analytics results

        :query ObjectID id: Analytics ID
        :form ObjectID id: Observable ID
        :>json object: JSON object representing the ``AnalyticsResults`` instance
        """
        analytics = get_object_or_404(self.objectmanager, id=id)
        observable = get_object_or_404(Observable, id=request.form.get('id'))

        result = analytics.run(observable, current_user.settings).to_mongo()
        result.pop('settings')
        return render_json(result)
Exemple #4
0
    def get(self, klass, node_id):
        klass = NODES_CLASSES[klass.lower().split('.')[0]]
        node = klass.objects.get(id=node_id)

        result = {'links': list(), 'nodes': list()}

        result['nodes'].append(node.to_mongo())

        node_ids = set()
        links = list(set(list(node.incoming()) + list(node.outgoing())))

        for link, node in links:
            if node.id not in node_ids:
                node_ids.add(node)
                result['nodes'].append(node.to_mongo())

            result['links'].append(link.to_dict())

        return render_json(result)
Exemple #5
0
    def get(self, klass, node_id):
        klass = NODES_CLASSES[klass.lower().split('.')[0]]
        node = klass.objects.get(id=node_id)

        result = {'links': list(), 'nodes': list()}

        result['nodes'].append(node.to_mongo())

        node_ids = set()
        links = list(set(list(node.incoming()) + list(node.outgoing())))

        for link, node in links:
            if node.id not in node_ids:
                node_ids.add(node)
                result['nodes'].append(node.to_mongo())

            result['links'].append(link.to_dict())

        return render_json(result)