Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

CE-1380 Sanitize args #231

Merged
merged 1 commit into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions codecov/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@

remove_token = re.compile(r'token=[^\&]+').sub

def sanitize_arg(replacement, arg):
return re.sub(r'[\&]+', replacement, arg, 0, re.MULTILINE)


ignored_path = re.compile(r'(/vendor)|'
r'(/js/generated/coverage)|'
r'(/__pycache__)|'
Expand Down Expand Up @@ -624,11 +628,11 @@ def main(*argv, **kwargs):
)
write('==> Processing gcov (disable by -X gcov)')
cmd = "find %s %s -type f -name '*.gcno' %s -exec %s -pb %s {} +" % (
(codecov.gcov_root or root),
(sanitize_arg('', codecov.gcov_root or root)),
dont_search_here,
" ".join(map(lambda a: "-not -path '%s'" % a, codecov.gcov_glob)),
(codecov.gcov_exec or ''),
(codecov.gcov_args or ''))
(sanitize_arg('', codecov.gcov_exec or '')),
(sanitize_arg('', codecov.gcov_args or '')))
write(' Executing gcov (%s)' % cmd)
try_to_run(cmd)

Expand Down
3 changes: 3 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ def test_none_found(self):
else:
raise Exception("Did not raise AssertionError")

def test_sanitize_arg(self):
self.assertEqual(codecov.sanitize_arg('', '& echo test > vuln1.txt'), ' echo test > vuln1.txt')

@unittest.skipUnless(os.getenv('JENKINS_URL'), 'Skip Jenkins CI test')
def test_ci_jenkins(self):
self.set_env(BUILD_URL='https://....',
Expand Down