Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Timesketch - Collaborative timeline analysis
https://github.com/google/timesketch/

Timesketch is developed by (in alphabetical order):

* Google Inc. (*@google.com)
* Johan Berggren (jberggren@gmail.com)

To reach the authors, please use the Timesketch development mailing
list <timesketch-dev@googlegroups.com>.
59 changes: 59 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
### Contributing

#### Before you contribute

We love contributions! Read this page (including the small print at the end).

Before we can use your code, you must sign the [Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1) (CLA), which you can do online. The CLA is necessary mainly because you own the copyright to your changes, even after your contribution becomes part of our codebase, so we need your permission to use and distribute your code. We also need to be sure of various other things—for instance that you'll tell us if you know that your code infringes on other people's patents. You don't have to sign the CLA until after you've submitted your code for review and a member has approved it, but you must do it before we can put your code into our codebase. Before you start working on a larger contribution, you should get in touch with us first through the issue tracker with your idea so that we can help out and possibly guide you. Coordinating up front makes it much easier to avoid frustration later on.

We use the github [fork and pull review process](https://help.github.com/articles/using-pull-requests) to review all contributions. First, fork the timesketch repository by following the [github instructions](https://help.github.com/articles/fork-a-repo). Then check out your personal fork:

$ git clone https://github.com/<username>/timesketch.git

Add an upstream remote so you can easily keep up to date with the main repository:

$ git remote add upstream https://github.com/google/timesketch.git

To update your local repo from the main:

$ git pull upstream master

Please follow the Style Guide and make your changes. Once you're ready for review make sure the tests pass:

$ yarn install
$ python ./run_tests.py

Commit your changes to your personal fork and then use the GitHub Web UI to create and send the pull request. We'll review and merge the change.

#### Code review

All submissions, including submissions by project members, require review. To keep the code base maintainable and readable all code is developed using a similar coding style. It ensures:

The code is easy to maintain and understand. As a developer you'll sometimes find yourself thinking hmm, what is the code supposed to do here. It is important that you should be able to come back to code 5 months later and still quickly understand what it supposed to be doing. Also for other people that want to contribute it is necessary that they need to be able to quickly understand the code. Be that said, quick-and-dirty solutions might work in the short term, but we'll ban them from the code base to gain better long term quality.
With the code review process we ensure that at least two eyes looked over the code in hopes of finding potential bugs or errors (before they become bugs and errors). This also improves the overall code quality and makes sure that every developer knows to (largely) expect the same coding style.

Exception: Auto generated UI builds
PRs with only auto generated builds of the UI frontend (no new code) made by core project members (repo admins and maintainers with merge permissions) may be merged without review (by repo admins). Rational: All code in the build have already been reviewed.

#### Documentation review

One exception from the code review policy outlined above is simple documentation updates and additions made by core project members (repo admins and maintainers with merge permissions). These can be merged without review.

Note: Any change that affects the layout and structure of the site (timesketch.org) has to go through the review process and any update from external contributors has to be reviewed as well.

#### Style guide

We primarily follow the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html). Various Timesketch specific additions/variations are:

- Quote strings as ' or """ instead of "
- Textual strings should be Unicode strings and hence defined as u'string'
Use the format() function instead of the %-way of formatting strings.
Use positional or parameter format specifiers with typing e.g. '{0:s}' or '{text:s}' instead of '{0}', '{}' or '{:s}'. If we ever want to have language specific output strings we don't need to change the entire codebase. It also makes is easier in determining what type every parameter is expected to be.
- Use "cls" as the name of the class variable in preference of "klass"
- When catching exceptions use "as exception:" not some alternative form like "as error:" or "as details:"
- Use textual pylint overrides e.g. "# pylint: disable=no-self-argument" instead of "# pylint: disable=E0213". For a list of overrides see: http://docs.pylint.org/features.html

#### The small print

Contributions made by corporations are covered by a different agreement than
the one above, the Software Grant and Corporate Contributor License Agreement.
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
include LICENSE README.md
include AUTHORS LICENSE README.md
include requirements.txt test_requirements.txt
include run_tests.py
exclude .gitignore
exclude *.pyc
recursive-include config *
recursive-include data *
recursive-include timesketch/frontend/dist *
recursive-include timesketch/frontend-ng/dist *
recursive-include timesketch/lib/experimental *.cql
recursive-include timesketch/static *
recursive-include timesketch/templates *
recursive-exclude timesketch *.pyc
5 changes: 4 additions & 1 deletion api_client/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
"""This is the setup file for the project."""
from __future__ import unicode_literals

from setuptools import find_packages, setup
from setuptools import find_packages
from setuptools import setup

from timesketch_api_client import version


long_description = (
"The Timesketch API client provides you with a set of Python libraries "
"to connect to your Timesketch (https://github.com/google/timesketch) "
Expand Down
27 changes: 14 additions & 13 deletions api_client/python/timesketch_api_client/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def _run_aggregator(
"""Run an aggregator class.

Args:
aggregator_name: the name of the aggregator class.
parameters: a dict with the parameters for the aggregation class.
search_id: an optional integer value with a primary key to a
aggregator_name (str): the name of the aggregator class.
parameters (dict): a dict with the parameters for the aggregation class.
search_id (int): an optional integer value with a primary key to a
saved search.
chart_type: string with the chart type.
chart_type (str): string with the chart type.

Returns:
A dict with the aggregation results.
Expand Down Expand Up @@ -136,13 +136,13 @@ def _run_aggregator(

return error.get_response_json(response, logger)

# pylint: disable=arguments-differ
# pylint: disable=arguments-renamed
def from_saved(self, aggregation_id):
"""Initialize the aggregation object from a saved aggregation.

Args:
aggregation_id: integer value for the stored
aggregation (primary key).
aggregation_id (int): integer value for the stored
aggregation (primary key).
"""
resource_uri = "sketches/{0:d}/aggregation/{1:d}/".format(
self._sketch.id, aggregation_id
Expand Down Expand Up @@ -188,7 +188,8 @@ def from_manual(self, aggregate_dsl, **kwargs):
"""Initialize the aggregation object by running an aggregation DSL.

Args:
aggregate_dsl: OpenSearch aggregation query DSL string.
aggregate_dsl (str): OpenSearch aggregation query DSL string.
kwargs: Optional arguments
"""
super().from_manual(**kwargs)
resource_url = "{0:s}/sketches/{1:d}/aggregation/explore/".format(
Expand Down Expand Up @@ -225,12 +226,12 @@ def from_aggregator_run(
"""Initialize the aggregation object by running an aggregator class.

Args:
aggregator_name: name of the aggregator class to run.
aggregator_parameters: a dict with the parameters of the aggregator
aggregator_name (str): name of the aggregator class to run.
aggregator_parameters (dict): a dict with the parameters of the aggregator
class.
search_id: an optional integer value with a primary key to a saved
search_id (int): an optional integer value with a primary key to a saved
search.
chart_type: optional string with the chart type.
chart_type (str): optional string with the chart type.
"""
self.type = "aggregator_run"
self._parameters = aggregator_parameters
Expand Down Expand Up @@ -600,7 +601,7 @@ def from_dict(self, group_dict):
agg_obj.from_saved(agg_id)
self._aggregations.append(agg_obj)

# pylint: disable=arguments-differ
# pylint: disable=arguments-renamed
def from_saved(self, group_id):
"""Feed group data from a group ID.

Expand Down
7 changes: 5 additions & 2 deletions api_client/python/timesketch_api_client/aggregation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
# limitations under the License.
"""Tests for the Timesketch API aggregation object."""
import unittest
import mock

import altair as alt
import mock

from . import aggregation, client, test_lib
from . import aggregation
from . import client
from . import test_lib


class AggregationTest(unittest.TestCase):
Expand All @@ -29,6 +31,7 @@ def setUp(self):
self.api_client = client.TimesketchApi("http://127.0.0.1", "test", "test")
self.sketch = self.api_client.get_sketch(1)

# pylint: disable=protected-access
def test_init(self):
"""Tests the Aggregation init method."""
aggregation_obj = aggregation.Aggregation(self.sketch)
Expand Down
Loading
Loading