Commit f0a5c659 authored by Simon Chabot's avatar Simon Chabot
Browse files

initial commit

parents
Pipeline #42021 failed with stage
in 34 seconds
image: python
stages:
- tests
- after-tests
before_script:
- pip install tox
py3:
stage: tests
script: tox -e py3
flake8:
stage: tests
script: tox -e flake8
check-manifest:
stage: tests
script: tox -e check-manifest
black:
stage: tests
script: tox -e black
# If you have mypy set up
# mypy:
# stage: tests
# script: tox -e mypy
# If you have your project on readthedocs, you can automatically trigger its
# build by setting:
# - READTHEDOCS_TOKEN
# - READTHEDOCS_ID
# in your heptapod project Settings > CI/CD > Variables.
# You can find those secrets by creating a new integration in your readthedocs
# project here: https://readthedocs.org/dashboard/cubicweb_encryption/integrations/
#
# Related documentation:
# https://docs.readthedocs.io/en/latest/webhooks.html#using-the-generic-api-integration
#
# trigger-readthedocs:
# only:
# refs:
# - branch/default
# stage: after-tests
# script:
# # regarding the " everywhere when there is a '%': yaml is extremly weird when % are involved
# - curl -X POST -d "token=${READTHEDOCS_TOKEN}" https://readthedocs.org/api/v2/webhook/cubicweb_encryption/${READTHEDOCS_ID} -w "\nhttp code:"\ "%{http_code}\n" -f
include *.py
include */*.py
recursive-include cubicweb_encryption *.py
recursive-include cubicweb_encryption/data *.gif *.png *.ico *.css *.js
recursive-include cubicweb_encryption/i18n *.po
recursive-include cubicweb_encryption/wdoc *
recursive-include test/data bootstrap_cubes *.py
include *.ini
prune debian
exclude cubicweb-encryption.spec
exclude .gitlab-ci.yml
# Summary
A cube that adds support for encrypted attributes
# for el5, force use of python2.6
%if 0%{?el5}
%define python python26
%define __python /usr/bin/python2.6
%else
%define python python
%define __python /usr/bin/python
%endif
%{!?_python_sitelib: %define _python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Name: cubicweb-encryption
Version: 0.1.0
Release: logilab.1%{?dist}
Summary: A cube that adds support for encrypted attributes
Group: Applications/Internet
License: LGPL
Source0: cubicweb-encryption-%{version}.tar.gz
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildRequires: %{python} %{python}-setuptools
Requires: cubicweb >= 3.30.0
Requires: %{python}-six >= 1.4.0
%description
A cube that adds support for encrypted attributes
%prep
%setup -q -n cubicweb-encryption-%{version}
%if 0%{?el5}
# change the python version in shebangs
find . -name '*.py' -type f -print0 | xargs -0 sed -i '1,3s;^#!.*python.*$;#! /usr/bin/python2.6;'
%endif
%install
%{__python} setup.py --quiet install --no-compile --prefix=%{_prefix} --root="$RPM_BUILD_ROOT"
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
%{_python_sitelib}/*
"""cubicweb-encryption application package
A cube that adds support for encrypted attributes
"""
def includeme(config):
pass
# pylint: disable=W0622
"""cubicweb-encryption application packaging information"""
modname = "cubicweb_encryption"
distname = "cubicweb-encryption"
numversion = (0, 1, 0)
version = ".".join(str(num) for num in numversion)
license = "LGPL"
author = "LOGILAB S.A. (Paris, FRANCE)"
author_email = "contact@logilab.fr"
description = "A cube that adds support for encrypted attributes"
web = "http://www.cubicweb.org/project/%s" % distname
__depends__ = {"cubicweb": ">= 3.30.0"}
__recommends__ = {}
classifiers = [
"Environment :: Web Environment",
"Framework :: CubicWeb",
"Programming Language :: Python :: 3",
"Programming Language :: JavaScript",
]
# -*- coding: utf-8 -*-
# copyright 2021 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-encryption entity's classes"""
# -*- coding: utf-8 -*-
# copyright 2021 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-encryption specific hooks and operations"""
msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
# -*- coding: utf-8 -*-
# copyright 2021 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-encryption postcreate script, executed at instance creation time or when
the cube is added to an existing instance.
You could setup site properties or a workflow here for example.
"""
# Example of site property change
# set_property('ui.site-title', "<sitename>")
# -*- coding: utf-8 -*-
# copyright 2021 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-encryption schema"""
from yams.buildobjs import make_type
EncryptedString = make_type("EncryptedString")
# -*- coding: utf-8 -*-
# copyright 2016-2021 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""Register the new type."""
from logilab.database import get_db_helper, FunctionDescr
from logilab.database.sqlgen import SQLExpression
from rql.utils import register_function
from yams import register_base_type
#
# EncryptedString type
#
# this key should be stored in the all-in-one.conf (or elsewhere), obviously…
PWD = "toto"
def convert_encryptedstring(x):
if isinstance(x, SQLExpression):
return x
elif isinstance(x, str):
return SQLExpression("pgp_sym_encrypt(%(x)s, %(key)s)", x=x, key=PWD)
return SQLExpression("pgp_sym_encrypt(%(x)s, %(key)s)", x=x, key=PWD)
# Register the new type
register_base_type("EncryptedString")
# Map the new type with PostgreSQL
pghelper = get_db_helper("postgres")
pghelper.TYPE_MAPPING["EncryptedString"] = "text"
pghelper.TYPE_CONVERTERS["EncryptedString"] = convert_encryptedstring
# Map the new type with SQLite3
sqlitehelper = get_db_helper("sqlite")
sqlitehelper.TYPE_MAPPING["EncryptedString"] = "text"
sqlitehelper.TYPE_CONVERTERS["EncryptedString"] = lambda x: x
class DECRYPTED(FunctionDescr):
minargs = 1
maxargs = 1
supported_backends = ("postgres", "sqlite")
rtype = "text"
def as_sql_postgres(self, args):
field = args[0]
return f"pgp_sym_decrypt({field}::bytea, '{PWD}')"
def as_sql_sqlite(self, args):
field = args[0]
return field
register_function(DECRYPTED)
# -*- coding: utf-8 -*-
# copyright 2021 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-encryption views/forms/actions/components for web ui"""
cubicweb-encryption (0.1.0-1) UNRELEASED; urgency=medium
* Initial release.
-- LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> Wed, 17 Mar 2021 09:01:07 +0000
Source: cubicweb-encryption
Section: web
Priority: optional
Maintainer: LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr>
Build-Depends:
debhelper (>= 9),
dh-python,
python3-all,
python3-setuptools,
python3-pytest,
Standards-Version: 4.3.0
X-Python3-Version: >= 3.4
Package: python3-cubicweb-encryption
Architecture: all
Depends:
${python3:Depends},
${misc:Depends},
Description: A cube that adds support for encrypted attributes
CubicWeb is a semantic web application framework.
.
A cube that adds support for encrypted attributes
.
This package will install all the components you need to run an application
using the cubicweb-encryption cube.
Upstream Author:
LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr>
Copyright:
Copyright (c) 2021 LOGILAB S.A. (Paris, FRANCE).
http://www.logilab.fr -- mailto:contact@logilab.fr
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment