Commit 512b1341 authored by HacKan's avatar HacKan
Browse files

Create Blake2Signer package

parent b79415b2
[flake8]
rst-directives =
# These are sorted alphabetically - but that does not matter
autosummary,data,currentmodule,deprecated,
glossary,moduleauthor,plot,testcode,
versionadded,versionchanged,
rst-roles =
attr,class,func,meth,mod,obj,ref,term,
# C programming language:
c:member,
# Python programming language:
py:func,py:mod,
max-line-length=89
show-source=true
enable-extensions=G
import-order-style=pycharm
# Maximum Cyclomatic Complexity allowed
max-complexity = 5
# Set the application name
application-import-names=blake2signer
.idea
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
image: "docker:19.03.13"
stages:
- static_analysis
- test
- build
- integration_test
- security_analysis
- publish
python lint:
stage: static_analysis
image: "registry.gitlab.com/nevrona/public/poetry-docker:1.0.10"
variables:
INVOKE_RUN_SHELL: /bin/ash
POETRY_VIRTUALENVS_CREATE: 0
before_script:
- poetry install
script:
- inv reformat
- changes="$(git status --porcelain=v2 2>/dev/null)"
- if [ -n "$changes" ]; then printf "Code is not properly formatted\n%s" "$changes"; exit 1; fi
- inv lint
except:
- main
- tags
- feature/deploy
packages security:
stage: static_analysis
image: "registry.gitlab.com/nevrona/public/poetry-docker:1.0.10"
before_script:
- pip install safety
script:
- poetry export -f requirements.txt -o requirements.txt --dev
- safety check --full-report -r requirements.txt
except:
- main
- tags
- feature/deploy
tests:
stage: test
image: "registry.gitlab.com/nevrona/public/poetry-docker:1.0.10"
variables:
INVOKE_RUN_SHELL: /bin/ash
POETRY_VIRTUALENVS_CREATE: 0
before_script:
- poetry install
script:
- inv tests
except:
- main
- tags
- feature/deploy
# The last version is 0.30.0
[style]
based_on_style = pep8
# Align closing bracket with visual indentation.
ALIGN_CLOSING_BRACKET_WITH_VISUAL_INDENT = True
# Allow dictionary keys to exist on multiple lines. For example:
#
# x = {
# ('this is the first element of a tuple',
# 'this is the second element of a tuple'):
# value,
# }
ALLOW_MULTILINE_DICTIONARY_KEYS = True
# Allow splits before the dictionary value.
ALLOW_SPLIT_BEFORE_DICT_VALUE = True
# Allow splitting before a default / named assignment in an argument list.
ALLOW_SPLIT_BEFORE_DEFAULT_OR_NAMED_ASSIGNS = True
# Let spacing indicate operator precedence. For example:
# a = 1 * 2 + 3 / 4
# b = 1 / 2 - 3 * 4
# c = (1 + 2) * (3 - 4)
# d = (1 - 2) / (3 + 4)
# e = 1 * 2 - 3
# f = 1 + 2 + 3 + 4
#
# will be formatted as follows to indicate precedence:
#
# a = 1*2 + 3/4
# b = 1/2 - 3*4
# c = (1+2) * (3-4)
# d = (1-2) / (3+4)
# e = 1*2 - 3
# f = 1 + 2 + 3 + 4
# We should review this setting after flake8 or pycodestyle
# is updated regarding issue with E226 (currently setting it
# raises E226).
ARITHMETIC_PRECEDENCE_INDICATION = False
# Insert a blank line before a 'def' or 'class' immediately nested
# within another 'def' or 'class'. For example:
#
# class Foo:
# # <------ this blank line
# def method():
# ...
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = True
# Insert a blank line before a module docstring.
BLANK_LINE_BEFORE_MODULE_DOCSTRING = False
# Do not split consecutive brackets. Only relevant when
# dedent_closing_brackets is set. For example:
#
# call_func_that_takes_a_dict(
# {
# 'key1': 'value1',
# 'key2': 'value2',
# }
# )
#
# would reformat to:
#
# call_func_that_takes_a_dict({
# 'key1': 'value1',
# 'key2': 'value2',
# })
COALESCE_BRACKETS = True
# The column limit.
COLUMN_LIMIT = 89
# Put closing brackets on a separate line, dedented, if the bracketed
# expression can't fit in a single line. Applies to all kinds of
# brackets, including function definitions and calls. For example:
#
# config = {
# 'key1': 'value1',
# 'key2': 'value2',
# } # <--- this bracket is dedented and on a separate line
#
# time_series = self.remote_client.query_entity_counters(
# entity='dev3246.region1',
# key='dns.query_latency_tcp',
# transform=Transformation.AVERAGE(window=timedelta(seconds=60)),
# start_ts=now()-timedelta(days=3),
# end_ts=now(),
# ) # <--- this bracket is dedented and on a separate line
DEDENT_CLOSING_BRACKETS = True
# Place each dictionary entry onto its own line.
EACH_DICT_ENTRY_ON_SEPARATE_LINE = True
# Respect EACH_DICT_ENTRY_ON_SEPARATE_LINE even if the line is shorter
# than COLUMN_LIMIT.
FORCE_MULTILINE_DICT=True
# The i18n function call names. The presence of this function stops
# reformattting on that line, because the string it has cannot be moved
# away from the i18n comment.
I18N_FUNCTION_CALL = ["_", "ugettext", "gettext"]
# Indent the dictionary value if it cannot fit on the same line as the
# dictionary key. For example:
#
# config = {
# 'key1':
# 'value1',
# 'key2': value1 +
# value2,
# }
INDENT_DICTIONARY_VALUE = True
# Insert a space between the ending comma and closing bracket of a list,
# etc.
SPACE_BETWEEN_ENDING_COMMA_AND_CLOSING_BRACKET = False
# Set to True to prefer spaces around the assignment operator for
# default or keyword arguments
SPACES_AROUND_DEFAULT_OR_NAMED_ASSIGN = False
# The number of spaces required before a trailing comment.
SPACES_BEFORE_COMMENT = 2
# Split before arguments if the argument list is terminated by a
# comma
SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED = True
# If a comma separated list (dict, list, tuple, or function def) is on
# a line that is too long, split such that all elements are on a
# single line.
SPLIT_ALL_COMMA_SEPARATED_VALUES = False
# Variation on SPLIT_ALL_COMMA_SEPARATED_VALUES in which, if a subexpression
# with a comma fits in its starting line, then the subexpression is not split.
# This avoids splits like the one for b in this code:
#
# abcdef(
# aReallyLongThing: int,
# b: [Int,
# Int])
#
# With the new knob this is split as:
#
# abcdef(
# aReallyLongThing: int,
# b: [Int, Int])
SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES = False
# Set to True to prefer splitting before +, -, *, /, //, or @
# rather than after.
SPLIT_BEFORE_ARITHMETIC_OPERATOR = True
# Set to True to prefer splitting before '&', '|' or '^' rather than
# after.
SPLIT_BEFORE_BITWISE_OPERATOR = True
# Split before the closing bracket if a list or dict literal doesn't fit
# on a single line.
SPLIT_BEFORE_CLOSING_BRACKET = True
# Split before the '.' if we need to split a longer expression:
# foo = ('This is a really long string: {}, {}, {}, {}'.format(a, b, c, d))
# would reformat to something like:
# foo = ('This is a really long string: {}, {}, {}, {}'
# .format(a, b, c, d))
SPLIT_BEFORE_DOT = True
# Split after the opening paren which surrounds an expression if it doesn't fit
# on a single line.
SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN = True
# If an argument / parameter list is going to be split, then split
# before the first argument.
SPLIT_BEFORE_FIRST_ARGUMENT = True
# For list comprehensions and generator expressions with multiple clauses.
# For example:
#
# result = [
# a_var + b_var for a_var in xrange(1000) for b_var in xrange(1000)
# if a_var % b_var]
#
# would reformat to something like:
#
# result = [
# a_var + b_var
# for a_var in xrange(1000)
# for b_var in xrange(1000)
# if a_var % b_var]
SPLIT_COMPLEX_COMPREHENSION = True
# Contributors
This section is intended for those who wish to contribute to this project. You can contribute in many ways:
* Reporting problems of any kind: things not working correctly, wrong/missing docs, etc.
* Solving existing issues.
* Creating PRs with code/docs/etc.
* Forking this project to create your own.
* Becoming a project maintainer.
## Code of conduct
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), [version 2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html).
### Our Pledge
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
### Our Standards
Examples of behavior that contributes to a positive environment for our community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Making PRs
For a pull request of whatever change you want to do, the following commands must succeed locally:
* `inv reformat`: format code using YAPF.
* `inv lint`: static analysis for compliance of PEP8, PEP257, PEP287 and many more.
* `inv tests`: run the tests battery.
* `inv safety`: run a security analysis over dependencies using `safety`.
You can alternatively run `inv commit` to run all of the above and commit afterwards.
If the linter complains about *code too complex*, run `inv cc -c` (or the long expression `inv cyclomatic-complexity --complex`) for more information.
Your PR must include the necessary docstrings and unit tests so that coverage remains 100%.
### Releasing new versions
I choose to stick with [semver](https://semver.org/), which is compatible with [PEP440](https://www.python.org/dev/peps/pep-0440/) (but only the syntax for version core).
Once everything is ready for release, follow these steps:
1. Create a new release branch from `develop`: `git flow release start <M.m.p>`
1. Edit `pyproject.toml` and change `version` (you can use `poetry major|minor|patch` accordingly to one-up said version part).
1. Edit `blake2signer/__init__.py` and change `__version__`: `__version__ = '<M.m.p>'`.
1. Commit and push, create MR to `main`.
1. Merge into `main`, create MR to `develop`.
1. Merge into `develop`, create and push signed tag: `git tag -s <M.m.p>`.
1. Build packages to publish: `poetry build`.
1. Publish to testpypi: `poetry publish -r testpypi` or `twine upload -r testpypi dist/*`.
1. Check published package and if all went well, publish: `poetry publish` or `twine upload dist/*`.
1. Create release in Gitlab and [properly sign packages](https://gist.github.com/HacKanCuBa/6fabded3565853adebf3dd140e72d33e).
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not