Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
.. figure:: https://cloud.githubusercontent.com/assets/2049665/21398745/27452db6-c76e-11e6-8605-8e5f3301472b.png :alt: image
image
A unit testing tool for Python’s bottle library. We wrote this for our
own testing purposes at https://www.hvst.com. Thanks
brenguyen711 <https://github.com/brenguyen711>
__ for the great name!
::
sudo pip install boddle
Assuming you have a bottle route like this:
.. code:: python
@bottle.get('/woot') def woot(): return bottle.request.params['name']
You can unit test it like:
.. code:: python
import unittest from boddle import boddle
class TestIt(unittest.TestCase): def testWoot(self): with boddle(params={'name':'derek'}): self.assertEqual(woot(), 'derek')
See ```example.py`` <example.py>`__.
Options
The Bottle-specific params that are supported are:
+-----------------------------------------+----------------------------+
| Argument | Notes |
+=========================================+============================+
| ``params`` | Populates |
| | ``request.params``. Takes |
| | a ``dict`` or list of |
| | pairs. Useful for both |
| | POST and GET params. |
+-----------------------------------------+----------------------------+
| ``path`` | The path component of the |
| | url. Populates |
| | ``request.path``, which |
| | always has a preceeding |
| | ``/``. |
+-----------------------------------------+----------------------------+
| ``method`` | POST, GET, etc. Bottle |
| | will uppercase the value. |
+-----------------------------------------+----------------------------+
| ``headers`` | Any HTTP headers. Takes a |
| | ``dict``. |
+-----------------------------------------+----------------------------+
| ``json`` | Takes anything that can be |
| | consumed by |
| | ``json.dumps()``. Also |
| | sets the content type of |
| | the request. |
+-----------------------------------------+----------------------------+
| ``url`` | The full URL, protocol, |
| | domain, port, path, etc. |
| | Will be parsed until its |
| | ``urlparts`` before |
| | populating |
| | ``request.url``. |
+-----------------------------------------+----------------------------+
| ``body`` | The raw body of the |
| | request. Takes either a |
| | ``str`` or a file-like |
| | object. ``str``\ s will be |
| | converted into file-like |
| | objects. Populated |
| | ``request.body``. |
+-----------------------------------------+----------------------------+
| ``query`` | Populates |
| | ``request.query``. Takes a |
| | ``dict``. |
+-----------------------------------------+----------------------------+
All other keyword arguments will be assigned to the request object. For
instance, we often do:
.. code:: python
with boddle(current_user=someone):
# code that accesses bottle.request.current_user
You can also nest ``boddle`` calls. For instance:
.. code:: python
with boddle(path='/woot'):
with boddle(params={'name':'derek'}):
# both path and params are set here
# only path is set here
**ALL CHANGES TO ``bottle.request`` ARE REVERTED WHEN THE WITH BLOCK
ENDS.**
Testing
-------
.. figure:: https://api.travis-ci.org/keredson/boddle.svg?branch=master
:alt: image
image
::
$ git clone https://github.com/keredson/boddle.git
$ cd boddle
$ python tests.py
............
----------------------------------------------------------------------
Ran 12 tests in 0.001s
OK
FAQs
A unit testing tool for Python's bottle library.
We found that boddle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.