Github user markap14 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/461#discussion_r64257999
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java
 ---
    @@ -2024,6 +1843,24 @@ public Response instantiateTemplate(
         // templates
         // ---------
     
    +    private void authorizeSnippetUsage(final AuthorizableLookup lookup, 
final String groupId, final String snippetId) {
    +        // ensure write access to the target process group
    +        lookup.getProcessGroup(groupId).authorize(authorizer, 
RequestAction.WRITE);
    +
    +        // ensure read permission to every component in the snippet
    +        final Snippet snippet = lookup.getSnippet(snippetId);
    +        final Set<Authorizable> authorizables = new HashSet<>();
    +        
authorizables.addAll(snippet.getProcessGroups().keySet().stream().map(id -> 
lookup.getProcessGroup(id)).collect(Collectors.toSet()));
    --- End diff --
    
    It probably makes sense here to change this to:
    `snippet.getProcessGroups().keySet().stream().map(id -> 
lookup.getProcessGroup(id)).forEach(auth -> authorizables.add(auth));
    `
    This way we don't have to keep creating all of these intermediate Set 
objects just so that we can add them to the 'authorizables' set.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to