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

Commit

Permalink
Merge pull request #231 from codecov/ce-1380
Browse files Browse the repository at this point in the history
CE-1380 Sanitize args
  • Loading branch information
drazisil authored Feb 22, 2020
2 parents 73b1b13 + 2a80aa4 commit b2951c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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

0 comments on commit b2951c0

Please sign in to comment.