Skip to content

Commit

Permalink
Merge tag '3.27.0' of https://github.com/datastax/python-driver into …
Browse files Browse the repository at this point in the history
…master

version 3.27.0

* tag '3.27.0' of https://github.com/datastax/python-driver:
  Missed dependency on cryptography in setup.py
  Update docs.yaml to point to latest 3.27.0 docs, take two
  remove future plans (datastax#1155)
  Update docs.yaml to point to latest 3.27.0 docs
  update RH nav order (datastax#1154)
  Include docs for 3.27.0 (datastax#1153)
  Release 3.27: changelog & version
  PYTHON-1341 Impl of client-side column-level encryption/decryption (datastax#1150)
  Update ref to include latest version supported (datastax#1149)
  Update driver version supported (datastax#1148)
  Add 3.26 for docs (datastax#1147)
  Fix typo
  Doc changes following on from 3.26.0 release
  • Loading branch information
fruch committed Jun 6, 2024
2 parents 32d9a3c + d911621 commit c69935e
Show file tree
Hide file tree
Showing 23 changed files with 596 additions and 58 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
3.27.0
======
May 1, 2023

Features
--------
* Add support for client-side encryption (PYTHON-1341)

3.26.0
======
March 13, 2023
Expand All @@ -17,7 +25,7 @@ Others
* Fix deprecation warning in query tracing (PR 1103)
* Remove mutable default values from some tests (PR 1116)
* Remove dependency on unittest2 (PYTHON-1289)
* Fix deprecation warnings for asyncio.coroutine annotation in asyncioreactor (PYTTHON-1290)
* Fix deprecation warnings for asyncio.coroutine annotation in asyncioreactor (PYTHON-1290)
* Fix typos in source files (PR 1126)
* HostFilterPolicyInitTest fix for Python 3.11 (PR 1131)
* Fix for DontPrepareOnIgnoredHostsTest (PYTHON-1287)
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ matrices = [
"SMOKE": [
"SERVER": ['3.11', '4.0', 'dse-6.8.30'],
"RUNTIME": ['3.7.7', '3.8.3'],
"CYTHON": ["False"]
"CYTHON": ["True", "False"]
]
]

Expand Down
5 changes: 2 additions & 3 deletions README-dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,10 @@ Adding a New Python Runtime Support
* Add the new python version to our jenkins image:
https://github.com/riptano/openstack-jenkins-drivers/

* Add the new python version in job-creator:
https://github.com/riptano/job-creator/
* Add the new python version in the Jenkinsfile and TravisCI configs as appropriate

* Run the tests and ensure they all pass
* also test all event loops

* Update the wheels building repo to support that version:
https://github.com/riptano/python-dse-driver-wheels
https://github.com/datastax/python-driver-wheels
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Scylla Enterprise (2018.1.x+) using exclusively Cassandra's binary protocol and
.. image:: https://github.com/scylladb/python-driver/workflows/CI%20Docs/badge.svg?tag=*-scylla
:target: https://github.com/scylladb/python-driver/actions?query=workflow%3A%22CI+Docs%22+event%3Apush+branch%3A*-scylla

The driver supports Python versions 3.6-3.11.
The driver supports Python versions 3.6-3.12.

.. **Note:** This driver does not support big-endian systems.
Expand Down
2 changes: 1 addition & 1 deletion cassandra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def emit(self, record):

logging.getLogger('cassandra').addHandler(NullHandler())

__version_info__ = (3, 26, 8)
__version_info__ = (3, 27, 0)
__version__ = '.'.join(map(str, __version_info__))


Expand Down
18 changes: 17 additions & 1 deletion cassandra/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,12 @@ def default_retry_policy(self, policy):
load the configuration and certificates.
"""

column_encryption_policy = None
"""
An instance of :class:`cassandra.policies.ColumnEncryptionPolicy` specifying encryption materials to be
used for columns in this cluster.
"""

shard_aware_options = None
"""
Can be set with :class:`ShardAwareOptions` or with a dict, to disable the automatic shardaware,
Expand Down Expand Up @@ -1150,6 +1156,7 @@ def __init__(self,
monitor_reporting_interval=30,
client_id=None,
cloud=None,
column_encryption_policy=None,
scylla_cloud=None,
shard_aware_options=None):
"""
Expand Down Expand Up @@ -1228,6 +1235,9 @@ def __init__(self,

self.port = port

if column_encryption_policy is not None:
self.column_encryption_policy = column_encryption_policy

self.endpoint_factory = endpoint_factory or DefaultEndPointFactory(port=self.port)
self.endpoint_factory.configure(self)

Expand Down Expand Up @@ -2646,6 +2656,12 @@ def __init__(self, cluster, hosts, keyspace=None):

self.encoder = Encoder()

if self.cluster.column_encryption_policy is not None:
try:
self.client_protocol_handler.column_encryption_policy = self.cluster.column_encryption_policy
except AttributeError:
log.info("Unable to set column encryption policy for session")

# create connection pools in parallel
self._initial_connect_futures = set()
for host in hosts:
Expand Down Expand Up @@ -3185,7 +3201,7 @@ def prepare(self, query, custom_payload=None, keyspace=None):
prepared_keyspace = keyspace if keyspace else None
prepared_statement = PreparedStatement.from_message(
response.query_id, response.bind_metadata, response.pk_indexes, self.cluster.metadata, query, prepared_keyspace,
self._protocol_version, response.column_metadata, response.result_metadata_id)
self._protocol_version, response.column_metadata, response.result_metadata_id, self.cluster.column_encryption_policy)
prepared_statement.custom_payload = future.custom_payload

self.cluster.add_prepared(response.query_id, prepared_statement)
Expand Down
16 changes: 15 additions & 1 deletion cassandra/obj_parser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ include "ioutils.pyx"
from cassandra import DriverException
from cassandra.bytesio cimport BytesIOReader
from cassandra.deserializers cimport Deserializer, from_binary
from cassandra.deserializers import find_deserializer
from cassandra.parsing cimport ParseDesc, ColumnParser, RowParser
from cassandra.tuple cimport tuple_new, tuple_set

from cpython.bytes cimport PyBytes_AsStringAndSize


cdef class ListParser(ColumnParser):
"""Decode a ResultMessage into a list of tuples (or other objects)"""
Expand Down Expand Up @@ -58,18 +61,29 @@ cdef class TupleRowParser(RowParser):
assert desc.rowsize >= 0

cdef Buffer buf
cdef Buffer newbuf
cdef Py_ssize_t i, rowsize = desc.rowsize
cdef Deserializer deserializer
cdef tuple res = tuple_new(desc.rowsize)

ce_policy = desc.column_encryption_policy
for i in range(rowsize):
# Read the next few bytes
get_buf(reader, &buf)

# Deserialize bytes to python object
deserializer = desc.deserializers[i]
coldesc = desc.coldescs[i]
uses_ce = ce_policy and ce_policy.contains_column(coldesc)
try:
val = from_binary(deserializer, &buf, desc.protocol_version)
if uses_ce:
col_type = ce_policy.column_type(coldesc)
decrypted_bytes = ce_policy.decrypt(coldesc, to_bytes(&buf))
PyBytes_AsStringAndSize(decrypted_bytes, &newbuf.ptr, &newbuf.size)
deserializer = find_deserializer(ce_policy.column_type(coldesc))
val = from_binary(deserializer, &newbuf, desc.protocol_version)
else:
val = from_binary(deserializer, &buf, desc.protocol_version)
except Exception as e:
raise DriverException('Failed decoding result column "%s" of type %s: %s' % (desc.colnames[i],
desc.coltypes[i].cql_parameterized_type(),
Expand Down
2 changes: 2 additions & 0 deletions cassandra/parsing.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ from cassandra.deserializers cimport Deserializer
cdef class ParseDesc:
cdef public object colnames
cdef public object coltypes
cdef public object column_encryption_policy
cdef public list coldescs
cdef Deserializer[::1] deserializers
cdef public int protocol_version
cdef Py_ssize_t rowsize
Expand Down
4 changes: 3 additions & 1 deletion cassandra/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ Module containing the definitions and declarations (parsing.pxd) for parsers.
cdef class ParseDesc:
"""Description of what structure to parse"""

def __init__(self, colnames, coltypes, deserializers, protocol_version):
def __init__(self, colnames, coltypes, column_encryption_policy, coldescs, deserializers, protocol_version):
self.colnames = colnames
self.coltypes = coltypes
self.column_encryption_policy = column_encryption_policy
self.coldescs = coldescs
self.deserializers = deserializers
self.protocol_version = protocol_version
self.rowsize = len(colnames)
Expand Down
Loading

0 comments on commit c69935e

Please sign in to comment.