#30 framework: sepolicy.info() returns a generator, not a list
Closed 4 years ago by plautrba. Opened 4 years ago by plautrba.
plautrba/setroubleshoot sepolicy.info-generator  into  master

@@ -734,10 +734,10 @@ 

      def __typeMatch(self, context, type_list):

          # get array of context type and it's aliases

          try:

-             _info = info(TYPE, context.type)[0]

+             _info = next(info(TYPE, context.type))

              ctypes = _info.get('aliases', [])

              ctypes.append(_info['name'])

-         except (RuntimeError, IndexError):

+         except (RuntimeError, IndexError, StopIteration):

              ctypes = [context.type]

  

          for type in type_list:

Commit c55edb3 ("framework: Fix AVC.__typeMatch to handle aliases
properly") was forward ported from stable branch. Unfortunately, stable branch
is supposed to be used with sepolicy version which generates a list, while
master branch is used with version generating a generator.

Fixes:

  File "/usr/lib/python3.8/site-packages/setroubleshoot/audit_data.py", line 737, in __typeMatch                                                                                                                                                                                                                             
    _info = info(TYPE, context.type)[0]                                                                                                                                                                                                                                                                                      
  TypeError: 'generator' object is not subscriptable                                                                                                                                                                                                                                                                         

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1784564

rebased onto 59d1907

4 years ago

Pull-Request has been closed by plautrba

4 years ago
Metadata