-
Notifications
You must be signed in to change notification settings - Fork 2.9k
NIFI-14381: Add flow analysis rule to identify unset SSL Context Service controller services #9813
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
Conversation
exceptionfactory
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for proposing this new rule @mattyb149.
I noted a few questions and concerns related to the rule name, as RequireSecureConnection implies that SSL Context Service is required, which is not always the case.
The fact that some components do not require an SSL Context Service raises the question as to the validity of this rule for general purposes. As mentioned in the detailed comments, InvokeHTTP defaults to the system trust store, as do some other components. The fact that the nature of the default behavior can be different raises a question about the usefulness of this rule. For example, it would not work in a flow that requires a mixture of standard trusted certificates and custom trusted certificates for internal services. That could be addressed by always requiring a custom SSL Context Service configuration.
At minimum, changing the name and adjusting the description is important to convey the actual behavior. Thoughts?
...standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireSecureConnection.java
Outdated
Show resolved
Hide resolved
...standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireSecureConnection.java
Outdated
Show resolved
Hide resolved
...standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireSecureConnection.java
Outdated
Show resolved
Hide resolved
...standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireSecureConnection.java
Outdated
Show resolved
Hide resolved
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-rules/pom.xml
Outdated
Show resolved
Hide resolved
...standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireCustomSSLContext.java
Outdated
Show resolved
Hide resolved
pvillard31
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSON flow definitions in the tests contain vendor specific versions, can we have the same flows where vendor specific versions are replaced by Apache NiFi versions?
Also, just a suggestion: do we want to expose an optional property where an admin can provide additional processors to check? I'm thinking about custom extensions that are quite frequent. I remember numerous NiFi users with custom variations of ListenHTTP / HandleHTTPRequest processors.
|
@pvillard31 Yes I missed that, will replace with Apache NiFi versions. I'm in favor of the property to add components by the name of the type (that was in the original PR), what do you think about having the default value be the entire list and return to using the comma-separated list as a configurable property |
|
Regarding custom class names, I think the problem is that the Property Name has to be |
|
Yep, ok, my bad, I thought we had the information and we could do something like: if (component instanceof VersionedConfigurableComponent versionedConfigurableComponent) {
final Map<String, VersionedPropertyDescriptor> props = versionedConfigurableComponent.getPropertyDescriptors();
for (Entry<String, VersionedPropertyDescriptor> entry : props.entrySet()) {
if (entry.getValue().getIdentifiesControllerService()) {
// entry.getValue().getControllerServiceDefinition();
}
}
}and have the information about the controller service interface that this property expects but this it not something available. That could be an interesting improvement I guess. |
I can't get the class name for it (see Pierre's comments above), we'd need an API change to add a method to retrieve the identified controller service unless there's some other way to get it (but I couldn't find one). |
...standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireCustomSSLContext.java
Outdated
Show resolved
Hide resolved
...sources/docs/org.apache.nifi.flowanalysis.rules.RequireCustomSSLContext/additionalDetails.md
Outdated
Show resolved
Hide resolved
I was referring to the Processor class, such as |
Ah gotcha, will change |
exceptionfactory
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates @mattyb149. This looks close to completion. Now that the scope is clear, I have one more recommendation regarding the rule name, then I think this is ready to proceed.
...standard-rules/src/main/java/org/apache/nifi/flowanalysis/rules/RequireCustomSSLContext.java
Outdated
Show resolved
Hide resolved
exceptionfactory
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for renaming, on final review, I noticed that the logic to check the component type includes some unnecessary checking for the simple type, and for an empty collection, neither of which are necessary.
| ) | ||
| public class RequireServerSSLContextService extends AbstractFlowAnalysisRule { | ||
|
|
||
| private final List<String> componentTypes = List.of( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private final List<String> componentTypes = List.of( | |
| private static final List<String> componentTypes = List.of( |
| String encounteredSimpleComponentType = encounteredComponentType.substring(encounteredComponentType.lastIndexOf(".") + 1); | ||
|
|
||
| if (componentTypes.isEmpty() || componentTypes.contains(encounteredComponentType) || componentTypes.contains(encounteredSimpleComponentType)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic can be simplified since componentTypes is static:
| String encounteredSimpleComponentType = encounteredComponentType.substring(encounteredComponentType.lastIndexOf(".") + 1); | |
| if (componentTypes.isEmpty() || componentTypes.contains(encounteredComponentType) || componentTypes.contains(encounteredSimpleComponentType)) { | |
| if (componentTypes.contains(encounteredComponentType)) { |
…ice controller services
…uireServerSSLContextService
exceptionfactory
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @mattyb149, the latest version looks good!
Any remaining comments @pvillard31?
…ice controller services Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes apache#9813.
Summary
NIFI-14381 This PR introduces a Flow Analysis Rule that will examine specified (or all if the Component Type is left blank) components and if they have an SSL Context Service property that is unset will issue a violation.
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation