exceptionfactory commented on code in PR #9813: URL: https://github.com/apache/nifi/pull/9813#discussion_r2010257912
########## nifi-extension-bundles/nifi-standard-bundle/nifi-standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireSecureConnection.java: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.flowanalysis.rules; + +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.documentation.UseCase; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ControllerService; +import org.apache.nifi.flow.VersionedComponent; +import org.apache.nifi.flow.VersionedExtensionComponent; +import org.apache.nifi.flowanalysis.AbstractFlowAnalysisRule; +import org.apache.nifi.flowanalysis.ComponentAnalysisResult; +import org.apache.nifi.flowanalysis.FlowAnalysisRuleContext; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextProvider; +import org.apache.nifi.util.StringUtils; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + + +@Tags({"component", "processor", "controller service", "type"}) +@CapabilityDescription("Produces rule violations for each component (i.e. processors or controller services) having a property " + + "identifying an SSLContextService that is not set.") +@UseCase( + description = "Ensure that no ports can be opened for insecure (plaintext, e.g.) communications.", Review Comment: Related to the name, this is not completely accurate for all cases. ########## nifi-extension-bundles/nifi-standard-bundle/nifi-standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireSecureConnection.java: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.flowanalysis.rules; + +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.documentation.UseCase; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ControllerService; +import org.apache.nifi.flow.VersionedComponent; +import org.apache.nifi.flow.VersionedExtensionComponent; +import org.apache.nifi.flowanalysis.AbstractFlowAnalysisRule; +import org.apache.nifi.flowanalysis.ComponentAnalysisResult; +import org.apache.nifi.flowanalysis.FlowAnalysisRuleContext; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextProvider; +import org.apache.nifi.util.StringUtils; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + + +@Tags({"component", "processor", "controller service", "type"}) +@CapabilityDescription("Produces rule violations for each component (i.e. processors or controller services) having a property " + + "identifying an SSLContextService that is not set.") +@UseCase( + description = "Ensure that no ports can be opened for insecure (plaintext, e.g.) communications.", + configuration = """ + To avoid the violation, ensure that the "SSL Context Service" property is set for the specified component(s). + """ +) +public class RequireSecureConnection extends AbstractFlowAnalysisRule { Review Comment: The name is somewhat misleading because certain components, such as `InvokeHTTP`, have a secure connection without configuring an SSL Context Service. Although more verbose, something like `RequireCustomSSLContext` would be more precise. ########## nifi-extension-bundles/nifi-standard-bundle/nifi-standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireSecureConnection.java: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.flowanalysis.rules; + +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.documentation.UseCase; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ControllerService; +import org.apache.nifi.flow.VersionedComponent; +import org.apache.nifi.flow.VersionedExtensionComponent; +import org.apache.nifi.flowanalysis.AbstractFlowAnalysisRule; +import org.apache.nifi.flowanalysis.ComponentAnalysisResult; +import org.apache.nifi.flowanalysis.FlowAnalysisRuleContext; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextProvider; +import org.apache.nifi.util.StringUtils; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + + +@Tags({"component", "processor", "controller service", "type"}) +@CapabilityDescription("Produces rule violations for each component (i.e. processors or controller services) having a property " + + "identifying an SSLContextService that is not set.") +@UseCase( + description = "Ensure that no ports can be opened for insecure (plaintext, e.g.) communications.", + configuration = """ + To avoid the violation, ensure that the "SSL Context Service" property is set for the specified component(s). + """ +) +public class RequireSecureConnection extends AbstractFlowAnalysisRule { + public static final PropertyDescriptor COMPONENT_TYPE = new PropertyDescriptor.Builder() + .name("component-type") + .displayName("Component Type(s)") + .description("A comma-separated list of component types. Components of the given type that have a property identifying an SSL Context Service will produce a rule violation " + + "if the service is not set. If no components are specified (i.e. this property is blank), the rule will apply to all components.") Review Comment: It would be helpful to indicate a few examples, such as `Processor`, and `ControllerService`, although this could be error-prone and may be better as a limited set of allowable values. ########## nifi-extension-bundles/nifi-standard-bundle/nifi-standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireSecureConnection.java: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.flowanalysis.rules; + +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.documentation.UseCase; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ControllerService; +import org.apache.nifi.flow.VersionedComponent; +import org.apache.nifi.flow.VersionedExtensionComponent; +import org.apache.nifi.flowanalysis.AbstractFlowAnalysisRule; +import org.apache.nifi.flowanalysis.ComponentAnalysisResult; +import org.apache.nifi.flowanalysis.FlowAnalysisRuleContext; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextProvider; +import org.apache.nifi.util.StringUtils; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + + +@Tags({"component", "processor", "controller service", "type"}) +@CapabilityDescription("Produces rule violations for each component (i.e. processors or controller services) having a property " + + "identifying an SSLContextService that is not set.") +@UseCase( + description = "Ensure that no ports can be opened for insecure (plaintext, e.g.) communications.", + configuration = """ + To avoid the violation, ensure that the "SSL Context Service" property is set for the specified component(s). + """ +) +public class RequireSecureConnection extends AbstractFlowAnalysisRule { + public static final PropertyDescriptor COMPONENT_TYPE = new PropertyDescriptor.Builder() + .name("component-type") + .displayName("Component Type(s)") Review Comment: The `name()` should be used without the `displayName`, and the parentheses are not necessary. ```suggestion .name("Component Types") ``` ########## nifi-extension-bundles/nifi-standard-bundle/nifi-standard-rules/pom.xml: ########## @@ -23,7 +23,13 @@ <artifactId>nifi-standard-rules</artifactId> <packaging>jar</packaging> - <dependencies /> + <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-ssl-context-service-api</artifactId> + <scope>compile</scope> Review Comment: Should the scope be set to `provided`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
