Skip to content

Commit 2868685

Browse files
authored
Enable universal newlines when executing local commands. (#156)
Universal newline support is enabled by default in all calls that read data. This means that any non-binary evidence with a foreign newline convention cannot be verified. When the evidence is read, all line endings are converted to '\n' which changes the expected digest. This change enables universal newline mode during the evidence fetch. The subprocess output will be opened as text streams in universal newlines mode. All line endings will be converted to '\n' ensuring the evidence can be later verified. If you must retain evidence with foreign newline conventions then set `binary_content = True`.
1 parent a7d803e commit 2868685

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# [2.0.1](https://github.com/ComplianceAsCode/auditree-framework/releases/tag/v2.0.1)
2+
3+
- [FIXED] Enable universal newlines when executing local commands.
4+
15
# [2.0.0](https://github.com/ComplianceAsCode/auditree-framework/releases/tag/v2.0.0)
26

37
- [ADDED] Documentation on how to use it with 1Password CLI.

compliance/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414
"""Compliance automation package."""
1515

16-
__version__ = "2.0.0"
16+
__version__ = "2.0.1"

compliance/fetch.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,10 @@ def fetchLocalCommands( # noqa: N802
150150
cmd += ["-t"]
151151
if not cwd:
152152
cwd = os.path.expanduser("~")
153-
stdin = str.encode("\n".join(commands) + "\n")
154-
return (
155-
check_output(cmd, cwd=cwd, env=env, input=stdin, timeout=timeout)
156-
.decode()
157-
.rstrip()
158-
)
153+
stdin = "\n".join(commands) + "\n"
154+
return check_output(
155+
cmd, cwd=cwd, env=env, input=stdin, timeout=timeout, universal_newlines=True
156+
).rstrip()
159157

160158

161159
def fetch(url, name):

0 commit comments

Comments
 (0)