diff --git a/.codecov-env.sh b/.codecov-env.sh new file mode 100755 index 00000000..d642fc03 --- /dev/null +++ b/.codecov-env.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo -e CODECOV_ENV -e CODECOV_TOKEN -e CODECOV_URL -e CODECOV_SLUG -e VCS_COMMIT_ID -e VCS_BRANCH_NAME -e VCS_PULL_REQUEST -e VCS_SLUG -e VCS_TAG -e CI_BUILD_URL -e CI_BUILD_ID -e CI_JOB_ID -e CI -e TRAVIS -e SHIPPABLE -e TRAVIS_BRANCH -e TRAVIS_COMMIT -e TRAVIS_JOB_NUMBER -e TRAVIS_PULL_REQUEST -e TRAVIS_JOB_ID -e TRAVIS_REPO_SLUG -e TRAVIS_TAG -e TRAVIS_OS_NAME diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..08df5157 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +parallel=True diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..30333dee --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "t"] + path = t + url = https://github.com/cheako/tor2web-tests.git diff --git a/.travis.yml b/.travis.yml index 47e1f92a..b69f4919 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,17 @@ -language: python -dist: trusty -sudo: required -python: - - "2.7" -install: true +services: +- docker + +# Don't assume ruby. +language: generic + +before_install: +- docker build -t tor2web . +- echo CID=`docker run -d tor2web tail -f /dev/null` | tee cid + script: - - $TRAVIS_BUILD_DIR/scripts/travis.sh +# - scripts/travis.sh +- . cid; docker exec -e TTWLANG=python $CID /bin/sh -c 'cd /usr/src/github/Tor2web; python2 setup.py install && { prove -v -f t/tx || true; prove -f; }' + +# Generate and deploy documentation +after_success: +- . cid; docker exec `./.codecov-env.sh` $CID /bin/sh -c 'cd /usr/src/github/Tor2web; head /dev/null .coverage*; python-coverage combine; python-coverage xml -i; head /dev/null .coverage*; codecov -X gcov' diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..047bb155 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM debian:stretch +LABEL Description="This image is used to test Tor2web" Version="0.1" +RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends --allow-downgrades --allow-remove-essential --allow-change-held-packages install strace libio-socket-socks-perl libproc-daemon-perl libipc-run-perl libcommon-sense-perl libhttp-daemon-perl libio-socket-ssl-perl python-pip python-setuptools python-dev libffi-dev libssl1.0-dev apparmor apparmor-utils build-essential python-zope.component python-zope.event python-zope.interface python-coverage python-wheel python-requests python-idna python-certifi git procps +RUN ln -s python-coverage /usr/bin/coverage; pip install codecov +COPY . /usr/src/github/Tor2web +RUN pip2 install -r /usr/src/github/Tor2web/requirements.txt diff --git a/requirements/requirements-trusty.txt b/requirements/requirements-trusty.txt index 139f0a67..944006cd 100644 --- a/requirements/requirements-trusty.txt +++ b/requirements/requirements-trusty.txt @@ -5,7 +5,7 @@ cryptography==1.2.3 enum34==0.9.23 idna==2.0 pyOpenSSL==0.15.1 -pyasn1==0.1.9 +pyasn1==0.3.4 pycparser==2.10 service_identity==16.0.0 six==1.5.2 diff --git a/requirements/requirements-xenial.txt b/requirements/requirements-xenial.txt index 5c96567b..15a533da 100644 --- a/requirements/requirements-xenial.txt +++ b/requirements/requirements-xenial.txt @@ -5,7 +5,7 @@ cryptography==1.2.3 enum34==1.1.2 idna==2.0 pyOpenSSL==0.15.1 -pyasn1==0.1.9 +pyasn1==0.3.4 pycparser==2.14 service_identity==16.0.0 six==1.10.0 diff --git a/t b/t new file mode 160000 index 00000000..1f8b2164 --- /dev/null +++ b/t @@ -0,0 +1 @@ +Subproject commit 1f8b21646653e8a7581d3d66232d3227240a6ec7 diff --git a/test-intermediate.pem b/test-intermediate.pem new file mode 100644 index 00000000..d537cd5e --- /dev/null +++ b/test-intermediate.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDBDCCAeygAwIBAgIJAK25kuAT+ZsMMA0GCSqGSIb3DQEBCwUAMBcxFTATBgNV +BAMMDCoub25pb24udGVzdDAeFw0xNzA5MTEwOTQ2NDhaFw0yNzA5MDkwOTQ2NDha +MBcxFTATBgNVBAMMDCoub25pb24udGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAKrfBwR43axQKVjX3jD3dBfWnCp9vRMAV9JGHU2a/WF8gg0b1zTa +/LQCcRgJFIWKaTUedC/OiVlLkx807Q34RNAglzG6auoHJoepTY50Ef+ZnCqDG+ho +s2DZp7/S8xejh8liw+iIKFxFcolnms5SoluMx658BdflMJwS3zPqaVXtI7ZmgZN+ +X1e+orN2zbHUiORNqG1G2Bck31JbQZDgnkZxzVR9EAEm7uKFtvuONsZICMB6x+Vl +dojhHQnILWaJkQ/uDUR51E+06gXQZQ85zfcrUMcpW0bUG//k2PaucG7Xt28Qp/W2 +ZT4rkKqMItvwSBzYNAZunlDXd/HAdIlUePECAwEAAaNTMFEwHQYDVR0OBBYEFKjx +AkZaUg6nAzO0hfk66NbPIxTcMB8GA1UdIwQYMBaAFKjxAkZaUg6nAzO0hfk66NbP +IxTcMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBABwIKtlImJ/S +SNP0HWzxgSz5sLGWJc1Nmw2rW0nQ8u42pzAjaslwH/FPEy/A6g7S5F8FN1fua+2m +pDxQmYM+bTno4mNwcATw3MCEvPjOqOdp8Di1xEj7m2jlMY2uNuKImBXsU2sgKCKw +TUHAaQXya1rx/SA7CjBUrTPRfVJJAwIzYgXuzx/GvOi+c3t/uMlGz5h6DpuTcgO/ +YJdRbrrzKLeJjpFDBOpVhWrlUib3kCgc2pRjeuVb7Yb+ZoN9aI++wKTCS/g/LZTW +4DoZQ1fWh7PBDJiDbGVeJC6fxJxVR1bTyzTwvCA7NO9541mUHwsXHBS6w0FuQiKe +5pmX5LNJxlc= +-----END CERTIFICATE----- diff --git a/tor2web/t2w.py b/tor2web/t2w.py index 72c59a05..1a81bb27 100644 --- a/tor2web/t2w.py +++ b/tor2web/t2w.py @@ -213,14 +213,18 @@ def processExited(self, reason): def spawnT2W(father, childFDs, fds_https, fds_http): + executable = sys.executable; + cmdline = [ sys.executable, __file__] + sys.argv[1:]; + if os.environ.has_key('TTW_COVERAGE'): + executable = os.environ['TTW_COVERAGE']; + cmdline = [ os.environ['TTW_COVERAGE'], 'run', __file__] + sys.argv[1:]; + child_env = os.environ.copy() child_env['T2W_FDS_HTTPS'] = fds_https child_env['T2W_FDS_HTTP'] = fds_http return reactor.spawnProcess(T2WPP(father, childFDs, fds_https, fds_http), - sys.executable, - [sys.executable, __file__] + sys.argv[1:], - env=child_env, + executable,cmdline,env=child_env, childFDs=childFDs) @@ -1312,7 +1316,7 @@ def daemon_shutdown(self): self.quitting = True for pid in self.subprocesses: - os.kill(pid, signal.SIGINT) + os.kill(pid, signal.SIGTERM) self.subprocesses = [] @@ -1394,7 +1398,7 @@ def SigQUIT(SIG, FRM): sys.excepthook = None -set_pdeathsig(signal.SIGINT) +set_pdeathsig(signal.SIGTERM) # ######################### # Security UMASK hardening @@ -1560,8 +1564,6 @@ def nullStartedConnecting(self, connector): os.chmod(os.path.join(config.rundir, "rpc.socket"), 0600) signal.signal(signal.SIGUSR1, SigQUIT) - signal.signal(signal.SIGTERM, SigQUIT) - signal.signal(signal.SIGINT, SigQUIT) start_worker()