Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
a3fd4817
Commit
a3fd4817
authored
Aug 24, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unicode and other fixes for vault
parent
6e107d2f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
7 deletions
+9
-7
lib/ansible/parsing/__init__.py
+4
-1
lib/ansible/parsing/vault/__init__.py
+0
-0
lib/ansible/plugins/action/copy.py
+0
-1
test/units/parsing/vault/test_vault.py
+5
-5
No files found.
lib/ansible/parsing/__init__.py
View file @
a3fd4817
...
...
@@ -151,12 +151,15 @@ class DataLoader():
show_content
=
True
try
:
with
open
(
file_name
,
'r'
)
as
f
:
with
open
(
file_name
,
'r
b
'
)
as
f
:
data
=
f
.
read
()
if
self
.
_vault
.
is_encrypted
(
data
):
data
=
self
.
_vault
.
decrypt
(
data
)
show_content
=
False
data
=
to_unicode
(
data
,
errors
=
'strict'
)
return
(
data
,
show_content
)
except
(
IOError
,
OSError
)
as
e
:
raise
AnsibleParserError
(
"an error occurred while trying to read the file '
%
s':
%
s"
%
(
file_name
,
str
(
e
)))
...
...
lib/ansible/parsing/vault/__init__.py
View file @
a3fd4817
This diff is collapsed.
Click to expand it.
lib/ansible/plugins/action/copy.py
View file @
a3fd4817
...
...
@@ -29,7 +29,6 @@ from ansible.plugins.action import ActionBase
from
ansible.utils.boolean
import
boolean
from
ansible.utils.hashing
import
checksum
from
ansible.utils.unicode
import
to_bytes
from
ansible.parsing.vault
import
VaultLib
class
ActionModule
(
ActionBase
):
...
...
test/units/parsing/vault/test_vault.py
View file @
a3fd4817
...
...
@@ -64,7 +64,7 @@ class TestVaultLib(unittest.TestCase):
slots
=
[
'is_encrypted'
,
'encrypt'
,
'decrypt'
,
'_
add_header
'
,
'_
format_output
'
,
'_split_header'
,]
for
slot
in
slots
:
assert
hasattr
(
v
,
slot
),
"VaultLib is missing the
%
s method"
%
slot
...
...
@@ -75,11 +75,11 @@ class TestVaultLib(unittest.TestCase):
data
=
u"$ANSIBLE_VAULT;9.9;TEST
\n
%
s"
%
hexlify
(
b
"ansible"
)
assert
v
.
is_encrypted
(
data
),
"encryption check on headered text failed"
def
test_
add_header
(
self
):
def
test_
format_output
(
self
):
v
=
VaultLib
(
'ansible'
)
v
.
cipher_name
=
"TEST"
sensitive_data
=
"ansible"
data
=
v
.
_
add_header
(
sensitive_data
)
data
=
v
.
_
format_output
(
sensitive_data
)
lines
=
data
.
split
(
b
'
\n
'
)
assert
len
(
lines
)
>
1
,
"failed to properly add header"
header
=
to_unicode
(
lines
[
0
])
...
...
@@ -87,7 +87,7 @@ class TestVaultLib(unittest.TestCase):
header_parts
=
header
.
split
(
';'
)
assert
len
(
header_parts
)
==
3
,
"header has the wrong number of parts"
assert
header_parts
[
0
]
==
'$ANSIBLE_VAULT'
,
"header does not start with $ANSIBLE_VAULT"
assert
header_parts
[
1
]
==
v
.
version
,
"header version is incorrect"
assert
header_parts
[
1
]
==
v
.
b_
version
,
"header version is incorrect"
assert
header_parts
[
2
]
==
'TEST'
,
"header does end with cipher name"
def
test_split_header
(
self
):
...
...
@@ -97,7 +97,7 @@ class TestVaultLib(unittest.TestCase):
lines
=
rdata
.
split
(
b
'
\n
'
)
assert
lines
[
0
]
==
b
"ansible"
assert
v
.
cipher_name
==
'TEST'
,
"cipher name was not set"
assert
v
.
version
==
"9.9"
assert
v
.
b_
version
==
"9.9"
def
test_encrypt_decrypt_aes
(
self
):
if
not
HAS_AES
or
not
HAS_COUNTER
or
not
HAS_PBKDF2
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment