Skip to content

Conversation

@jdmeyer3
Copy link

@jdmeyer3 jdmeyer3 commented Aug 6, 2019

Closes #4758

The error caused in #4758 is because the ldap rbac is expecting the document returned from the ActionExecutionDB to contain action.pack and action.uid, but they are currently not being returned.

Here is the traceback I got from the rbac

Traceback (most recent call last):
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2rbac_enterprise_backend/utils.py", line 120, in assert_user_has_resource_db_permission
    permission_type=permission_type)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2rbac_enterprise_backend/utils.py", line 287, in user_has_resource_db_permission
    permission_type=permission_type)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2rbac_enterprise_backend/resolvers.py", line 673, in user_has_resource_db_permission
    pack_db = PackDB(ref=action['pack'])
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/mongoengine/base/datastructures.py", line 54, in __getitem__
    value = super(BaseDict, self).__getitem__(key)
KeyError: 'pack'

and here is the action object that is returned when it gets the key error

<ActionExecutionDB: ActionExecutionDB(action={u'parameters': {u'pack': {u'required': True, u'type': u'string', u'description': u'Name of pack to lookup'}}}, children=[], context={}, delay=None, end_timestamp=None, id=5d49d6ddf55f7d00f89a00e7, liveaction={}, log=[], parameters={u'log_level': u'DEBUG', u'pack': u'packs'}, parent=None, result={u'result': {u'git_status': None, u'pack': {u'description': u'Pack management functionality.', u'author': u'StackStorm, Inc.', u'python_versions': [u'2', u'3'], u'version': u'3.1.0', u'email': u'[email protected]', u'name': u'packs'}}, u'exit_code': 0, u'stderr': u'', u'stdout': u''}, rule={}, runner={u'runner_parameters': {u'debug': {u'default': False, u'required': False, u'type': u'boolean', u'description': u'Enable runner debug mode.'}, u'content_version': {u'required': False, u'type': u'string', u'description': u'Git revision of the pack content to use for this action execution (git commit sha / tag / branch). Only applies to packs which are git repositories.'}, u'log_level': {u'default': u'DEBUG', u'enum': [u'AUDIT', u'CRITICAL', u'ERROR', u'WARNING', u'INFO', u'DEBUG'], u'type': u'string', u'description': u'Default log level for Python runner actions.'}, u'env': {u'type': u'object', u'description': u'Environment variables which will be available to the script.'}, u'timeout': {u'default': 600, u'type': u'integer', u'description': u"Action timeout in seconds. Action will get killed if it doesn't finish in timeout seconds."}}}, start_timestamp="2019-08-06 19:58:10.371616+00:00", status=None, task_execution=None, trigger={}, trigger_instance={}, trigger_type={}, web_url=None, workflow_execution=None)>

By having mongo return the action.pack, and the action.uid, it should satisfy the st2rbac requirements
image

Kami added 7 commits July 30, 2019 21:08
Make sure we only generate coverage for runners and orquesta integration
tests when ENABLE_COVERAGE environment variable is set to "yes".

Coverage adds a lot of overhead so this should speed up PR builds.
invocation basis.

Update tests which have a race / rely on timing to use longer wait time
to avoid failure.
nightly build.

This should substantially speed up PR builds.
@CLAassistant
Copy link

CLAassistant commented Aug 6, 2019

CLA assistant check
All committers have signed the CLA.

@jdmeyer3 jdmeyer3 force-pushed the bug/enterprise_ldap_view_executions_error branch from 4b0d69e to 0abe410 Compare August 6, 2019 20:08
@VineeshJain
Copy link
Contributor

Thanks for your contribution @jdmeyer3 , we will review it and merge.

@jdmeyer3 jdmeyer3 force-pushed the bug/enterprise_ldap_view_executions_error branch from 46c3c93 to 3cf45d3 Compare August 6, 2019 21:35
@jdmeyer3 jdmeyer3 force-pushed the bug/enterprise_ldap_view_executions_error branch from 3cf45d3 to 8fb27e7 Compare August 6, 2019 21:36
Kami added 2 commits August 7, 2019 09:57
"url_hosts_blacklist" and also add support for whitelist approach using
"url_hosts_whitelist" runner parameter.
@arm4b arm4b added this to the 3.2.0 milestone Aug 7, 2019
jdmeyer3 and others added 10 commits August 7, 2019 09:34
Previously we don't had test cases for HTTPClient class, but not the
actual runner.
are specified, but not all of them have corresponding nightly tasks.

For example:

TASK="foo1 foo2 foo3" and only "foo2-nightly" task exists. In this case,
only "foo2-nightly" would run and other would be ignored.
'runner.runner_parameters',
'parameters'
'parameters',
# necessary for ActionExecutionDB to determine permissions in enterprise ldap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, we could only include that if rbac is enabled, but since those attributes are quite small, it doesn't hurt to include them in all the responses...

@Kami
Copy link
Member

Kami commented Aug 9, 2019

Thanks for contributing this bug fix.

I will go ahead and add a corresponding test case to our proprietary RBAC code base.

@Kami
Copy link
Member

Kami commented Aug 9, 2019

While working on the tests, I noticed there is another bug hiding in there.

When, rbac.permission_isolation config option is enabled, context attribute is mandatory as well - 9a712d9.

Kami added 2 commits August 9, 2019 16:30
works when RBAC is enabled.

When RBAC is enabled, we simply use admin use when testing include and
exclude attributes functionality.
@Kami
Copy link
Member

Kami commented Aug 9, 2019

And to clarify / add some context - I believe this issue would only affect WebUI by default, but not CLI, since WebUI tries to retrieve less fields (only the ones it needs) to speed things up.

jdmeyer3 and others added 6 commits August 9, 2019 16:47
works when RBAC is enabled.

When RBAC is enabled, we simply use admin use when testing include and
exclude attributes functionality.
…m:jdmeyer3/st2 into bug/enterprise_ldap_view_executions_error
@Kami Kami merged commit cd64cec into StackStorm:master Aug 9, 2019
@Kami Kami modified the milestones: 3.2.0, 3.1.1 Aug 9, 2019
test_exact_object_count = True

# True if those tests are running with rbac enabled
rbac_enabled = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this value set to True for the tests below?


def test_get_all_exclude_attributes_and_include_attributes_are_mutually_exclusive(self):
if self.rbac_enabled:
self.use_user(self.users['admin'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain where self.rbac_enabled is set to True and also how is adding the user here test the changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

With enterprise LDAP, retrieve single execution returns 500

7 participants