Skip to content

Commit

Permalink
Merge pull request #536 from kasunch/hidesensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
uilianries authored Dec 3, 2020
2 parents 40b5d2a + 3110972 commit c65cd53
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cpt/runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import subprocess
import re
from collections import namedtuple

from conans import tools
Expand Down Expand Up @@ -375,8 +376,12 @@ def __init__(self, runner, printer):
self.runner = runner
self.printer = printer

def __call__(self, command):
self.printer.print_command(command)
def __call__(self, command, hide_sensitive=True):
cmd_str = command
if hide_sensitive:
cmd_str = re.sub(r'(CONAN_LOGIN_USERNAME[_\w+]*)=\"(\w+)\"', r'\1="xxxxxxxx"', cmd_str)
cmd_str = re.sub(r'(CONAN_PASSWORD[_\w+]*)=\"(\w+)\"', r'\1="xxxxxxxx"', cmd_str)
self.printer.print_command(cmd_str)
sys.stderr.flush()
sys.stdout.flush()
return self.runner(command)
33 changes: 33 additions & 0 deletions cpt/test/integration/docker_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess
import unittest
import time
import textwrap

from conans import tools
from conans.model.ref import ConanFileReference
Expand Down Expand Up @@ -234,3 +235,35 @@ def build(self):
self.packager.run()
self.assertIn("Error updating the image", str(raised.exception))
self.assertIn("foobar install conan_package_tools", str(raised.exception))

@unittest.skipUnless(is_linux_and_have_docker(), "Requires Linux and Docker")
def test_docker_hidden_password(self):
conanfile = textwrap.dedent("""
from conans import ConanFile
class Pkg(ConanFile):
settings = "os", "compiler", "build_type", "arch"
def build(self):
pass
""")

self.save_conanfile(conanfile)
with tools.environment_append({"CONAN_USERNAME": "bar",
"CONAN_LOGIN_USERNAME": "foobar",
"CONAN_PASSWORD": "foobazcouse",
"CONAN_DOCKER_IMAGE": "conanio/gcc8",
"CONAN_REFERENCE": "foo/0.0.1@bar/testing",
"CONAN_DOCKER_IMAGE_SKIP_UPDATE": "TRUE",
"CONAN_FORCE_SELINUX": "TRUE",
"CONAN_DOCKER_USE_SUDO": "FALSE",
"CONAN_DOCKER_SHELL": "/bin/bash -c",
}):
self.packager = ConanMultiPackager(gcc_versions=["8"],
archs=["x86_64"],
build_types=["Release"],
out=self.output.write)
self.packager.add({})
self.packager.run()
self.assertIn('-e CONAN_LOGIN_USERNAME="xxxxxxxx"', self.output)
self.assertIn('-e CONAN_PASSWORD="xxxxxxxx"', self.output)

0 comments on commit c65cd53

Please sign in to comment.