Skip to content

Commit

Permalink
Do not use mutable arguments in pynamo models (#184)
Browse files Browse the repository at this point in the history
* Do not use mutable arguments in pynamo models

* Bump version

* Update changelog

* Fix changelog
  • Loading branch information
ryan-lane committed Feb 20, 2019
1 parent f6d3e04 commit 102710d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 4.4.0

* Use ``dict`` and ``set`` in pynamo models rather than ``{}`` and ``set()``,
to avoid potential corrupted data in model saves. Based on how confidant
currently uses the pynamo models, the default arguments can't lead to data
corruption, but to avoid potential future issues, we're fixing the default
args to not be mutable.

## 4.3.1

* Packaging fix

## 4.3.0

* Case insentive sort for service and credential list API responses

## 4.2.0

* Don't in-memory cache the USERS\_FILE, but re-read it every time, so that
Expand Down
4 changes: 2 additions & 2 deletions confidant/models/blind_credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class Meta:
data_type_date_index = DataTypeDateIndex()
name = UnicodeAttribute()
credential_pairs = JSONAttribute()
credential_keys = NonNullUnicodeSetAttribute(default=set([]), null=True)
credential_keys = NonNullUnicodeSetAttribute(default=set, null=True)
enabled = BooleanAttribute(default=True)
data_key = JSONAttribute()
cipher_version = NumberAttribute()
cipher_type = UnicodeAttribute()
metadata = JSONAttribute(default={}, null=True)
metadata = JSONAttribute(default=dict, null=True)
modified_date = UTCDateTimeAttribute(default=datetime.now)
modified_by = UnicodeAttribute()
documentation = UnicodeAttribute(null=True)
2 changes: 1 addition & 1 deletion confidant/models/credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Meta:
data_key = BinaryAttribute()
# TODO: add cipher_type
cipher_version = NumberAttribute(null=True)
metadata = JSONAttribute(default={}, null=True)
metadata = JSONAttribute(default=dict, null=True)
modified_date = UTCDateTimeAttribute(default=datetime.now)
modified_by = UnicodeAttribute()
documentation = UnicodeAttribute(null=True)
4 changes: 2 additions & 2 deletions confidant/models/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Meta:
data_type_date_index = DataTypeDateIndex()
revision = NumberAttribute()
enabled = BooleanAttribute(default=True)
credentials = NonNullUnicodeSetAttribute(default=set())
blind_credentials = NonNullUnicodeSetAttribute(default=set())
credentials = NonNullUnicodeSetAttribute(default=set)
blind_credentials = NonNullUnicodeSetAttribute(default=set)
account = UnicodeAttribute(null=True)
modified_date = UTCDateTimeAttribute(default=datetime.now)
modified_by = UnicodeAttribute()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

setup(
name="confidant",
version="4.3.1",
version="4.4.0",
packages=find_packages(exclude=["test*"]),
include_package_data=True,
zip_safe=False,
Expand Down

0 comments on commit 102710d

Please sign in to comment.