From 64262ffdc8714b2eac28d45042dc4c4f767cf093 Mon Sep 17 00:00:00 2001 From: cezary-witkowski Date: Mon, 13 Jan 2025 15:27:17 +0100 Subject: [PATCH] [MNT-24807] Quickfix --- .../event2/filter/NodePropertyFilter.java | 21 +-- .../alfresco/repo/transfer/TransferModel.java | 158 ++++++++---------- .../repo/event2/EventFilterUnitTest.java | 64 ++++--- 3 files changed, 122 insertions(+), 121 deletions(-) diff --git a/repository/src/main/java/org/alfresco/repo/event2/filter/NodePropertyFilter.java b/repository/src/main/java/org/alfresco/repo/event2/filter/NodePropertyFilter.java index d6a4d70bdfb..14247aa0d2e 100644 --- a/repository/src/main/java/org/alfresco/repo/event2/filter/NodePropertyFilter.java +++ b/repository/src/main/java/org/alfresco/repo/event2/filter/NodePropertyFilter.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2023 Alfresco Software Limited + * Copyright (C) 2005 - 2025 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -39,18 +39,18 @@ */ public class NodePropertyFilter extends AbstractNodeEventFilter { - private static final String FILTERED_PROPERTIES = "sys:*"; + private static final String FILTERED_PROPERTIES = "sys:*,usr:password,usr:salt,usr:passwordHash,trx:password"; // These properties are included as top-level info, // so exclude them from the properties object private static final Set EXCLUDED_TOP_LEVEL_PROPS = Set.of(ContentModel.PROP_NAME, - ContentModel.PROP_MODIFIER, - ContentModel.PROP_MODIFIED, - ContentModel.PROP_CREATOR, - ContentModel.PROP_CREATED, - ContentModel.PROP_CONTENT); + ContentModel.PROP_MODIFIER, + ContentModel.PROP_MODIFIED, + ContentModel.PROP_CREATOR, + ContentModel.PROP_CREATED, + ContentModel.PROP_CONTENT); // These properties should not be excluded from the properties object private static final Set ALLOWED_PROPERTIES = Set.of(ContentModel.PROP_CASCADE_TX, - ContentModel.PROP_CASCADE_CRC); + ContentModel.PROP_CASCADE_CRC); private final List nodePropertiesBlackList; @@ -63,14 +63,15 @@ public NodePropertyFilter() public Set getExcludedTypes() { Set result = new HashSet<>(EXCLUDED_TOP_LEVEL_PROPS); - nodePropertiesBlackList.forEach(nodeProperty-> result.addAll(expandTypeDef(nodeProperty))); + nodePropertiesBlackList.forEach(nodeProperty -> result.addAll(expandTypeDef(nodeProperty))); return result; } @Override public boolean isExcluded(QName qName) { - if(qName != null && ALLOWED_PROPERTIES.contains(qName)){ + if (qName != null && ALLOWED_PROPERTIES.contains(qName)) + { return false; } return super.isExcluded(qName); diff --git a/repository/src/main/java/org/alfresco/repo/transfer/TransferModel.java b/repository/src/main/java/org/alfresco/repo/transfer/TransferModel.java index 4f694040412..893c0958400 100644 --- a/repository/src/main/java/org/alfresco/repo/transfer/TransferModel.java +++ b/repository/src/main/java/org/alfresco/repo/transfer/TransferModel.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2025 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -23,87 +23,75 @@ * along with Alfresco. If not, see . * #L% */ -package org.alfresco.repo.transfer; - -import org.alfresco.service.namespace.QName; - -/** - * Transfer Model Constants - * - * @author Mark Rogers - * @author Brian Remmington - */ -public interface TransferModel -{ - static final String TRANSFER_MODEL_1_0_URI = "http://www.alfresco.org/model/transfer/1.0"; - - static final QName ASPECT_ENABLEABLE = QName.createQName(TRANSFER_MODEL_1_0_URI, "enableable"); -// static final QName ASSOC_IMAP_ATTACHMENTS_FOLDER = QName.createQName(IMAP_MODEL_1_0_URI, "attachmentsFolder"); - - /** - * Aspect : transferred - */ - static final QName ASPECT_TRANSFERRED = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferred"); - static final QName PROP_REPOSITORY_ID = QName.createQName(TRANSFER_MODEL_1_0_URI, "repositoryId"); - static final QName PROP_FROM_REPOSITORY_ID = QName.createQName(TRANSFER_MODEL_1_0_URI, "fromRepositoryId"); - static final QName PROP_FROM_CONTENT = QName.createQName(TRANSFER_MODEL_1_0_URI, "fromContent"); - - /** - * Aspect : alien - */ - static final QName ASPECT_ALIEN = QName.createQName(TRANSFER_MODEL_1_0_URI, "alien"); - static final QName PROP_INVADED_BY = QName.createQName(TRANSFER_MODEL_1_0_URI, "invadedBy"); - - /** - * Aspect : fileTransferTarget - */ - static final QName TYPE_FILE_TRANSFER_TARGET = QName.createQName(TRANSFER_MODEL_1_0_URI, "fileTransferTarget"); - static final QName ASSOC_ROOT_FILE_TRANSFER = QName.createQName(TRANSFER_MODEL_1_0_URI, "fileTransferRootNode"); - - /* - * Type : Transfer Group - */ - static final QName TYPE_TRANSFER_GROUP = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferGroup"); - - /* - * Type : Transfer Target - */ - static final QName TYPE_TRANSFER_TARGET = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferTarget"); - static final QName PROP_ENDPOINT_PROTOCOL = QName.createQName(TRANSFER_MODEL_1_0_URI, "endpointprotocol"); - static final QName PROP_ENDPOINT_HOST = QName.createQName(TRANSFER_MODEL_1_0_URI, "endpointhost"); - static final QName PROP_ENDPOINT_PORT = QName.createQName(TRANSFER_MODEL_1_0_URI, "endpointport"); - static final QName PROP_ENDPOINT_PATH = QName.createQName(TRANSFER_MODEL_1_0_URI, "endpointpath"); - static final QName PROP_USERNAME = QName.createQName(TRANSFER_MODEL_1_0_URI, "username"); - static final QName PROP_PASSWORD = QName.createQName(TRANSFER_MODEL_1_0_URI, "password"); - - static final QName PROP_ENABLED = QName.createQName(TRANSFER_MODEL_1_0_URI, "enabled"); - - /* - * Type : Transfer Lock - */ - static final QName TYPE_TRANSFER_LOCK = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferLock"); - static final QName PROP_TRANSFER_ID = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferId"); - - /* - * Type : Transfer Record - */ - static final QName TYPE_TRANSFER_RECORD = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferRecord"); - static final QName PROP_PROGRESS_POSITION = QName.createQName(TRANSFER_MODEL_1_0_URI, "progressPosition"); - static final QName PROP_PROGRESS_ENDPOINT = QName.createQName(TRANSFER_MODEL_1_0_URI, "progressEndpoint"); - static final QName PROP_TRANSFER_STATUS = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferStatus"); - static final QName PROP_TRANSFER_ERROR = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferError"); - - /* - * Type : Transfer report - */ - static final QName TYPE_TRANSFER_REPORT = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferReport"); - static final QName TYPE_TRANSFER_REPORT_DEST = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferReportDest"); - - /* - * Type : Temp Transfer Storage - */ - static final QName TYPE_TEMP_TRANSFER_STORE = QName.createQName(TRANSFER_MODEL_1_0_URI, "tempTransferStore"); - static final QName ASSOC_TRANSFER_ORPHAN = QName.createQName(TRANSFER_MODEL_1_0_URI, "orphan"); - - -} +package org.alfresco.repo.transfer; + +import org.alfresco.service.namespace.QName; + +/** + * Transfer Model Constants + * + * @author Mark Rogers + * @author Brian Remmington + */ +public interface TransferModel +{ + static final String TRANSFER_MODEL_PREFIX = "trx"; + static final String TRANSFER_MODEL_1_0_URI = "http://www.alfresco.org/model/transfer/1.0"; + + static final QName ASPECT_ENABLEABLE = QName.createQName(TRANSFER_MODEL_1_0_URI, "enableable"); + // static final QName ASSOC_IMAP_ATTACHMENTS_FOLDER = QName.createQName(IMAP_MODEL_1_0_URI, "attachmentsFolder"); + + /** + * Aspect : transferred + */ + static final QName ASPECT_TRANSFERRED = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferred"); + static final QName PROP_REPOSITORY_ID = QName.createQName(TRANSFER_MODEL_1_0_URI, "repositoryId"); + static final QName PROP_FROM_REPOSITORY_ID = QName.createQName(TRANSFER_MODEL_1_0_URI, "fromRepositoryId"); + static final QName PROP_FROM_CONTENT = QName.createQName(TRANSFER_MODEL_1_0_URI, "fromContent"); + + /** + * Aspect : alien + */ + static final QName ASPECT_ALIEN = QName.createQName(TRANSFER_MODEL_1_0_URI, "alien"); + static final QName PROP_INVADED_BY = QName.createQName(TRANSFER_MODEL_1_0_URI, "invadedBy"); + + /** + * Aspect : fileTransferTarget + */ + static final QName TYPE_FILE_TRANSFER_TARGET = QName.createQName(TRANSFER_MODEL_1_0_URI, "fileTransferTarget"); + static final QName ASSOC_ROOT_FILE_TRANSFER = QName.createQName(TRANSFER_MODEL_1_0_URI, "fileTransferRootNode"); + + /* Type : Transfer Group */ + static final QName TYPE_TRANSFER_GROUP = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferGroup"); + + /* Type : Transfer Target */ + static final QName TYPE_TRANSFER_TARGET = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferTarget"); + static final QName PROP_ENDPOINT_PROTOCOL = QName.createQName(TRANSFER_MODEL_1_0_URI, "endpointprotocol"); + static final QName PROP_ENDPOINT_HOST = QName.createQName(TRANSFER_MODEL_1_0_URI, "endpointhost"); + static final QName PROP_ENDPOINT_PORT = QName.createQName(TRANSFER_MODEL_1_0_URI, "endpointport"); + static final QName PROP_ENDPOINT_PATH = QName.createQName(TRANSFER_MODEL_1_0_URI, "endpointpath"); + static final QName PROP_USERNAME = QName.createQName(TRANSFER_MODEL_1_0_URI, "username"); + static final QName PROP_PASSWORD = QName.createQName(TRANSFER_MODEL_1_0_URI, "password"); + + static final QName PROP_ENABLED = QName.createQName(TRANSFER_MODEL_1_0_URI, "enabled"); + + /* Type : Transfer Lock */ + static final QName TYPE_TRANSFER_LOCK = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferLock"); + static final QName PROP_TRANSFER_ID = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferId"); + + /* Type : Transfer Record */ + static final QName TYPE_TRANSFER_RECORD = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferRecord"); + static final QName PROP_PROGRESS_POSITION = QName.createQName(TRANSFER_MODEL_1_0_URI, "progressPosition"); + static final QName PROP_PROGRESS_ENDPOINT = QName.createQName(TRANSFER_MODEL_1_0_URI, "progressEndpoint"); + static final QName PROP_TRANSFER_STATUS = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferStatus"); + static final QName PROP_TRANSFER_ERROR = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferError"); + + /* Type : Transfer report */ + static final QName TYPE_TRANSFER_REPORT = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferReport"); + static final QName TYPE_TRANSFER_REPORT_DEST = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferReportDest"); + + /* Type : Temp Transfer Storage */ + static final QName TYPE_TEMP_TRANSFER_STORE = QName.createQName(TRANSFER_MODEL_1_0_URI, "tempTransferStore"); + static final QName ASSOC_TRANSFER_ORPHAN = QName.createQName(TRANSFER_MODEL_1_0_URI, "orphan"); + +} diff --git a/repository/src/test/java/org/alfresco/repo/event2/EventFilterUnitTest.java b/repository/src/test/java/org/alfresco/repo/event2/EventFilterUnitTest.java index 25c60567813..cb5aba1f878 100644 --- a/repository/src/test/java/org/alfresco/repo/event2/EventFilterUnitTest.java +++ b/repository/src/test/java/org/alfresco/repo/event2/EventFilterUnitTest.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2020 Alfresco Software Limited + * Copyright (C) 2005 - 2025 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -35,6 +35,10 @@ import java.util.Collection; import java.util.Collections; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.stubbing.Answer; + import org.alfresco.model.ContentModel; import org.alfresco.model.ForumModel; import org.alfresco.model.RenditionModel; @@ -43,14 +47,12 @@ import org.alfresco.repo.event2.filter.NodeAspectFilter; import org.alfresco.repo.event2.filter.NodePropertyFilter; import org.alfresco.repo.event2.filter.NodeTypeFilter; +import org.alfresco.repo.transfer.TransferModel; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.namespace.NamespaceException; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.OneToManyHashBiMap; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.stubbing.Answer; /** * Tests event filters. @@ -78,13 +80,17 @@ public static void setUp() namespaceService = new MockNamespaceServiceImpl(); namespaceService.registerNamespace(NamespaceService.SYSTEM_MODEL_PREFIX, - NamespaceService.SYSTEM_MODEL_1_0_URI); + NamespaceService.SYSTEM_MODEL_1_0_URI); namespaceService.registerNamespace(NamespaceService.CONTENT_MODEL_PREFIX, - NamespaceService.CONTENT_MODEL_1_0_URI); + NamespaceService.CONTENT_MODEL_1_0_URI); namespaceService.registerNamespace(NamespaceService.FORUMS_MODEL_PREFIX, - NamespaceService.FORUMS_MODEL_1_0_URI); + NamespaceService.FORUMS_MODEL_1_0_URI); namespaceService.registerNamespace(NamespaceService.RENDITION_MODEL_PREFIX, - NamespaceService.RENDITION_MODEL_1_0_URI); + NamespaceService.RENDITION_MODEL_1_0_URI); + namespaceService.registerNamespace(ContentModel.USER_MODEL_PREFIX, + ContentModel.USER_MODEL_URI); + namespaceService.registerNamespace(TransferModel.TRANSFER_MODEL_PREFIX, + TransferModel.TRANSFER_MODEL_1_0_URI); propertyFilter = new NodePropertyFilter(); propertyFilter.setNamespaceService(namespaceService); @@ -114,31 +120,37 @@ public static void setUp() public void nodePropertyFilter() { assertTrue("System properties are excluded by default.", - propertyFilter.isExcluded(ContentModel.PROP_NODE_UUID)); + propertyFilter.isExcluded(ContentModel.PROP_NODE_UUID)); assertTrue("System properties are excluded by default.", - propertyFilter.isExcluded(ContentModel.PROP_NODE_DBID)); + propertyFilter.isExcluded(ContentModel.PROP_NODE_DBID)); + + assertTrue(propertyFilter.isExcluded(ContentModel.PROP_PASSWORD)); + assertTrue(propertyFilter.isExcluded(ContentModel.PROP_SALT)); + assertTrue(propertyFilter.isExcluded(ContentModel.PROP_PASSWORD_HASH)); + assertTrue(propertyFilter.isExcluded(TransferModel.PROP_PASSWORD)); assertFalse("Property cascadeTx is not excluded", propertyFilter.isExcluded(ContentModel.PROP_CASCADE_TX)); assertFalse("Property cascadeCRC is not excluded", propertyFilter.isExcluded(ContentModel.PROP_CASCADE_CRC)); assertFalse(propertyFilter.isExcluded(ContentModel.PROP_TITLE)); + } @Test public void nodeTypeFilter() { assertTrue("Thumbnail node type should have been filtered.", - typeFilter.isExcluded(ContentModel.TYPE_THUMBNAIL)); + typeFilter.isExcluded(ContentModel.TYPE_THUMBNAIL)); assertTrue("System folder node types are excluded by default.", - typeFilter.isExcluded(ContentModel.TYPE_SYSTEM_FOLDER)); + typeFilter.isExcluded(ContentModel.TYPE_SYSTEM_FOLDER)); assertTrue("System node type should have been filtered (sys:*).", - typeFilter.isExcluded(QName.createQName("sys:testSomeSystemType", namespaceService))); + typeFilter.isExcluded(QName.createQName("sys:testSomeSystemType", namespaceService))); assertTrue("Forum node type should have been filtered (fm:*).", - typeFilter.isExcluded(ForumModel.TYPE_POST)); + typeFilter.isExcluded(ForumModel.TYPE_POST)); assertFalse(typeFilter.isExcluded(ContentModel.TYPE_FOLDER)); } @@ -147,7 +159,7 @@ public void nodeTypeFilter() public void nodeAspectFilter() { assertTrue("Working copy aspect should have been filtered.", - aspectFilter.isExcluded(ContentModel.ASPECT_WORKING_COPY)); + aspectFilter.isExcluded(ContentModel.ASPECT_WORKING_COPY)); assertFalse(aspectFilter.isExcluded(ContentModel.ASPECT_TITLED)); } @@ -160,41 +172,41 @@ public void childAssociationTypeFilter() assertFalse(childAssociationTypeFilter.isExcluded(ContentModel.ASSOC_CONTAINS)); } - + @Test public void userFilter_case_insensitive() { assertTrue("System user should have been filtered.", - caseInsensitive_userFilter.isExcluded("System")); + caseInsensitive_userFilter.isExcluded("System")); assertTrue("System user should have been filtered (case-insensitive).", - caseInsensitive_userFilter.isExcluded("SYSTEM")); + caseInsensitive_userFilter.isExcluded("SYSTEM")); assertTrue("'null' user should have been filtered.", - caseInsensitive_userFilter.isExcluded("null")); + caseInsensitive_userFilter.isExcluded("null")); assertTrue("john.doe user should have been filtered.", - caseInsensitive_userFilter.isExcluded("John.Doe")); + caseInsensitive_userFilter.isExcluded("John.Doe")); assertFalse("'jane.doe' user should not have been filtered.", - caseInsensitive_userFilter.isExcluded("jane.doe")); + caseInsensitive_userFilter.isExcluded("jane.doe")); } @Test public void userFilter_case_sensitive() { assertFalse("'system' user should not have been filtered.", - caseSensitive_userFilter.isExcluded("system")); + caseSensitive_userFilter.isExcluded("system")); assertTrue("'System' user should have been filtered.", - caseSensitive_userFilter.isExcluded("System")); + caseSensitive_userFilter.isExcluded("System")); assertFalse("'John.Doe' user should not have been filtered.", - caseSensitive_userFilter.isExcluded("John.Doe")); + caseSensitive_userFilter.isExcluded("John.Doe")); assertTrue("'john.doe' user should have been filtered.", - caseSensitive_userFilter.isExcluded("john.doe")); + caseSensitive_userFilter.isExcluded("john.doe")); assertFalse("'jane.doe' user should not have been filtered.", - caseSensitive_userFilter.isExcluded("jane.doe")); + caseSensitive_userFilter.isExcluded("jane.doe")); } /**