How to use timesketch - 10 common examples

To help you get started, we’ve selected a few timesketch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / timesketch / timesketch / lib / testlib.py View on Github external
def _commit_to_database(self, model):
        """Add object to the database session and commit.

        Args:
            model: Instance of timesketch.models.[model] object
        """
        db_session.add(model)
        db_session.commit()
github google / timesketch / timesketch / lib / testlib.py View on Github external
def _create_view(self, name, sketch, user):
        """Create a view in the database.

        Args:
            name: Name of the view (string)
            sketch: A sketch (instance of timesketch.models.sketch.Sketch)
            user: A user (instance of timesketch.models.user.User)

        Returns:
            A view (instance of timesketch.models.sketch.View)
        """
        view = View(
            name=name,
            query_string=name,
            query_filter=json.dumps(dict()),
            user=user,
            sketch=sketch)
        self._commit_to_database(view)
        return view
github google / timesketch / timesketch / lib / testlib.py View on Github external
def _create_searchindex(self, name, user, acl=False):
        """Create a searchindex in the database.

        Args:
            name: Name of the searchindex (string)
            user: A user (instance of timesketch.models.user.User)
            acl: Boolean value to decide if ACL permissions should be set

        Returns:
            A searchindex (instance of timesketch.models.sketch.SearchIndex)
        """
        searchindex = SearchIndex.get_or_create(
            name=name, description=name, index_name=name, user=user)
        if acl:
            for permission in ['read', 'write', 'delete']:
                searchindex.grant_permission(permission=permission, user=user)
        self._commit_to_database(searchindex)
        return searchindex
github google / timesketch / timesketch / lib / testlib.py View on Github external
def _create_user(self, username, set_password=False):
        """Create a user in the database.

        Args:
            username: Username (string)
            set_password: Boolean value to decide if a password should be set
        Returns:
            A user (instance of timesketch.models.user.User)
        """
        user = User.get_or_create(username=username)
        if set_password:
            user.set_password(plaintext='test', rounds=4)
        self._commit_to_database(user)
        return user
github google / timesketch / timesketch / apps / sketch / tests.py View on Github external
def setUp(self):
        self.user = User.objects.create(username="testuser")
        self.sketch = Sketch.objects.create(
            user=self.user, title="testsketch1")
        self.timeline = Timeline.objects.create(
            user=self.user, title="test", datastore_index="123456")
        self.sketch_timeline = SketchTimeline.objects.create(
            timeline=self.timeline, user=self.user, sketch=self.sketch)
github google / timesketch / timesketch / apps / sketch / tests.py View on Github external
def setUp(self):
        self.user1 = User.objects.create(username="testuser1")
        self.user2 = User.objects.create(username="testuser2")
        self.sketch1 = Sketch.objects.create(
            user=self.user1, title="testsketch1")
        self.sketch2 = Sketch.objects.create(
            user=self.user1, title="testsketch2")
        SavedView.objects.create(
            user=self.user1, sketch=self.sketch2, query="", filter="")
        self.sketch1.make_public(self.user1)
        self.sketch2.make_private(self.user1)
github google / timesketch / timesketch / apps / sketch / tests.py View on Github external
def setUp(self):
        self.user1 = User.objects.create(username="testuser1")
        self.user2 = User.objects.create(username="testuser2")
        self.sketch1 = Sketch.objects.create(
            user=self.user1, title="testsketch1")
        self.sketch2 = Sketch.objects.create(
            user=self.user1, title="testsketch2")
        SavedView.objects.create(
            user=self.user1, sketch=self.sketch2, query="", filter="")
        self.sketch1.make_public(self.user1)
        self.sketch2.make_private(self.user1)
github google / timesketch / timesketch / apps / acl / tests.py View on Github external
def setUp(self):
        self.user = User.objects.create(username='user1')
        self.sketch1 = Sketch.objects.create(user=self.user, title='sketch1')
        self.sketch2 = Sketch.objects.create(user=self.user, title='sketch2')
        self.sketch1.make_public(self.user)
        self.sketch2.make_private(self.user)
        self.ace = self.sketch1.acl.create(user=self.user)
        # Make the sketch public again to catch the case where an public ace is
        # already present.
        self.sketch1.make_public(self.user)
github google / timesketch / timesketch / apps / api / tests.py View on Github external
def _create_sketch(self, user):
        """Creates a sketch, comment and saved view to be used in the tests.

        Returns:
            Sketch object (instance of timesketch.apps.sketch.models.Sketch)
        """
        sketch = Sketch.objects.create(user=user, title='Test')
        EventComment.objects.create(
            user=user, body='test', sketch=sketch, datastore_id='test',
            datastore_index='test')
        SavedView.objects.create(
            user=user, sketch=sketch, query="Test",
            filter=json.dumps({'foo': 'bar'}), name="Test")
        return sketch
github google / timesketch / timesketch / apps / acl / tests.py View on Github external
def setUp(self):
        self.user = User.objects.create(username='user1')
        self.sketch1 = Sketch.objects.create(user=self.user, title='sketch1')
        self.sketch2 = Sketch.objects.create(user=self.user, title='sketch2')
        self.sketch1.make_public(self.user)
        self.sketch2.make_private(self.user)
        self.ace = self.sketch1.acl.create(user=self.user)
        # Make the sketch public again to catch the case where an public ace is
        # already present.
        self.sketch1.make_public(self.user)