Skip to content

Commit 7fa8b10

Browse files
committed
Revert changes for custom exclude patterns and only leave default ones
1 parent 4cf9c83 commit 7fa8b10

File tree

2 files changed

+7
-38
lines changed

2 files changed

+7
-38
lines changed

easybuild/tools/testing.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959

6060
_log = fancylogger.getLogger('testing', fname=False)
6161

62-
_exclude_env_from_report = []
6362
DEFAULT_EXCLUDE_FROM_TEST_REPORT_ENV_VAR_NAMES = [
6463
'KEY',
6564
'SECRET',
@@ -81,7 +80,8 @@
8180
r'xox[baprs]-[A-Za-z0-9-]+', # Slack token
8281

8382
# https://github.com/odomojuli/regextokens
84-
r'^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$', # Base64
83+
# This is too aggressive and can end up excluding any alphanumeric string with length multiple of 4
84+
# r'^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$', # Base64
8585
r'[1-9][0-9]+-[0-9a-zA-Z]{40}', # Twitter token
8686
r'EAACEdEose0cBA[0-9A-Za-z]+', # Facebook token
8787
r'[0-9a-fA-F]{7}.[0-9a-fA-F]{32}', # Instagram token
@@ -183,21 +183,6 @@ def session_state():
183183
}
184184

185185

186-
def exclude_env_from_report_add(key):
187-
"""
188-
Exclude key from test report if an environment variables contains key.
189-
:param key: environment variable to exclude
190-
"""
191-
_exclude_env_from_report.append(key.upper())
192-
193-
194-
def exclude_env_from_report_clear():
195-
"""
196-
Clear list of environment variables to exclude from test report.
197-
"""
198-
_exclude_env_from_report.clear()
199-
200-
201186
def create_test_report(msg, ecs_with_res, init_session_state, pr_nrs=None, gist_log=False, easyblock_pr_nrs=None,
202187
ec_parse_error=None):
203188
"""
@@ -323,7 +308,7 @@ def create_test_report(msg, ecs_with_res, init_session_state, pr_nrs=None, gist_
323308
for key in sorted(environ_dump.keys()):
324309
if env_filter is not None and env_filter.search(key):
325310
continue
326-
if any(x in key.upper() for x in DEFAULT_EXCLUDE_FROM_TEST_REPORT_ENV_VAR_NAMES + _exclude_env_from_report):
311+
if any(x in key.upper() for x in DEFAULT_EXCLUDE_FROM_TEST_REPORT_ENV_VAR_NAMES):
327312
continue
328313
value = environ_dump[key]
329314
if any(re.match(rgx, value) for rgx in DEFAULT_EXCLUDE_FROM_TEST_REPORT_VALUE_REGEX):

test/framework/github.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
from easybuild.tools.github import det_pr_title, fetch_easyconfigs_from_commit, fetch_files_from_commit
5656
from easybuild.tools.github import is_patch_for, pick_default_branch
5757
from easybuild.tools.testing import create_test_report, post_pr_test_report, session_state
58-
from easybuild.tools.testing import exclude_env_from_report_add, exclude_env_from_report_clear
5958
import easybuild.tools.github as gh
6059

6160
try:
@@ -1320,15 +1319,11 @@ def test_github_create_test_report(self):
13201319
]
13211320
environ = {
13221321
'USER': 'test',
1323-
'DONT_REMOVE_ME': 'test-123',
13241322
}
13251323
JWT_HDR = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9'
13261324
JWT_PLD = 'eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNzA4MzQ1MTIzLCJleHAiOjE3MDgzNTUxMjN9'
13271325
JWT_SIG = 'SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
13281326
secret_environ = {
1329-
'REMOVEME': 'test-abc',
1330-
'ReMoVeMe2': 'TeSt-xyz',
1331-
13321327
# Test default removal based on variable value
13331328
'TOTALLYPUBLICVAR1': 'AKIAIOSFODNN7EXAMPLE', # AWS_ACCESS_KEY
13341329
'TOTALLYPUBLICVAR2': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', # AWS_SECRET_KEY
@@ -1355,27 +1350,19 @@ def test_github_create_test_report(self):
13551350
'time': gmtime(0),
13561351
}
13571352

1358-
# Test exclude_env_from_report_add/clear
1359-
exclude_env_from_report_add('REMOVEME'.lower()) # Also check that the name is uppercased in the check
1360-
13611353
res = create_test_report("just a test", ecs_with_res, init_session_state)
13621354
patterns = [
13631355
"**SUCCESS** _test.eb_",
13641356
"**FAIL (build issue)** _fail.eb_",
13651357
"01 Jan 1970 00:00:00",
13661358
"EASYBUILD_DEBUG=1",
1367-
"DONT_REMOVE_ME = test-123",
1359+
"USER = test",
13681360
]
13691361
for pattern in patterns:
13701362
self.assertIn(pattern, res['full'])
13711363

1372-
# Test that excluded patterns works by matching also partial strings
1373-
exclude_patterns1 = [
1374-
'REMOVEME',
1375-
'ReMoVeMe2',
1376-
]
13771364
# Test that known token regexes for ENV vars are excluded by default
1378-
exclude_patterns2 = [
1365+
exclude_patterns = [
13791366
'TOTALLYPUBLICVAR1',
13801367
'TOTALLYPUBLICVAR2',
13811368
'TOTALLYPUBLICVAR3',
@@ -1392,21 +1379,18 @@ def test_github_create_test_report(self):
13921379
'SECRET_SECRET',
13931380
'INFO_CREDENTIALS',
13941381
]
1395-
for pattern in exclude_patterns1 + exclude_patterns2:
1382+
for pattern in exclude_patterns:
13961383
# .lower() test that variable name is not case sensitive for excluding
13971384
self.assertNotIn(pattern.lower(), res['full'])
13981385

1399-
exclude_env_from_report_clear()
1400-
patterns += exclude_patterns1
1401-
14021386
res = create_test_report("just a test", ecs_with_res, init_session_state)
14031387
for pattern in patterns:
14041388
self.assertIn(pattern, res['full'])
14051389

14061390
for pattern in patterns[:2]:
14071391
self.assertIn(pattern, res['overview'])
14081392

1409-
for pattern in exclude_patterns2:
1393+
for pattern in exclude_patterns:
14101394
# .lower() test that variable name is not case sensitive for excluding
14111395
self.assertNotIn(pattern.lower(), res['full'])
14121396

0 commit comments

Comments
 (0)