Skip to content

Commit 47f6ae9

Browse files
author
cboling
committed
Initial code check in.
- Mostly code from my older 'packet' library that I've pulled from github
1 parent 3bec9e4 commit 47f6ae9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+6064
-2
lines changed

Diff for: .coveragerc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[run]
2+
branch = True
3+
omit = venv*/*, test/*, examples/*
4+
parallel = True
5+
6+
[report]
7+
8+
[html]

Diff for: .gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,9 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161+
/util/mk_cipher
162+
/tls_packet/umt.py
163+
/tls_packet/eapol.py
164+
/tls_packet/eap.py
165+
/captures/
166+
/.python-version

Diff for: MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include LICENSE VERSION README.md

Diff for: Makefile

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# -------------------------------------------------------------------------
2+
# Copyright 2023-2023, Boling Consulting Solutions, bcsw.net
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License
15+
# -------------------------------------------------------------------------
16+
#
17+
# Makefile method of doing things should you prefer
18+
#
19+
# Configure shell
20+
SHELL = bash -eu -o pipefail
21+
22+
# Variables
23+
THIS_MAKEFILE := $(abspath $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
24+
WORKING_DIR := $(dir $(THIS_MAKEFILE) )
25+
PACKAGE_DIR := $(WORKING_DIR)/tls_packet
26+
TEST_DIR := $(WORKING_DIR)/test
27+
28+
include setup.mk
29+
30+
# Variables
31+
VENVDIR := venv
32+
TESTVENVDIR := $(VENVDIR)-test
33+
PYVERSION ?= ${PYVERSION:-"3.11"}
34+
PYTHON := python${PYVERSION}
35+
36+
COVERAGE_OPTS = --with-xcoverage --with-xunit \
37+
--cover-html --cover-html-dir=tmp/cover
38+
39+
PYLINT_DISABLES = -d similarities -d broad-except -d missing-class-docstring
40+
PYLINT_OPTS = -j 4 --exit-zero --rcfile=${WORKING_DIR}.pylintrc $(PYLINT_DISABLES)
41+
PYLINT_OUT = $(WORKING_DIR)pylint.out
42+
43+
PYLAMA_DISABLES =
44+
PYLAMA_OPTS = --async $(PYLAMA_DISABLES)
45+
PYLAMA_OUT = $(WORKING_DIR)pylama.out
46+
47+
LICENSE_OUT = $(WORKING_DIR)license-check.out
48+
49+
.PHONY: venv test dist clean distclean upload
50+
51+
## Defaults
52+
default: help ## Default operation is to print this help text
53+
54+
## Virtual Environment
55+
venv: $(PACKAGE_DIR)/requirements.txt $(VENVDIR)/.built ## Application virtual environment
56+
57+
venv-test: $(TEST_DIR)/requirements.txt $(TESTVENVDIR)/.built ## Unit-test/lint/... virtual environment
58+
59+
$(VENVDIR)/.built:
60+
@ ${PYTHON} -m venv ${VENVDIR}
61+
@ (source ${VENVDIR}/bin/activate && \
62+
if python -m pip install --disable-pip-version-check -r $(PACKAGE_DIR)/requirements.txt; \
63+
then \
64+
uname -s > ${VENVDIR}/.built; \
65+
fi)
66+
67+
$(TESTVENVDIR)/.built:
68+
@ ${PYTHON} -m venv ${TESTVENVDIR}
69+
@ (source ${TESTVENVDIR}/bin/activate && \
70+
if python -m pip install --disable-pip-version-check -r test/requirements.txt; \
71+
then \
72+
python -m pip install --disable-pip-version-check pylint; \
73+
uname -s > ${TESTVENVDIR}/.built; \
74+
fi)
75+
76+
######################################################################
77+
## License and security
78+
79+
show-licenses: venv ## Show licenses of imported modules
80+
@ (source ${VENVDIR}/bin/activate && \
81+
python -m pip install --upgrade --disable-pip-version-check pip-licenses && \
82+
pip-licenses 2>&1 | tee ${LICENSE_OUT})
83+
84+
bandit-test: venv-test ## Run security test on python source
85+
$(Q) echo "Running python security check with bandit on module code"
86+
@ (source ${TESTVENVDIR}/bin/activate && \
87+
python -m pip install --upgrade --disable-pip-version-check bandit && \
88+
bandit -n 3 -r $(PACKAGE_DIR))
89+
90+
bandit-test-all: venv bandit-test ## Run security test on python source and imported modules
91+
$(Q) echo "Running python security check with bandit on imports"
92+
@ (source ${TESTVENVDIR}/bin/activate && \
93+
python -m pip install --upgrade --disable-pip-version-check bandit && \
94+
bandit -n 3 -r $(WORKING_DIR)/${VENVDIR})
95+
96+
######################################################################
97+
## Testing
98+
99+
test: venv-test ## Run tox-based unit tests
100+
$(Q) echo "Executing unit tests w/tox"
101+
@ python -m pip install --upgrade --disable-pip-version-check tox && \
102+
. ${TESTVENVDIR}/bin/activate && tox
103+
104+
######################################################################
105+
## Linting
106+
107+
lint: venv-test pylint-lint pylama-lint ## Run lint on all sources and dockerfiles
108+
$(Q) echo "Installing pylint"
109+
$(Q) (source ${TESTVENVDIR}/bin/activate && \
110+
python -m pip install --upgrade --disable-pip-version-check pylint)
111+
112+
pylint-lint: venv-test ## Run lint on PON Automation using pylint
113+
@ (source ${TESTVENVDIR}/bin/activate && \
114+
pylint ${PYLINT_OPTS} ${PACKAGE_DIR} 2>&1 | tee ${PYLINT_OUT} && \
115+
echo; echo "See \"file://${PYLINT_OUT}\" for lint report")
116+
117+
# Pylama is a document and code linter collection of other tools
118+
pylama-lint: venv-test ## Run lint on PON Automation using pylama
119+
$(Q) echo "Executing pylama"
120+
$(Q) (source ${TESTVENVDIR}/bin/activate && \
121+
python -m pip install --upgrade --disable-pip-version-check pylama[all] && \
122+
$(MAKE) app-pylama)
123+
124+
app-pylama: venv-test
125+
pylama ${PYLAMA_OPTS} ${PACKAGE_DIR} 2>&1 | tee ${PYLAMA_OUT}
126+
$(Q) echo
127+
$(Q) echo "See \"file://${PYLAMA_OUT}\" for pylama report"
128+
129+
######################################################################
130+
# Release related (Lint ran last since it probably will have errors until
131+
# the code is refactored (which is not planned at this time)
132+
## Release and Publishing Procedures
133+
release-check: distclean venv venv-test test bandit-test lint ## Clean distribution and run unit-test, security, and lint
134+
135+
dist: ## Create source distribution of the python package
136+
$(Q) echo "Creating python source distribution"
137+
rm -rf dist/
138+
python setup.py sdist
139+
140+
upload: clean lint test dist ## Upload test version of python package to test.pypi.org
141+
$(Q) echo "Uploading sdist to test.pypi.org"
142+
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
143+
144+
######################################################################
145+
## Utility
146+
clean: ## Cleanup directory of build and test artifacts
147+
@ -rm -rf .tox *.coverage *.egg-info ${DOCKER_TARBALLNAME}.gz build/*.deb test/.pytest_cache ${PYLAMA_OUT} ${PYLINT_OUT} ${LICENSE_OUT}
148+
@ -find . -name '*.pyc' | xargs rm -f
149+
@ -find . -name '__pycache__' | xargs rm -rf
150+
@ -find . -name '__pycache__' | xargs rm -rf
151+
@ -find . -name 'htmlcov' | xargs rm -rf
152+
@ -find . -name 'junit-report.xml' | xargs rm -rf
153+
@ -find . -name 'coverage.xml' | xargs rm -rf
154+
@ -find . -name '.coverage' | xargs rm -rf
155+
156+
distclean: clean ## Cleanup all build, test, and virtual environment artifacts
157+
@ -rm -rf ${VENVDIR} ${TESTVENVDIR} ${BUILD_DIR}
158+
159+
help: ## Print help for each Makefile target
160+
@echo ''
161+
@echo 'Usage:'
162+
@echo ' ${YELLOW}make${RESET} ${GREEN}<target> [<target> ...]${RESET}'
163+
@echo ''
164+
@echo 'Targets:'
165+
@awk 'BEGIN {FS = ":.*?## "} { \
166+
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-23s${GREEN}%s${RESET}\n", $$1, $$2} \
167+
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
168+
}' $(MAKEFILE_LIST)
169+
170+
# end file

Diff for: README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1-
# tls-packet
2-
Python TLS Packet decoder/serializer library
1+
# tls_packet
2+
Python TLS Packet decoder/serializer library with a focus on TLS packets used during
3+
IEEE 802.1x/RADIUS interactions
4+
5+
The initial target is a TLSv1.2 with emphasis on the TLS Client Side operations. Once it
6+
is successfully working against a FreeRADIUS v3.0+ server, other TLS vesions (particularly v1.3)
7+
will be supported.
8+
9+
In addition, a goal once it works with FreeRADIUS as a client, creating the TLS Server side to work
10+
without a FreeRADIUS server is a goal.
11+
12+
Another future goal is to provide some decode options similar to what go-packet provides so that
13+
the users can tune for the performance they need.
14+
15+
## Release History
16+
17+
| Version | Notes |
18+
|:-------:|:---------------------------------------------|
19+
| 0.0.0 | Nothing yet. Please stay come back later... |

Diff for: VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

Diff for: docs/8021X-2020.pdf

2.48 MB
Binary file not shown.

Diff for: docs/T-REC-X.509-201910-I!!MSW-E.docx

2.41 MB
Binary file not shown.
95 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

Diff for: env.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
# -------------------------------------------------------------------------
3+
# Copyright 2023-2023, Boling Consulting Solutions, bcsw.net
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License
16+
# -------------------------------------------------------------------------
17+
18+
# load local python virtualenv if exists
19+
VENVDIR=${VENVDIR:-venv}
20+
PACKAGEDIR=${PACKAGEDIR:-packet}
21+
PYVERSION ?= ${PYVERSION:-"3.8"}
22+
23+
if [ -e "${VENVDIR}/.built" ]; then
24+
. $VENVDIR/bin/activate
25+
else
26+
echo "Creating python development environment"
27+
virtualenv --python=python${PYVERSION} -v ${VENVDIR} &&\
28+
source ./${VENVDIR}/bin/activate && set -u && \
29+
pip install --disable-pip-version-check -r ${PACKAGEDIR}/requirements.txt && \
30+
uname -s > ${VENVDIR}/.built
31+
fi

Diff for: pylama.ini

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -------------------------------------------------------------------------
2+
# Copyright 2023-2023, Boling Consulting Solutions, bcsw.net
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License
15+
# -------------------------------------------------------------------------
16+
# pylama ignore file
17+
18+
[pep8]
19+
max_line_length = 300 # Basically ignore it

Diff for: setup.mk

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# -------------------------------------------------------------------------
2+
# Copyright 2023-2023, Boling Consulting Solutions, bcsw.net
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License
15+
# -------------------------------------------------------------------------
16+
#
17+
# Makefile Setup
18+
#
19+
## VERBOSE Option - Set V (for verbose) on the command line (make V=1 <targets...>) to see additional output
20+
ifeq ("$(origin V)", "command line")
21+
export Q=
22+
else
23+
export Q=@
24+
export MAKEFLAGS+=--no-print-directory
25+
endif
26+
27+
## NO_COLOR Option - Set NO_COLOR on the command line (make NO_COLOR=1 <targets...>) to not colorize output
28+
ifeq ("$(origin NO_COLOR)", "command line")
29+
export GREEN :=
30+
export YELLOW :=
31+
export WHITE :=
32+
export CYAN :=
33+
export RESET :=
34+
else
35+
export GREEN := $(shell tput -Txterm setaf 2)
36+
export YELLOW := $(shell tput -Txterm setaf 3)
37+
export WHITE := $(shell tput -Txterm setaf 7)
38+
export CYAN := $(shell tput -Txterm setaf 6)
39+
export RESET := $(shell tput -Txterm sgr0)
40+
endif
41+

Diff for: setup.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2023, Boling Consulting Solutions
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# pylint: disable=missing-module-docstring
17+
18+
# Always prefer setuptools over distutils
19+
from __future__ import absolute_import
20+
from os import path
21+
from glob import glob
22+
from setuptools import setup, find_packages
23+
24+
PACKAGE = 'tls_packet'
25+
setup_dir = path.dirname(path.abspath(__file__))
26+
version_file = path.join(setup_dir, "VERSION")
27+
28+
# Get the long description from the README file
29+
with open(path.join(setup_dir, 'README.md'), encoding='utf-8') as f:
30+
long_description = f.read()
31+
32+
with open(version_file) as version_file:
33+
version = version_file.read().strip()
34+
35+
requirements = open(path.join(setup_dir, "tls_packet/requirements.txt")).read().splitlines()
36+
required = [line for line in requirements if not line.startswith("-")]
37+
38+
setup(
39+
name=PACKAGE,
40+
version=version,
41+
description='A python library for encoding and decoding TLS Packets',
42+
author='Chip Boling',
43+
author_email='[email protected]',
44+
long_description=long_description,
45+
long_description_content_type='text/markdown',
46+
url='https://github.com/cboling/tls-client',
47+
classifiers=[
48+
'Development Status :: 2 - Pre-Alpha',
49+
'Intended Audience :: Developers',
50+
'Topic :: Software Development :: Libraries',
51+
'License :: OSI Approved :: Apache Software License',
52+
'Programming Language :: Python :: 3.8',
53+
'Programming Language :: Python :: 3.9',
54+
'Programming Language :: Python :: 3.10',
55+
'Programming Language :: Python :: 3.11',
56+
],
57+
python_requires='>=3.8',
58+
packages=find_packages('src'),
59+
package_dir={'': 'src'},
60+
py_modules=[path.splitext(path.basename(path))[0] for path in glob('tls-client/*.py')],
61+
install_requires=[required],
62+
include_package_data=True,
63+
)

0 commit comments

Comments
 (0)