@Test public void nothingLoggableByDefault() { ImmutableSafeLoggableData.Builder builder = ImmutableSafeLoggableData.builder(); SafeLoggableDataUtils.addLoggableNamesToBuilder(builder, TABLE_REFERENCE_1, TABLE_METADATA_1); SafeLoggableData safeLoggableData = builder.build(); assertThat(safeLoggableData.isTableReferenceSafe(TABLE_REFERENCE_1)).isFalse(); assertThat(safeLoggableData.isRowComponentNameSafe(TABLE_REFERENCE_1, ROW_COMPONENT_NAME)).isFalse(); assertThat(safeLoggableData.isColumnNameSafe(TABLE_REFERENCE_1, "barrrr")).isFalse(); }
@VisibleForTesting static void addLoggableNamesToBuilder( ImmutableSafeLoggableData.Builder builder, TableReference ref, TableMetadata tableMetadata) { if (IS_SAFE.test(tableMetadata.getNameLogSafety())) { builder.addPermittedTableReferences(ref); } builder.addPermittedTableReferences(AtlasDbConstants.DEFAULT_METADATA_TABLE); Set<String> loggableRowComponentNames = tableMetadata.getRowMetadata() .getRowParts() .stream() .filter(rowComponent -> IS_SAFE.test(rowComponent.getLogSafety())) .map(NameComponentDescription::getComponentName) .collect(Collectors.toSet()); builder.putPermittedRowComponents(ref, loggableRowComponentNames); Set<NamedColumnDescription> namedColumns = tableMetadata.getColumns().getNamedColumns(); if (namedColumns != null) { Set<String> loggableColumnNames = namedColumns .stream() .filter(columnComponent -> IS_SAFE.test(columnComponent.getLogSafety())) .map(NamedColumnDescription::getLongName) .collect(Collectors.toSet()); builder.putPermittedColumnNames(ref, loggableColumnNames); } }
SafeLoggableDataUtils { @VisibleForTesting static void addLoggableNamesToBuilder( ImmutableSafeLoggableData.Builder builder, TableReference ref, TableMetadata tableMetadata) { if (IS_SAFE.test(tableMetadata.getNameLogSafety())) { builder.addPermittedTableReferences(ref); } builder.addPermittedTableReferences(AtlasDbConstants.DEFAULT_METADATA_TABLE); Set<String> loggableRowComponentNames = tableMetadata.getRowMetadata() .getRowParts() .stream() .filter(rowComponent -> IS_SAFE.test(rowComponent.getLogSafety())) .map(NameComponentDescription::getComponentName) .collect(Collectors.toSet()); builder.putPermittedRowComponents(ref, loggableRowComponentNames); Set<NamedColumnDescription> namedColumns = tableMetadata.getColumns().getNamedColumns(); if (namedColumns != null) { Set<String> loggableColumnNames = namedColumns .stream() .filter(columnComponent -> IS_SAFE.test(columnComponent.getLogSafety())) .map(NamedColumnDescription::getLongName) .collect(Collectors.toSet()); builder.putPermittedColumnNames(ref, loggableColumnNames); } } }
SafeLoggableDataUtils { @VisibleForTesting static void addLoggableNamesToBuilder( ImmutableSafeLoggableData.Builder builder, TableReference ref, TableMetadata tableMetadata) { if (IS_SAFE.test(tableMetadata.getNameLogSafety())) { builder.addPermittedTableReferences(ref); } builder.addPermittedTableReferences(AtlasDbConstants.DEFAULT_METADATA_TABLE); Set<String> loggableRowComponentNames = tableMetadata.getRowMetadata() .getRowParts() .stream() .filter(rowComponent -> IS_SAFE.test(rowComponent.getLogSafety())) .map(NameComponentDescription::getComponentName) .collect(Collectors.toSet()); builder.putPermittedRowComponents(ref, loggableRowComponentNames); Set<NamedColumnDescription> namedColumns = tableMetadata.getColumns().getNamedColumns(); if (namedColumns != null) { Set<String> loggableColumnNames = namedColumns .stream() .filter(columnComponent -> IS_SAFE.test(columnComponent.getLogSafety())) .map(NamedColumnDescription::getLongName) .collect(Collectors.toSet()); builder.putPermittedColumnNames(ref, loggableColumnNames); } } private  SafeLoggableDataUtils(); }
SafeLoggableDataUtils { @VisibleForTesting static void addLoggableNamesToBuilder( ImmutableSafeLoggableData.Builder builder, TableReference ref, TableMetadata tableMetadata) { if (IS_SAFE.test(tableMetadata.getNameLogSafety())) { builder.addPermittedTableReferences(ref); } builder.addPermittedTableReferences(AtlasDbConstants.DEFAULT_METADATA_TABLE); Set<String> loggableRowComponentNames = tableMetadata.getRowMetadata() .getRowParts() .stream() .filter(rowComponent -> IS_SAFE.test(rowComponent.getLogSafety())) .map(NameComponentDescription::getComponentName) .collect(Collectors.toSet()); builder.putPermittedRowComponents(ref, loggableRowComponentNames); Set<NamedColumnDescription> namedColumns = tableMetadata.getColumns().getNamedColumns(); if (namedColumns != null) { Set<String> loggableColumnNames = namedColumns .stream() .filter(columnComponent -> IS_SAFE.test(columnComponent.getLogSafety())) .map(NamedColumnDescription::getLongName) .collect(Collectors.toSet()); builder.putPermittedColumnNames(ref, loggableColumnNames); } } private  SafeLoggableDataUtils(); static SafeLoggableData fromTableMetadata(Map<TableReference, byte[]> tableRefToMetadata); }
SafeLoggableDataUtils { @VisibleForTesting static void addLoggableNamesToBuilder( ImmutableSafeLoggableData.Builder builder, TableReference ref, TableMetadata tableMetadata) { if (IS_SAFE.test(tableMetadata.getNameLogSafety())) { builder.addPermittedTableReferences(ref); } builder.addPermittedTableReferences(AtlasDbConstants.DEFAULT_METADATA_TABLE); Set<String> loggableRowComponentNames = tableMetadata.getRowMetadata() .getRowParts() .stream() .filter(rowComponent -> IS_SAFE.test(rowComponent.getLogSafety())) .map(NameComponentDescription::getComponentName) .collect(Collectors.toSet()); builder.putPermittedRowComponents(ref, loggableRowComponentNames); Set<NamedColumnDescription> namedColumns = tableMetadata.getColumns().getNamedColumns(); if (namedColumns != null) { Set<String> loggableColumnNames = namedColumns .stream() .filter(columnComponent -> IS_SAFE.test(columnComponent.getLogSafety())) .map(NamedColumnDescription::getLongName) .collect(Collectors.toSet()); builder.putPermittedColumnNames(ref, loggableColumnNames); } } private  SafeLoggableDataUtils(); static SafeLoggableData fromTableMetadata(Map<TableReference, byte[]> tableRefToMetadata);  }