Skip to content

Commit 648c06e

Browse files
committed
chore: merge branch 'release/v1.0.1'
2 parents 8f11978 + 551ca9b commit 648c06e

32 files changed

Lines changed: 2449 additions & 154 deletions

.github/workflows/ci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ jobs:
1515
run: |
1616
python -m pip install --upgrade pip
1717
pip install -r requirements.txt
18-
pip install mypy flake8 types-termcolor==1.1.6
19-
- name: Type-check
20-
run: |
21-
mypy src/ tests/ examples/
18+
pip install flake8
2219
- name: Linter
2320
run: |
2421
flake8 --max-line-length=100
@@ -47,7 +44,15 @@ jobs:
4744
run: |
4845
python -m pip install --upgrade pip
4946
pip install -r requirements.txt
47+
pip install mypy types-termcolor>=1.1 types_redis>=4.3
5048
pip install cloudproof_py*.whl
49+
pip install ci_deps/*.whl
50+
- name: Type-check
51+
run: |
52+
mypy src/ tests/
53+
mypy examples/cli_demo
54+
mypy examples/findex_upsert_search
55+
mypy examples/cover_crypt
5156
- name: Run tests
5257
run: |
5358
python -m unittest tests/test*.py

.pre-commit-config.yaml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# See https://pre-commit.com/hooks.html for more hooks
44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.3.0
6+
rev: v4.4.0
77
hooks:
88
- id: check-added-large-files
99
- id: check-ast
@@ -46,18 +46,32 @@ repos:
4646
types_or: [css, javascript, jsx, markdown, bash, java, sh]
4747

4848
- repo: https://github.com/psf/black
49-
rev: 22.10.0
49+
rev: 22.12.0
5050
hooks:
5151
- id: black
5252

53-
- repo: https://gitlab.com/pycqa/flake8
54-
rev: 3.9.2
53+
- repo: https://github.com/pycqa/flake8
54+
rev: 6.0.0
5555
hooks:
5656
- id: flake8
5757
args: [--max-line-length=100]
5858

5959
- repo: https://github.com/pre-commit/mirrors-mypy
60-
rev: 'v0.990'
60+
rev: 'v0.991'
6161
hooks:
6262
- id: mypy
63-
additional_dependencies: [types_termcolor==1.1.6]
63+
additional_dependencies: [types_termcolor==1.1.6, types_redis==4.3.21.6]
64+
65+
- repo: https://github.com/igorshubovych/markdownlint-cli
66+
rev: v0.32.2
67+
hooks:
68+
- id: markdownlint-fix
69+
args: [--disable=MD013, --disable=MD024, --disable=MD041, --disable=MD046]
70+
71+
- repo: https://github.com/Lucas-C/pre-commit-hooks-nodejs
72+
rev: v1.1.2
73+
hooks:
74+
- id: htmlhint
75+
- id: dockerfile_lint
76+
- id: markdown-toc
77+
args: [--bullets='-'] # comment this to refresh TOC

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
---
6+
7+
## [1.0.1] - 2023-01-13
8+
9+
### Features
10+
11+
- Add findex example using dict
12+
- Add cover crypt example
13+
- Add `fetch_chains_batch_size` to findex search
14+
15+
---
16+
517
## [1.0.0] - 2022-12-21
618

719
### Documentation

LICENSE.md

Lines changed: 216 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,68 @@
11
# Cloudproof Encryption Python Library
22

3-
![ci status](https://github.com/Cosmian/cloudproof_python/actions/workflows/ci.yml/badge.svg)
3+
[![PyPI version](https://badge.fury.io/py/cloudproof_py.svg)](https://badge.fury.io/py/cloudproof_py)
4+
![Build status](https://github.com/Cosmian/cloudproof_python/actions/workflows/ci.yml/badge.svg)
45

56
The library provides a Python API to the **Cloudproof Encryption** product of the [Cosmian Ubiquitous Encryption platform](https://cosmian.com).
67

7-
Please [check the online documentation](https://docs.cosmian.com/cloudproof_encryption/use_cases_benefits/) for details on using the CloudProof APIs.
8+
<!-- toc -->
89

9-
## Build package
10+
- [Getting started](#getting-started)
11+
- [Demo](#demo)
12+
- [Building and testing](#building-and-testing)
13+
- [Versions Correspondence](#versions-correspondence)
1014

11-
```sh
12-
pip install -r requirements.txt
13-
scripts/build.sh [-i] [-t]
14-
```
15+
<!-- tocstop -->
16+
17+
## Getting started
1518

16-
## Build docs
19+
This library requires `Python >= 3.7`.
20+
21+
To install the current release:
1722

1823
```sh
19-
pip install -r docs/requirements.txt
20-
scripts/build.sh -d
24+
pip install cloudproof_py
2125
```
2226

27+
Code examples are available in [./examples](./examples) to get you started.
28+
Please [check the online documentation](https://docs.cosmian.com/cloudproof_encryption/use_cases_benefits/) for more details on using the CloudProof APIs.
29+
2330
## Demo
2431

2532
An interactive CLI demo combining policy-based encryption with searchable keywords.
2633

27-
Users from `./examples/cli_demo/data.json` are encrypted using CoverCrypt and indexed via Findex.
34+
Users data from `./examples/cli_demo/data.json` are encrypted using CoverCrypt and indexed via Findex.
35+
36+
Try the demo:
37+
38+
```sh
39+
examples/cli_demo/run_demo.sh
40+
```
41+
42+
## Building and testing
2843

29-
- Run
44+
To build from source:
3045

3146
```sh
32-
scripts/run_demo.sh
47+
scripts/build.sh [-i]
3348
```
3449

50+
**Note**: add `-i` to install after build.
51+
52+
To build and run the tests:
53+
54+
```sh
55+
scripts/build.sh -it
56+
```
57+
58+
To build the documentation:
59+
60+
```sh
61+
scripts/build.sh -d
62+
```
63+
64+
The generated documentation will be in `./docs/_build/html`.
65+
3566
## Versions Correspondence
3667

3768
This library depends on [CoverCrypt](https://github.com/Cosmian/cover_crypt) and [Findex](https://github.com/Cosmian/findex).
@@ -40,4 +71,4 @@ This table shows the minimum version correspondence between the various componen
4071

4172
| `cloudproof_py` | CoverCrypt | Findex |
4273
| --------------- | ---------- | ------ |
43-
| 1.0.0 | 8.0.1 | 1.0.1 |
74+
| >=1.0.0 | 8.0.1 | 1.0.1 |
Binary file not shown.

examples/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
This folder contains examples to get started with `Cloudproof Python`:
44

5+
- Findex - basic usage example: [findex_upsert_search](./findex_upsert_search)
6+
- CoverCrypt - basic usage example: [cover_crypt](./cover_crypt)
57
- Demo combining encryption (CoverCrypt) and search (Findex): [cli_demo](./cli_demo)

examples/cli_demo/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Demo
2+
3+
An interactive CLI demo combining policy-based encryption with searchable keywords.
4+
5+
## Run
6+
7+
```bash
8+
run_demo.sh
9+
```

examples/cli_demo/findex_db.py

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
import sqlite3
33
from cloudproof_py.findex import Findex
44

5-
from typing import Dict, List, Set, Tuple, Optional
5+
from typing import Dict, List, Set, Tuple
66

77

88
class FindexSQLite(Findex.FindexUpsert, Findex.FindexSearch):
9-
"""Implementation of Findex traits for a SQLite backend"""
9+
"""Implement Findex callbacks using SQLite."""
1010

1111
def __init__(self, db_conn: sqlite3.Connection) -> None:
1212
super().__init__()
1313
self.conn = db_conn
1414

1515
def fetch_entry_table(self, entry_uids: List[bytes]) -> Dict[bytes, bytes]:
16-
"""Query the entry table
16+
"""Query the Entry Table.
1717
1818
Args:
19-
entry_uids List[bytes]: uids to query. if None, return the entire table
19+
entry_uids (List[bytes], optional): uids to query. if None, return the entire table
2020
2121
Returns:
22-
Dict[bytes, bytes]
22+
Dict[bytes, bytes]: uid -> value mapping
2323
"""
2424
str_uids = ",".join("?" * len(entry_uids))
2525
cur = self.conn.execute(
@@ -89,62 +89,11 @@ def upsert_entry_table(
8989

9090
return rejected_lines
9191

92-
def insert_entry_table(self, entries_items: Dict[bytes, bytes]) -> None:
93-
"""Insert new key-value pairs in the entry table
94-
95-
Args:
96-
entry_items (Dict[bytes, bytes])
97-
"""
98-
sql_insert_entry = """INSERT INTO entry_table(uid,value) VALUES(?,?)"""
99-
self.conn.executemany(
100-
sql_insert_entry, entries_items.items()
101-
) # batch insertions
102-
10392
def insert_chain_table(self, chain_items: Dict[bytes, bytes]) -> None:
10493
"""Insert new key-value pairs in the chain table
10594
10695
Args:
10796
chain_items (Dict[bytes, bytes])
10897
"""
10998
sql_insert_chain = """INSERT INTO chain_table(uid,value) VALUES(?,?)"""
110-
self.conn.executemany(sql_insert_chain, chain_items.items()) # batch insertions
111-
112-
def remove_entry_table(self, entry_uids: Optional[List[bytes]] = None) -> None:
113-
"""Remove entries from entry table
114-
115-
Args:
116-
entry_uids (List[bytes], optional): uid of entries to delete.
117-
if None, delete all entries
118-
"""
119-
if entry_uids:
120-
self.conn.executemany(
121-
"DELETE FROM entry_table WHERE uid = ?", [(uid,) for uid in entry_uids]
122-
)
123-
else:
124-
self.conn.execute("DELETE FROM entry_table")
125-
126-
def remove_chain_table(self, chain_uids: List[bytes]) -> None:
127-
"""Remove entries from chain table
128-
129-
Args:
130-
chain_uids (List[bytes]): uids to remove from the chain table
131-
"""
132-
self.conn.executemany(
133-
"DELETE FROM chain_table WHERE uid = ?", [(uid,) for uid in chain_uids]
134-
)
135-
136-
def list_removed_locations(self, locations: List[bytes]) -> List[bytes]:
137-
"""Check whether uids still exist in the database
138-
139-
Args:
140-
db_uids (List[bytes]): uids to check
141-
142-
Returns:
143-
List[bytes]: list of uids that were removed
144-
"""
145-
res = []
146-
for uid in locations:
147-
cursor = self.conn.execute("SELECT * FROM users WHERE id = ?", (uid,))
148-
if not cursor.fetchone():
149-
res.append(uid)
150-
return res
99+
self.conn.executemany(sql_insert_chain, chain_items.items())

examples/cli_demo/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cloudproof-py==1.0
2+
termcolor==2.1.1
3+
types-termcolor==1.1.6

0 commit comments

Comments
 (0)