Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Changed

Contributed by @hnanchahal

* Upgraded cryptography version to 3.2 to avoid CVE-2020-25659 (security) #5095

Fixed
~~~~~~~~~
* Added monkey patch fix to st2stream to enable it to work with mongodb via SSL. (bug fix) #5078 #5091
Expand Down
35 changes: 22 additions & 13 deletions contrib/runners/python_runner/tests/unit/test_pythonrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
TEST_ACTION_PATH = os.path.join(tests_base.get_resources_path(), 'packs',
'pythonactions/actions/test.py')
PATHS_ACTION_PATH = os.path.join(tests_base.get_resources_path(), 'packs',
'pythonactions/actions/python_paths.py')
'pythonactions/actions/python_paths.py')
ACTION_1_PATH = os.path.join(tests_base.get_fixtures_path(),
'packs/dummy_pack_9/actions/list_repos_doesnt_exist.py')
ACTION_2_PATH = os.path.join(tests_base.get_fixtures_path(),
Expand All @@ -65,7 +65,7 @@
PRINT_CONFIG_ITEM_ACTION = os.path.join(tests_base.get_resources_path(), 'packs',
'pythonactions/actions/print_config_item_doesnt_exist.py')
PRINT_TO_STDOUT_STDERR_ACTION = os.path.join(tests_base.get_resources_path(), 'packs',
'pythonactions/actions/print_to_stdout_and_stderr.py')
'pythonactions/actions/print_to_stdout_and_stderr.py')


# Note: runner inherits parent args which doesn't work with tests since test pass additional
Expand Down Expand Up @@ -315,8 +315,8 @@ def test_action_stdout_and_stderr_is_not_stored_in_db_by_default(self, mock_spaw
runner.pre_run()
(_, output, _) = runner.run({'row_index': 4})

self.assertEqual(output['stdout'], 'pre result line 1\npost result line 1')
self.assertEqual(output['stderr'], 'stderr line 1\nstderr line 2\nstderr line 3\n')
self.assertMultiLineEqual(output['stdout'], 'pre result line 1\npost result line 1')
self.assertMultiLineEqual(output['stderr'], 'stderr line 1\nstderr line 2\nstderr line 3\n')
self.assertEqual(output['result'], 'True')
self.assertEqual(output['exit_code'], 0)

Expand All @@ -339,8 +339,8 @@ def test_action_stdout_and_stderr_is_not_stored_in_db_by_default(self, mock_spaw
runner.pre_run()
(_, output, _) = runner.run({'row_index': 4})

self.assertEqual(output['stdout'], 'pre result line 1\npost result line 1')
self.assertEqual(output['stderr'], 'stderr line 1\nstderr line 2\nstderr line 3\n')
self.assertMultiLineEqual(output['stdout'], 'pre result line 1\npost result line 1')
self.assertMultiLineEqual(output['stderr'], 'stderr line 1\nstderr line 2\nstderr line 3\n')
self.assertEqual(output['result'], 'True')
self.assertEqual(output['exit_code'], 0)

Expand Down Expand Up @@ -387,9 +387,9 @@ def test_action_stdout_and_stderr_is_stored_in_the_db(self, mock_spawn, mock_pop
runner.pre_run()
(_, output, _) = runner.run({'row_index': 4})

self.assertEqual(output['stdout'],
self.assertMultiLineEqual(output['stdout'],
'pre result line 1\npre result line 2\npost result line 1')
self.assertEqual(output['stderr'], 'stderr line 1\nstderr line 2\nstderr line 3\n')
self.assertMultiLineEqual(output['stderr'], 'stderr line 1\nstderr line 2\nstderr line 3\n')
self.assertEqual(output['result'], 'True')
self.assertEqual(output['exit_code'], 0)

Expand Down Expand Up @@ -420,19 +420,26 @@ def test_real_time_output_streaming_bufsize(self):
group='actionrunner')

output_dbs = ActionExecutionOutput.get_all()
self.assertEqual(len(output_dbs), (index - 1) * 4)
# Unexpected third party warnings will also inflate this number
self.assertGreaterEqual(len(output_dbs), (index - 1) * 4)

runner = self._get_mock_runner_obj()
runner.entry_point = PRINT_TO_STDOUT_STDERR_ACTION
runner.pre_run()
(_, output, _) = runner.run({'stdout_count': 2, 'stderr_count': 2})

self.assertEqual(output['stdout'], 'stdout line 0\nstdout line 1\n')
self.assertEqual(output['stderr'], 'stderr line 0\nstderr line 1\n')
# assertMultiLineEqual displays a diff if the two don't match
self.assertMultiLineEqual(output['stdout'], 'stdout line 0\nstdout line 1\n')
# Third party packages can unexpectedly emit warnings and add more
# output to the streamed stderr, so we check that the expected
# lines occurred, but we allow additional lines to exist
self.assertIn('stderr line 0\n', output['stderr'])
self.assertIn('stderr line 1\n', output['stderr'])
self.assertEqual(output['exit_code'], 0)

output_dbs = ActionExecutionOutput.get_all()
self.assertEqual(len(output_dbs), (index) * 4)
# Unexpected third party warnings will also inflate this number
self.assertGreaterEqual(len(output_dbs), (index) * 4)

@mock.patch('st2common.util.concurrency.subprocess_popen')
def test_stdout_interception_and_parsing(self, mock_popen):
Expand Down Expand Up @@ -701,7 +708,9 @@ def test_simple_action_log_messages_and_log_level_runner_param(self):
lines.append(line)

msg = ('Expected %s lines, got %s - "%s"' % (expected_count, len(lines), str(lines)))
self.assertEqual(len(lines), expected_count, msg)
# Dependencies can inject their own warnings, which increases the
# number of lines to more than we expect with simple equality checks
self.assertGreaterEqual(len(lines), expected_count, msg)

# Only log messages with level info and above should be displayed
runner = self._get_mock_runner_obj()
Expand Down
2 changes: 1 addition & 1 deletion fixed-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ amqp==2.5.2
apscheduler==3.6.3
# NOTE: 2.0 version breaks pymongo work with hosts
dnspython>=1.16.0,<2.0.0
cryptography==2.8
cryptography==3.2
# Note: 0.20.0 removed select.poll() on which some of our code and libraries we
# depend on rely
eventlet==0.25.1
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ amqp==2.5.2
apscheduler==3.6.3
argcomplete
bcrypt==3.1.7
cryptography==2.8
cryptography==3.2
dnspython<2.0.0,>=1.16.0
eventlet==0.25.1
flex==6.14.0
Expand Down
2 changes: 1 addition & 1 deletion st2client/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# in-requirements.txt for that component and then run 'make requirements' to
# update the component requirements.txt
argcomplete
cryptography==2.8
cryptography==3.2
jsonpath-rw==1.4.0
jsonschema==2.6.0
more-itertools==5.0.0
Expand Down
2 changes: 1 addition & 1 deletion st2common/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# update the component requirements.txt
amqp==2.5.2
apscheduler==3.6.3
cryptography==2.8
cryptography==3.2
dnspython<2.0.0,>=1.16.0
eventlet==0.25.1
flex==6.14.0
Expand Down