Skip to content

Commit 3757ec2

Browse files
authored
Merge pull request #20 from mnbf9rca/patch/bump-cryptography
bump cryptography above 41.0.3
2 parents c0189ff + 3775f14 commit 3757ec2

File tree

5 files changed

+88
-3
lines changed

5 files changed

+88
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. See [standa
44

55
## [Unreleased](https://github.com/dotenv-org/python-dotenv-vault/compare/v0.5.1...master)
66

7+
## 0.6.4
8+
9+
### Changed
10+
11+
- Bump Cryptography above 41.0.3 to resolve [#19](https://github.com/dotenv-org/python-dotenv-vault/issues/19) (High severity [CVE-2023-38325](https://nvd.nist.gov/vuln/detail/CVE-2023-38325))
12+
713
## 0.6.3
814

915
### Changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
python-dotenv~=0.21.0
2-
cryptography<41.0.0,>=3.1.0
2+
cryptography<42.0.0,>41.0.3

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ def read_files(files):
4040
],
4141
install_requires=[
4242
'python-dotenv~=0.21.0',
43-
'cryptography<41.0.0,>=3.1.0'
43+
'cryptography<42.0.0,>41.0.3'
4444
],
4545
)

src/dotenv_vault/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__title__ = "python-dotenv-vault"
22
__description__ = "Decrypt .env.vault file."
33
__url__ = "https://github.com/dotenv-org/python-dotenv-vault"
4-
__version__ = "0.6.3"
4+
__version__ = "0.6.4"
55
__author__ = "dotenv"
66
__author_email__ = "[email protected]"
77
__license__ = "MIT"

src/dotenv_vault/test_vault.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,82 @@ def test_load_dotenv_vault_not_there(self, find_dotenv):
7979
mocked_listdir.return_value = ['.env', 'some_file']
8080
path = vault.load_dotenv_vault()
8181
self.assertEqual(path, '/some/path/.env')
82+
83+
84+
class TestLoadDotenv:
85+
86+
@mock.patch.dict(os.environ, {"DOTENV_KEY": "secret_key"}, clear=True)
87+
@mock.patch("builtins.open", new_callable=mock.mock_open, read_data="KEY=VALUE")
88+
@mock.patch("dotenv_vault.main.parse_vault")
89+
@mock.patch("dotenv_vault.main.load_dotenv_vault")
90+
@mock.patch("dotenv_vault.main.dotenv.load_dotenv")
91+
def test_load_encrypted_env(
92+
self, mock_load_dotenv,
93+
mock_load_dotenv_vault,
94+
mock_parse_vault,
95+
mock_open
96+
):
97+
mock_parse_vault.return_value = "stream_with_decrypted_data"
98+
mock_load_dotenv_vault.return_value = "this_is_the_valut"
99+
mock_load_dotenv.return_value = True
100+
101+
assert vault.load_dotenv() == True
102+
mock_load_dotenv_vault.assert_called_once()
103+
mock_parse_vault.assert_called_once()
104+
mock_open.assert_called_once_with(mock_load_dotenv_vault.return_value)
105+
mock_load_dotenv.assert_called_once_with(
106+
stream=mock_parse_vault.return_value,
107+
verbose=False,
108+
override=True,
109+
interpolate=True,
110+
encoding="utf-8"
111+
)
112+
113+
@mock.patch.dict(os.environ, {"NOT_DOTENV_KEY": "shouldnt_be_detected"}, clear=True)
114+
@mock.patch("builtins.open", new_callable=mock.mock_open, read_data="KEY=VALUE")
115+
@mock.patch("dotenv_vault.main.dotenv.find_dotenv")
116+
@mock.patch("dotenv_vault.main.dotenv.load_dotenv")
117+
@mock.patch.dict(os.environ, {}, clear=True)
118+
def test_load_unencrypted_env(self,
119+
mock_load_dotenv,
120+
mock_find_dotenv,
121+
mock_open
122+
):
123+
mock_find_dotenv.return_value = "path_to_dotenv_file"
124+
mock_load_dotenv.return_value = True
125+
126+
assert vault.load_dotenv() == True
127+
mock_open.assert_called_once_with(mock_find_dotenv.return_value)
128+
mock_find_dotenv.assert_called_once_with(usecwd=True)
129+
mock_load_dotenv.assert_called_once_with(
130+
stream=mock_open.return_value,
131+
verbose=False,
132+
override=True,
133+
interpolate=True,
134+
encoding="utf-8"
135+
)
136+
137+
@mock.patch.dict(os.environ, {"NOT_DOTENV_KEY": "shouldnt_be_detected"}, clear=True)
138+
@mock.patch("builtins.open", new_callable=mock.mock_open, read_data="KEY=VALUE")
139+
@mock.patch("dotenv_vault.main.dotenv.find_dotenv")
140+
@mock.patch("dotenv_vault.main.dotenv.load_dotenv")
141+
@mock.patch.dict(os.environ, {}, clear=True)
142+
def test_load_with_stream_provided(self,
143+
mock_load_dotenv,
144+
mock_find_dotenv,
145+
mock_open
146+
):
147+
mock_find_dotenv.return_value = "path_to_dotenv_file"
148+
mock_load_dotenv.return_value = True
149+
test_stream_value = "test_stream_value"
150+
151+
assert vault.load_dotenv(stream=test_stream_value) == True
152+
mock_open.assert_not_called()
153+
mock_find_dotenv.assert_called_once_with(usecwd=True)
154+
mock_load_dotenv.assert_called_once_with(
155+
stream=test_stream_value,
156+
verbose=False,
157+
override=True,
158+
interpolate=True,
159+
encoding="utf-8"
160+
)

0 commit comments

Comments
 (0)