Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Nifi Add Custom Sensitive Field To Processor?

avatar
Expert Contributor

I'm trying to add in a password field to an execute script processor, how do I make this field "sensitive"?

13862-nifi-question1.png

1 ACCEPTED SOLUTION

avatar
Master Guru

With the ExecuteScript processor, you are likely just adding Dynamic Properties (also known as User-Defined Properties), which are not sensitive. To add your own sensitive properties to a scripted processor, you would need to use InvokeScriptedProcessor. There's an example from the NiFi mailing list (though not with sensitive properties, you'd just need to add .sensitive(true) to your PropertyDescriptor.Builder, and I have another example (with no added properties) on my blog.

View solution in original post

7 REPLIES 7

avatar
Master Guru

With the ExecuteScript processor, you are likely just adding Dynamic Properties (also known as User-Defined Properties), which are not sensitive. To add your own sensitive properties to a scripted processor, you would need to use InvokeScriptedProcessor. There's an example from the NiFi mailing list (though not with sensitive properties, you'd just need to add .sensitive(true) to your PropertyDescriptor.Builder, and I have another example (with no added properties) on my blog.

avatar
Expert Contributor

Hi thanks for the response, I'm Trying to use this inside the custom processor script, but it is not showing up as a required parameter in InvokeScriptedProcessor. I currently have this in "script body", along with the rest of the class.

	def password = new PropertyDescriptor.Builder()
                                .name('Password')
                                .description("Password used to connect")
                                .required(true)				
				.sensitive(true)
                                .build()

avatar
Master Guru

Check the getPropertyDescriptor() and getPropertyDescriptors() methods from the example in the mailing list (link above). You have to look up the descriptor by name in the former, and return a List of the PropertyDescriptors in the latter.

avatar
Expert Contributor

Hi,

Your example is showing an error: "Unable to resolve class ProcessorLog"

I did a direct import of your template.

avatar
Master Guru

That example was written against NiFi 0.x. In NiFi 1.x you can use ComponentLog rather than ProcessorLog.

avatar
Expert Contributor

@Matt Burgess Is there anyway of not using the password in your examples if I had already setup password-less SSH. The groovy script is throwing an error if I try to not use the password.

avatar
Master Guru

You can set .required(false) on your password property. Later on when the script would try to use the value (if it is set), you can call context.getProperty(password).isSet() to see if anything has been entered.