Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-7485

Builtin database name filter is incorrectly applied only to collections instead of databases in snapshot

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.7.0.Alpha1
    • 2.5.2.Final
    • mongodb-connector
    • None
    • False
    • None
    • False

      Filters.java

      private Predicate<String> createDatabaseFilter() {
              var dbIncludeList = config.getDbIncludeList();
              var dbExcludeList = config.getDbExcludeList();
      
              return Optional.<Predicate<String>> empty()
                      .or(() -> dbIncludeList.map(value -> includes(value, s -> s)))
                      .or(() -> dbExcludeList.map(value -> excludes(value, s -> s)))
                      .orElse((db) -> true);
          }
      
      private Predicate<CollectionId> createCollectionFilter() {
              var collectionIncludeList = config.getCollectionIncludeList();
              var collectionExcludeList = config.getCollectionExcludeList();
      
              final Predicate<CollectionId> collectionFilter = Optional.<Predicate<CollectionId>> empty()
                      .or(() -> collectionIncludeList.map(list -> includes(list, CollectionId::namespace)))
                      .or(() -> collectionExcludeList.map(list -> excludes(list, CollectionId::namespace)))
                      .orElse((id) -> true)
                      .and(this::isNotBuiltIn);
      
              // Create signal collection filter if specified and not included
              Optional<Predicate<CollectionId>> signalCollectionFilter = config.getSignalDataCollection()
                      .map(CollectionId::parse)
                      .filter(id -> !collectionFilter.test(id))
                      .map(id -> Predicates.includes(id.namespace(), CollectionId::namespace));
      
              // Combine signal filter and collection filter
              return signalCollectionFilter.map(collectionFilter::or).orElse(collectionFilter);
          }
      
      

      While this doesn't break anything it requires the elevated permissions on built-in mongo database (list collections).
      No unexpected collections are read as they are always filter out by the collection filter.

              anmohant Anisha Mohanty
              jcechace@redhat.com Jakub Čecháček
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: