Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] destinationSet.removeAllExcept doesn't remove destinations if no match is found #5875

Open
mhokanson opened this issue Aug 7, 2023 · 8 comments
Labels
bug Something isn't working Internal-Issue-Created An issue has been created in NextGen's internal issue tracker RS-11230 triaged

Comments

@mhokanson
Copy link
Contributor

Describe the bug
When using destinationSet.removeAllExcept(<destination name>) all destinations are enabled if no destinations match the supplied parameter.

This can lead to over-transmission of messages if there is a typo or some other issue in the destinationSet.removeAllExcept(<destination name>), leading to unintended PHI disclosures.

To Reproduce
Setup steps (if required). Example:

  1. Setup table in database with this schema
  2. Add rows '...'

Steps to reproduce the behavior:

  1. Set up multiple destinations
  2. In a source filter or transformer use destinationSet.removeAllExcept(<destination name>) with a typo in the <destination name> value
  3. Process a message which would have triggered destination removal if the typo weren't present
  4. Observe that no destinations were removed

Expected behavior
All destinations would be removed except the supplied destination. If no match is found all destinations should be removed (remove all except the one that wasn't found).

Actual behavior
When using destinationSet.removeAllExcept(<destination>) all destinations are enabled if no destinations match the supplied parameter.

Environment (please complete the following information):

  • OS: Windows 10, CentOS (version unknown)
  • Tested on Connect v3.10.1 (CentOS) and Connect v3.12.0 (Win 10)

Workaround(s)
Catch the output of destinationSet.removeAllExcept and perform a destinationSet.removeAll() if no destinations were removed.

@mhokanson mhokanson added the bug Something isn't working label Aug 7, 2023
@pacmano1
Copy link
Collaborator

pacmano1 commented Aug 7, 2023

On 4.3, it does not appear to work that way.

In the source transformer:

destinationSet.removeAllExcept(['ad']);

Send a message in and all three destinations are in fact removed.

The three destinations are named

  1. Destination 1
  2. Destination 2
  3. Destination 3

@pacmano1
Copy link
Collaborator

pacmano1 commented Aug 7, 2023

I suspect you are doing the below, i.e. you are not passing an array.

destinationSet.removeAllExcept('ad');

@mhokanson
Copy link
Contributor Author

Indeed I am (I copied what my predecessor had done).

Does 4.3 remove all three destinations if you pass a string instead of an array? Passing a string seems to remove all but the desired channels in my tests IF there is a match.

@pacmano1
Copy link
Collaborator

pacmano1 commented Aug 7, 2023

Blaming the last person, lol.

The call needs an array, not a string so 4.3 does the same thing. I suppose you might change/update your issue to:

destinationSet.removeAllExcpept() should throw an error if an array is not passed

@mhokanson
Copy link
Contributor Author

I'll just log a new issue for that. Thanks!

@tonygermano
Copy link
Collaborator

The call needs an array, not a string so 4.3 does the same thing. I suppose you might change/update your issue to:

destinationSet.removeAllExcpept() should throw an error if an array is not passed

This is not true. There are two versions of DestinationSet.removeAllExcept. One takes an Object and the other takes a Collection<Object>. A JS array satisfies the second one, but a plain string should work as well.

@tonygermano tonygermano reopened this Aug 30, 2023
@tonygermano
Copy link
Collaborator

I'm able to confirm the bug. It only occurs when you are using a destination name which doesn't exist. If you pass it a number for a metadata id which doesn't exist, then it will correctly remove all destinations.

@tonygermano
Copy link
Collaborator

The problem is in this method:

public boolean removeAllExcept(Object metaDataIdOrConnectorName) {
if (metaDataIds != null) {
Integer metaDataId = convertToMetaDataId(metaDataIdOrConnectorName);
if (metaDataId != null) {
return metaDataIds.retainAll(Collections.singleton(metaDataId));
}
}
return false;
}

Lines 104-106 should be changed to something like:

         final Set<Integer> set = (metaDataId != null) ? Collections.singleton(metaDataId) : Collections.emptySet();
         return metaDataIds.retainAll(set); 

@lmillergithub lmillergithub added triaged Internal-Issue-Created An issue has been created in NextGen's internal issue tracker RS-11230 labels Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Internal-Issue-Created An issue has been created in NextGen's internal issue tracker RS-11230 triaged
Projects
None yet
Development

No branches or pull requests

4 participants