internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mozilla/telemetry-analysis-service

Issue:
Support SameSite cookie attribute on sessionid
Firefox 60 introduces support for the SameSite cookie attribute: https://blog.mozilla.org/security/2018/04/24/same-site-cookies-in-firefox-60/
This provides significant protection against CSRF vulnerabilities and so it should be applied to the sessionid cookie.
It looks like its been added to Django https://code.djangoproject.com/ticket/27863 but the fix doesnt appear the be in the latest release or on older streams.
We have various other services that are also on django 1.11.x so I'll look into whether we can get the fix back-ported to that stream.


Discussion:
Unfortunately 1.11 is only receiving data loss and security fixes: https://code.djangoproject.com/ticket/29409 :(
Django 2.1 is [out in August](https://code.djangoproject.com/wiki/Version2.1Roadmap), which fits well the timeframe to work on ATMO again. I don't think this should be tried to be implemented as a 3rd party app right now given the non-trivial [implementation of the patch](https://github.com/django/django/pull/9860/files).
@psiinon Just saw a bunch of Django sites have been asked to do this, please make sure we use the same solution in the interim to 2.1.
@jezdez yes, pontoon are looking to support this via middleware: https://github.com/mozilla/pontoon/pull/964
I'm hoping this will be a common solution that other apps can use as well.
I talked with at IRC @psiinon the plan is to create a small Django package with this middleware and push it to Pypi today.
@jotes Thanks for releasing this as an app!

Resolving patch:
diff --git a/atmo/settings.py b/atmo/settings.py
--- a/atmo/settings.py
+++ b/atmo/settings.py
@@ -339,6 +339,7 @@ class Core(AWS, Celery, Constance, CSP, Configuration):
     ]
 
     MIDDLEWARE = (
+        'django_cookies_samesite.middleware.CookiesSameSite',
         'django.middleware.security.SecurityMiddleware',
         'dockerflow.django.middleware.DockerflowMiddleware',
         'whitenoise.middleware.WhiteNoiseMiddleware',
@@ -452,6 +453,9 @@ def AWS_DEFAULT_REGION(self):
     WHITENOISE_ALLOW_ALL_ORIGINS = False
     SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
     SESSION_CACHE_ALIAS = 'default'
+    SESSION_COOKIE_SAMESITE = 'Lax'
+    # in addition to sessionid and csrftoken cookies we use this cookie:
+    SESSION_COOKIE_SAMESITE_KEYS = ['news_current']
 
     SILENCED_SYSTEM_CHECKS = [
         'security.W003',  # We're using django-session-csrf
@@ -672,6 +676,7 @@ class Stage(Base):
     # Mark session and CSRF cookies as being HTTPS-only.
     CSRF_COOKIE_SECURE = True
     SESSION_COOKIE_SECURE = True
+    SESSION_COOKIE_SAMESITE = 'Strict'
     SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
     SECURE_BROWSER_XSS_FILTER = True
     SECURE_CONTENT_TYPE_NOSNIFF = True


Test patch:
Repository: OpenMined/PySyft

Issue:
Inplace methods in TensorBase class not inplace
Some of our inplace methods in the TensorBase class are not inplace.

**Example**
For addition,
Inplace: `self.data += tensor.data`
Not inplace: `self.data = self.data + tensor.data`

**Task**
Modify `__iadd__`, `__isub__`, `__imul__`, `__itruediv__` to be inplace operations following the above example.


Discussion:

Resolving patch:
diff --git a/syft/tensor.py b/syft/tensor.py
--- a/syft/tensor.py
+++ b/syft/tensor.py
@@ -63,7 +63,7 @@ def __iadd__(self, tensor):
             return NotImplemented
 
         tensor = _ensure_tensorbase(tensor)
-        self.data = self.data + tensor.data
+        self.data += tensor.data
         return self
 
     def __sub__(self, tensor):
@@ -80,7 +80,7 @@ def __isub__(self, tensor):
             return NotImplemented
 
         tensor = _ensure_tensorbase(tensor)
-        self.data = self.data - tensor.data
+        self.data -= tensor.data
         return self
 
     def __eq__(self, tensor):
@@ -118,7 +118,7 @@ def __imul__(self, tensor):
             return NotImplemented
 
         tensor = _ensure_tensorbase(tensor)
-        self.data = self.data * tensor.data
+        self.data *= tensor.data
         return self
 
     def __truediv__(self, tensor):
@@ -135,7 +135,7 @@ def __itruediv__(self, tensor):
             return NotImplemented
 
         tensor = _ensure_tensorbase(tensor)
-        self.data = self.data / tensor.data
+        self.data /= tensor.data
         return self
 
     def abs(self):


Test patch:
Repository: OpenMined/PySyft

Issue:
Support indexing of TensorBase objects
Indexing in Python is an extremely useful operation supported by major libraries like Numpy and Pandas. Therefore, we would like our TensorBase objects to support this operation as well. This [StackOverflow answer](https://stackoverflow.com/a/509295) contains a good explanation of how it works.

Since we are wrapping `numpy`'s `ndarray` in our TensorBase classes, a way of implementing it would be to pipe the operations through to `numpy`'s implementation.

**Acceptance criteria**
* Must support reverse indexing (e.g. `[-1]`).
* Contains unit tests demonstrating indexing behavior.


Discussion:

Resolving patch:
diff --git a/syft/tensor.py b/syft/tensor.py
--- a/syft/tensor.py
+++ b/syft/tensor.py
@@ -138,6 +138,13 @@ def __itruediv__(self, tensor):
         self.data /= tensor.data
         return self
 
+    def __getitem__(self, position):
+        """Get value at a specific index."""
+        if self.encrypted:
+            return NotImplemented
+
+        return TensorBase(self.data[position], self.encrypted)
+
     def abs(self):
         """Returns absolute value of tensor as a new tensor"""
         if self.encrypted:


Test patch:
diff --git a/tests/test_tensor.py b/tests/test_tensor.py
--- a/tests/test_tensor.py
+++ b/tests/test_tensor.py
@@ -118,6 +118,13 @@ def testIneqOp(self):
         self.assertTrue(t1 != t2)
 
 
+class IndexTests(unittest.TestCase):
+    def testIndexing(self):
+        t1 = TensorBase(np.array([1.2, 2, 3]))
+        self.assertEqual(1.2, t1[0].data)
+        self.assertEqual(3, t1[-1].data)
+
+
 class addmm(unittest.TestCase):
     def testaddmm1d(self):
         t1=TensorBase(np.array([1,2,3]))
Repository: OpenMined/PySyft

Issue:
Set up CI for automated testing and style checks
Now that our codebase is growing (hooray!), we should set up CI for automated testing and style checks (PEP8, PEP257). 

Choices include [CircleCI](https://circleci.com) and [TravisCI](https://travis-ci.org). These can be integrated into our repo such that every pull request will be checked before review. 


Discussion:
I have used Travis before and could set it up to run tests and check for any style guide violations tomorrow. Assign it to me if nobody else is already working on it.

Quick question: Should the build fail if something violates PEP8/PEP257? 
> Quick question: Should the build fail if something violates PEP8/PEP257?

Yes!
I would recommend using https://pypi.python.org/pypi/flake8

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -28,5 +28,5 @@ def read(fname):
     scripts=['bin/syft_cmd'],
     install_requires=requirements,
     setup_requires=['pytest-runner'],
-    tests_require=['pytest']
+    tests_require=['pytest', 'pytest-flake8']
 )


Test patch:
Repository: OpenMined/PySyft

Issue:
Implement Default cumprod Functionality for Base Tensor Type
**User Story A:** As a Data Scientist using Syft's Base Tensor type, we want to implement a default method for computing operations on a Tensor of arbitrary type. For this ticket to be complete, cumprod() should return a new tensor. For a reference on the operation this performs check out [PyTorch](http://pytorch.org/docs/master/tensors.html)'s documentation.

**Acceptance Criteria:**
- If the Base Tensor type's attribute "encrypted" is set to True, it should return a NotImplemented error.
- a unit test demonstrating the correct operation on the Base Tensor type implemented over int and float Tensors.
- inline documentation in the python code. For inspiration on inline documentation, please check out [PyTorch](http://pytorch.org/docs/master/tensors.html)'s documentation for this operator.


Discussion:
I'll take this if no one is working on it.

Resolving patch:
diff --git a/syft/tensor.py b/syft/tensor.py
--- a/syft/tensor.py
+++ b/syft/tensor.py
@@ -858,6 +858,19 @@ def size(self):
         else:
             return self.data.size
 
+    def cumprod(self, dim=0):
+        """Returns the cumulative product of elements in the dimension dim."""
+        if self.encrypted:
+            return NotImplemented
+        return syft.math.cumprod(self, dim)
+
+    def cumprod_(self, dim=0):
+        """calculate in-place the cumulative product of elements in the dimension dim."""
+        if self.encrypted:
+            return NotImplemented
+        self.data = syft.math.cumprod(self, dim).data
+        return self
+
     def split(self, split_size, dim=0):
         """Returns tuple of tensors of equally sized tensor/chunks (if possible)"""
         if self.encrypted:


Test patch:
diff --git a/tests/test_tensor.py b/tests/test_tensor.py
--- a/tests/test_tensor.py
+++ b/tests/test_tensor.py
@@ -647,6 +647,23 @@ def testNonZero(self):
         self.assertTrue(np.array_equal(t2.data, np.array([[0, 1, 1], [0, 1, 2]])))
 
 
+class cumprodTest(unittest.TestCase):
+    def testCumprod(self):
+        t1 = TensorBase(np.array([[1, 2, 3], [4, 5, 6]]))
+        t2 = TensorBase(np.array([[1.0, 2.0, 3.0], [4.0, 10.0, 18.0]]))
+        t3 = TensorBase(np.array([[1, 2, 6], [4, 20, 120]]))
+        self.assertTrue(np.equal(t1.cumprod(dim=0), t2).all())
+        self.assertTrue(np.equal(t1.cumprod(dim=1), t3).all())
+
+    def testCumprod_(self):
+        t1 = TensorBase(np.array([[1, 2, 3], [4, 5, 6]]))
+        t2 = TensorBase(np.array([[1.0, 2.0, 3.0], [4.0, 10.0, 18.0]]))
+        t3 = TensorBase(np.array([[1, 2, 6], [4, 20, 120]]))
+        self.assertTrue(np.equal(t1.cumprod_(dim=0), t2).all())
+        t1 = TensorBase(np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]))
+        self.assertTrue(np.equal(t1.cumprod_(dim=1), t3).all())
+
+
 class splitTests(unittest.TestCase):
     def testSplit(self):
         t1 = TensorBase(np.arange(8.0))
Repository: OpenMined/PySyft

Issue:
Implement Default select Functionality for Base Tensor Type
**User Story A:** As a Data Scientist using Syft's Base Tensor type, I want to leverage a default method for computing operations on a Tensor of arbitrary type. For this ticket to be complete, select() should return a new tensor. For a reference on the operation this performs check out [PyTorch](http://pytorch.org/docs/master/tensors.html)'s documentation.

**Acceptance Criteria:**
- If the Base Tensor type's attribute "encrypted" is set to True, it should return a NotImplemented error.
- a unit test demonstrating the correct operation on the Base Tensor type implemented over int and float Tensors.
- inline documentation in the python code. For inspiration on inline documentation, please check out [PyTorch](http://pytorch.org/docs/master/tensors.html)'s documentation for this operator.


Discussion:
I'm gonna go for this
@iamtrask PyTorch has a `index_select` [method](http://pytorch.org/docs/master/torch.html#torch.index_select). It has no `select` method. Is `index_select` what should be implemented?
If yes, should I called it `select` or call it `index_select`?
ah... index_select 

Resolving patch:
diff --git a/syft/tensor.py b/syft/tensor.py
--- a/syft/tensor.py
+++ b/syft/tensor.py
@@ -1160,6 +1160,22 @@ def serialize(self):
     def deserialize(b):
         return pickle.loads(b)
 
+    def index_select(self, dim, index):
+        """
+        Returns a new Tensor which indexes the ``input`` Tensor along
+        dimension ``dim`` using the entries in ``index``.
+
+        :param dim: dimension in which to index
+        :param index: 1D tensor containing the indices to index
+        :return: Tensor of selected indices
+        """
+        index = _ensure_tensorbase(index)
+        if self.encrypted or index.encrypted:
+            return NotImplemented
+        if index.data.ndim > 1:
+            raise ValueError("Index is supposed to be 1D")
+        return TensorBase(self.data.take(index, axis=dim))
+
     def mv(self, tensorvector):
         if self.encrypted:
             raise NotImplemented


Test patch:
diff --git a/tests/test_tensor.py b/tests/test_tensor.py
--- a/tests/test_tensor.py
+++ b/tests/test_tensor.py
@@ -751,6 +751,16 @@ def testNe_(self):
         self.assertTrue(syft.equal(t1, TensorBase([1, 1, 1, 0])))
 
 
+class index_selectTests(unittest.TestCase):
+    def testIndex_select(self):
+        t = TensorBase(np.reshape(np.arange(0, 2 * 3 * 4), (2, 3, 4)))
+        idx = np.array([1, 0])
+        dim = 2
+        result = t.index_select(dim=dim, index=idx)
+        expected = np.array([[[1, 0], [5, 4], [9, 8]], [[13, 12], [17, 16], [21, 20]]])
+        self.assertTrue(np.array_equal(result.data, expected))
+
+
 class gatherTests(unittest.TestCase):
     def testGatherNumerical1(self):
         t = TensorBase(np.array([[65, 17], [14, 25], [76, 22]]))
Repository: OpenMined/PySyft

Issue:
Implement Default geometric Functionality for Base Tensor Type
**User Story A:** As a Data Scientist using Syft's Base Tensor type, we want to implement a default method for computing operations on a Tensor of arbitrary type. For this ticket to be complete, geometric_() should perform the operation inline. For a reference on the operation this performs check out [PyTorch](http://pytorch.org/docs/master/tensors.html)'s documentation.

**Acceptance Criteria:**
- If the Base Tensor type's attribute "encrypted" is set to True, it should return a NotImplemented error.
- a unit test demonstrating the correct operation on the Base Tensor type implemented over int and float Tensors.
- inline documentation in the python code. For inspiration on inline documentation, please check out [PyTorch](http://pytorch.org/docs/master/tensors.html)'s documentation for this operator.


Discussion:
I'd like to take this up. 

Resolving patch:
diff --git a/syft/tensor.py b/syft/tensor.py
--- a/syft/tensor.py
+++ b/syft/tensor.py
@@ -862,6 +862,25 @@ def uniform(self, low=0, high=1):
         out = np.random.uniform(low=low, high=high, size=self.shape())
         return TensorBase(out)
 
+    def geometric_(self, p):
+        """Fills the given tensor in-place with samples from a geometric distribution
+        with given probability of success of an individual trial.
+
+        Parameters
+        ----------
+        p: float
+            Probability of success of an individual trial
+
+        Returns
+        -------
+        TensorBase
+            Caller with values in-place
+        """
+        if self.encrypted:
+            return NotImplemented
+        self.data = np.random.geometric(p, size=self.shape())
+        return self
+
     def cauchy_(self, median=0, sigma=1):
         """Fills the tensor in-place with numbers drawn from the Cauchy distribution:
 


Test patch:
diff --git a/tests/test_tensor.py b/tests/test_tensor.py
--- a/tests/test_tensor.py
+++ b/tests/test_tensor.py
@@ -716,6 +716,14 @@ def test_uniform_(self):
         self.assertTrue(np.all(t1.data > 0) and np.all(t1.data < 3))
 
 
+class geometricTests(unittest.TestCase):
+    def test_geometric_(self):
+        t1 = TensorBase(np.zeros((4, 4)))
+        out = t1.geometric_(p=0.5)
+        self.assertTupleEqual(t1.data.shape, out.data.shape)
+        self.assertTrue(np.all(out.data > 0))
+
+
 class fillTests(unittest.TestCase):
     def test_fill_(self):
         t1 = TensorBase(np.array([1, 2, 3, 4]))
Repository: OpenMined/PySyft

Issue:
Implement Default new Functionality for Base Tensor Type
**User Story A:** As a Data Scientist using Syft's Base Tensor type, I want to leverage a default method for computing operations on a Tensor of arbitrary type. For this ticket to be complete, new() should return a new tensor. For a reference on the operation this performs check out [PyTorch](http://pytorch.org/docs/master/tensors.html)'s documentation.

**Acceptance Criteria:**
- If the Base Tensor type's attribute "encrypted" is set to True, it should return a NotImplemented error.
- a unit test demonstrating the correct operation on the Base Tensor type implemented over int and float Tensors.
- inline documentation in the python code. For inspiration on inline documentation, please check out [PyTorch](http://pytorch.org/docs/master/tensors.html)'s documentation for this operator.


Discussion:
Hey, I want to help. How do I get started?

I'll pick this one up!

Resolving patch:
diff --git a/syft/tensor.py b/syft/tensor.py
--- a/syft/tensor.py
+++ b/syft/tensor.py
@@ -109,6 +109,30 @@ def __init__(self, arr_like, encrypted=False):
         self.data = _ensure_ndarray(arr_like)
         self.encrypted = encrypted
 
+    def new(self, *args, **kwargs):
+        """Constructs a new tensor instance of the same data type.
+
+        Parameters
+        ----------
+        *args
+            Variable length argument list used to instantiate
+            new TensorBase object.
+        **kwargs
+            Arbitrary keyword arguments used to instantiate
+            new TensorBase object.
+
+        Returns
+        -------
+        TensorBase class instance if parent TensorBase
+        has self.encrypted = False, otherwise return NotImplemented
+        error.
+
+        """
+        if self.encrypted:
+            return NotImplemented
+
+        return self.__class__(*args, **kwargs)
+
     def _calc_mul_depth(self, tensor1, tensor2):
         if isinstance(tensor1, TensorBase) and isinstance(tensor2, TensorBase):
             self._mul_depth = max(tensor1._mul_depth, tensor2._mul_depth) + 1


Test patch:
diff --git a/tests/test_tensor.py b/tests/test_tensor.py
--- a/tests/test_tensor.py
+++ b/tests/test_tensor.py
@@ -1119,6 +1119,29 @@ def test_mm_3d(self):
         self.assertTrue(np.alltrue(out.data == [[5, 8, 11], [8, 13, 18], [11, 18, 25]]))
 
 
+class newTensorTests(unittest.TestCase):
+    def test_encrypted_error(self):
+
+        t1 = TensorBase(np.array([1, 1, 1]), encrypted=True)
+        t2 = t1.new([1, 1, 2], encrypted=True)
+
+        self.assertEqual(t2, NotImplemented)
+
+    def test_return_new_float_tensor(self):
+
+        t1 = TensorBase(np.array([1, 1, 1]))
+        t2 = t1.new(np.array([1., 1., 2.]))
+
+        self.assertTrue(t2.data.dtype == np.float64)
+
+    def test_return_new_int_tensor(self):
+
+        t1 = TensorBase(np.array([1, 1, 1]))
+        t2 = t1.new(np.array([1, 1, 2]))
+
+        self.assertTrue(t2.data.dtype == np.int64)
+
+
 class half(unittest.TestCase):
     def half_test_1(self):
         t1 = TensorBase(np.array([2, 3, 4]))
Repository: OpenMined/PySyft

Issue:
1dim TensorBase slice returns ndarray instead of TensorBase
Currently a slice of TensorBase returns an ndarray if `dim() == 1`. This is not the behavior expected in PyTorch

Example pytorch session:
```python
t1 = Tensor([1,2,3,4])
t1[1:]
 2
 3
 4
[torch.FloatTensor of size 3]
```

Same with TensorBase
```python
t2 = TensorBase([1,2,3,4])
t2[1:]
array([2, 3, 4])
```

see https://github.com/OpenMined/PySyft/commit/7fb592dcd4ede5b0d0cc6bdc50b98a0445ad77c0#diff-796d7f13fb1460eef9cffdccebd38faeR148

Is this a bug or expected ? 



Discussion:

Resolving patch:
diff --git a/syft/tensor.py b/syft/tensor.py
--- a/syft/tensor.py
+++ b/syft/tensor.py
@@ -449,7 +449,7 @@ def __getitem__(self, position):
             return NotImplemented
         else:
             out = self.data[position]
-            if (len(self.shape()) == 1):
+            if (len(self.shape()) == 1) and (type(position) != slice):
                 return out
             else:
                 return TensorBase(self.data[position], self.encrypted)


Test patch:
diff --git a/tests/test_tensor.py b/tests/test_tensor.py
--- a/tests/test_tensor.py
+++ b/tests/test_tensor.py
@@ -957,6 +957,17 @@ def test_index(self):
         with pytest.raises(ValueError):
             t.index(3.5)
 
+    def test_index_slice_notation(self):
+        t1 = TensorBase(np.array([1, 2, 3, 4]))
+        expected1 = TensorBase(np.array([2, 3, 4]))
+        expected2 = type(t1[1:])
+        expected3 = 1
+
+        # Do not use "t.index" form in following test
+        self.assertEqual(expected1, t1[1:])
+        self.assertEqual(expected2, TensorBase)
+        self.assertEqual(expected3, t1[0])
+
     def test_index_add_(self):
         t1 = TensorBase(np.array([[0, 0, 0], [1, 1, 1], [1, 1, 1]]))
         t2 = TensorBase(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]))
Repository: OpenMined/PySyft

Issue:
SockerWorker error when decoding message
# SockerWorker error when decoding message

## Context
The issue append when sending Tensor to a remote SockerWorker, like in this example : 
https://github.com/OpenMined/PySyft/blob/master/examples/SocketWorker%20Client.ipynb

**Test Configuration**:
A Docker container with:
Python 3.6.5
Jupyter Notebook 5.5.0
IPython 6.4.0
PyTorch 0.3.1

## Failure Information

An Exception occurs when calling the send method of a Tensor object.
The exact code is `x = torch.FloatTensor([1,2,3,4,5]).send(remote_client)`
And here is the exception (which appends on the 'remote' notebook) :
```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-2e80f7b137c2> in <module>()
      3                             port=8188,
      4                             is_pointer=False,
----> 5                             is_client_worker=False)

/usr/local/lib/python3.6/dist-packages/syft-0.1.0-py3.6.egg/syft/core/workers.py in __init__(self, hook, hostname, port, max_connections, id, is_client_worker, objects, tmp_objects, known_workers, verbose, is_pointer, queue_size)
   1033             if(not is_client_worker or self.is_pointer):
   1034                 print("Ready to receive commands...")
-> 1035                 self._listen()
   1036             else:
   1037                 print("Ready!")

/usr/local/lib/python3.6/dist-packages/syft-0.1.0-py3.6.egg/syft/core/workers.py in _listen(self)
   1052 
   1053                     # process message and generate response
-> 1054                     response = self.receive_msg(message)
   1055 
   1056                     # send response back

/usr/local/lib/python3.6/dist-packages/syft-0.1.0-py3.6.egg/syft/core/workers.py in receive_msg(self, message_wrapper_json, is_binary)
    194 
    195         if(is_binary):
--> 196             message_wrapper_json = message_wrapper_json.decode('utf-8')
    197         message_wrapper = json.loads(message_wrapper_json)
    198 

AttributeError: 'str' object has no attribute 'decode'
```

### Steps to Reproduce
1. Run the [SockerWorker Server notebook](https://github.com/OpenMined/PySyft/blob/master/examples/SocketWorker%20Server.ipynb)
2. Run the first three cell of the [SockerWorker Client notebook](https://github.com/OpenMined/PySyft/blob/master/examples/SocketWorker%20Server.ipynb)




Discussion:

Resolving patch:
diff --git a/syft/core/workers.py b/syft/core/workers.py
--- a/syft/core/workers.py
+++ b/syft/core/workers.py
@@ -1051,7 +1051,7 @@ def _listen(self):
                     message = self._process_buffer(connection)
 
                     # process message and generate response
-                    response = self.receive_msg(message)
+                    response = self.receive_msg(message, False)
 
                     # send response back
                     connection.send(response.encode())


Test patch: