Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
task:
freebsd_instance:
matrix:
image: freebsd-12-1-release-amd64
install_script:
- mount -t fdescfs null /dev/fd

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't needed any more!

- pkg install -y python3
- python3 -m ensurepip
- make install-python-requirements-dev
test_script:
- pytest tests
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: python
python:
- "3.7"
sudo: false
install:
- make install-python-requirements-dev
script:
- make check
notifications:
email: false
addons:
apt:
packages:
- sqlite3
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
MYPYPATH = $(shell pwd)/.travis/mypy-stubs

PYTHON ?= python3

install-python-requirements:
$(PYTHON) -m ensurepip
$(PYTHON) -m pip install -U pip
$(PYTHON) -m pip install -Ur requirements.txt

install-python-requirements-dev: install-python-requirements
$(PYTHON) -m pip install -Ur requirements-dev.txt

check:
flake8 --version
mypy --version
flake8 --exclude=".travis,.eggs,__init__.py,docs,tests" --ignore=E203,E252,W391,D107,A001,A002,A003,A004,D412,D413,T499

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ignores are overridden here

bandit --skip B404,B110 --exclude tests/ *.py jail/*.py
test:
pytest tests --zpool $(ZPOOL)

.PHONY: docs
docs:
$(PYTHON) setup.py build_sphinx

help:
@echo " install"
@echo " Installs libioc"
@echo " uninstall"
@echo " Removes libioc"
@echo " test"
@echo " Run unit tests with pytest"
@echo " check"
@echo " Run static linters & other static analysis tests"
@echo " install-dev"
@echo " Install dependencies needed to run `check`"
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ py-jail

A native Python wrapper for FreeBSD jails using libc.

## Build Status

| Unit Tests | [![Unit Tests](https://api.cirrus-ci.com/github/gronke/py-jail.svg)](https://cirrus-ci.com/github/gronke/py-jail) |
| Code Style | [![Code Style](https://travis-ci.org/gronke/py-jail.svg?branch=master)](https://travis-ci.org/gronke/py-jail) |

## Usage

### jail_set
Expand Down
4 changes: 2 additions & 2 deletions jail/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) 2019, Stefan Grönke
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted providing that the following conditions
# are met:
Expand All @@ -9,7 +9,7 @@
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand Down
13 changes: 6 additions & 7 deletions jail/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) 2019, Stefan Grönke
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted providing that the following conditions
# are met:
Expand All @@ -9,7 +9,7 @@
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand All @@ -22,7 +22,6 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""Types used by jail (2)."""
import typing
import ctypes
import ipaddress
import struct
Expand Down Expand Up @@ -52,7 +51,7 @@ class in6_addr(ctypes.Structure):


def in6_addr_U_from_ip(ip6_address: ipaddress.IPv6Address) -> in6_addr_U:
return in6_addr_U(struct.unpack(
"B"*16,
bytes.fromhex(ip6_address.exploded.replace(":",""))
))
return in6_addr_U(struct.unpack(
"B" * 16,
bytes.fromhex(ip6_address.exploded.replace(":", "")),
))
12 changes: 12 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pytest
pytest-pep8
pytest-mock
pytest-benchmark
flake8-docstrings
flake8-mutable
flake8-builtins
flake8-mypy
bandit==1.5.1
bandit-high-entropy-string
sphinx-autodoc-typehints
sphinx_rtd_theme
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
test = pytest

[tool:pytest]
addopts = --verbose
addopts = --verbose

[flake8]
ignore = D101,D103

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these ignores are… ignored

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either way, I'd much prefer to fix this specific docs issue, rather than ignore it

25 changes: 12 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import typing
import os
import os.path
import sys
from setuptools import find_packages, setup
try:
from pip._internal.req import parse_requirements
Expand Down Expand Up @@ -34,23 +33,23 @@ def _read_requirements(

about = {}
with open(os.path.join(cwd, "jail", "__version__.py"), encoding="utf-8") as f:
VERSION = exec(f.read(), about)
VERSION = exec(f.read(), about) # nosec

with open(os.path.join(cwd, "README.md"), encoding="utf-8") as f:
long_description = f.read()

setup(
name="jail",
version=about["__version__"],
description="Native FreeBSD jail bindings with libc.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/gronke/py-jail",
author="Stefan Grönke",
author_email="stefan@gronke.net",
python_requires=">=3.6",
name="jail",
version=about["__version__"],
description="Native FreeBSD jail bindings with libc.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/gronke/py-jail",
author="Stefan Grönke",
author_email="stefan@gronke.net",
python_requires=">=3.6",
install_requires=requirements["install_requires"],
dependency_links=requirements["dependency_links"],
tests_require=["pytest", "pytest-runner", "pytest-benchmark"],
packages=find_packages(exclude=("tests",))
tests_require=["pytest", "pytest-runner", "pytest-benchmark"],
packages=find_packages(exclude=("tests",))
)