Repository navigation
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
…rameters on evaluation Co-authored-by: Cursor <cursoragent@cursor.com>
|
Reviewing... |
mcgilman
left a comment
There was a problem hiding this comment.
Thanks for picking this up. Resolving parameters in the search context is the right layer, and keeping getValue() raw while resolving only on evaluation looks correct. The sensitivity filter is also necessary: without it, a bare #{sensitiveParam} on a non-sensitive property would resolve to the sensitive value.
Two small requests below: one for the class Javadoc, one for the tests.
| /** | ||
| * Resolves only Parameters whose sensitivity matches the sensitivity of the Property, consistent with Parameter resolution at runtime | ||
| */ |
There was a problem hiding this comment.
This isn't quite consistent with runtime. At runtime, AbstractComponentNode.isResolveParameter keeps the entire raw value when any referenced parameter's sensitivity differs from the property's. This lookup filters each reference on its own, and expression language evaluates a filtered parameter to an empty value. For example, #{scripts.dir}/#{secret} on a non-sensitive property evaluates to /opt/scripts/ here, but runtime keeps the raw string. That configuration is already invalid, and the sensitive value is never substituted, so I don't think the behavior needs to change. The comment should describe what it does, though. Maybe something like:
| /** | |
| * Resolves only Parameters whose sensitivity matches the sensitivity of the Property, consistent with Parameter resolution at runtime | |
| */ | |
| /** | |
| * Resolves only Parameters whose sensitivity matches the sensitivity of the Property. A reference to a Parameter with | |
| * mismatched sensitivity evaluates to an empty value, so a sensitive Parameter value is never substituted into a non-sensitive Property. | |
| */ |
| @Test | ||
| void getPropertyEvaluatedExcludesSensitiveParameterForNonSensitiveProperty() { | ||
| when(processorNode.getRawPropertyValue(SCRIPT_FILE)).thenReturn("#{secret}"); | ||
|
|
||
| final String evaluated = context.getProperty(SCRIPT_FILE).evaluateAttributeExpressions().getValue(); | ||
|
|
||
| assertFalse(evaluated != null && evaluated.contains(SECRET_VALUE)); | ||
| } | ||
|
|
||
| @Test | ||
| void getPropertyEvaluatedExcludesNonSensitiveParameterForSensitiveProperty() { | ||
| when(processorNode.getRawPropertyValue(PASSWORD)).thenReturn("#{scripts.dir}"); | ||
|
|
||
| final String evaluated = context.getProperty(PASSWORD).evaluateAttributeExpressions().getValue(); | ||
|
|
||
| assertFalse(evaluated != null && evaluated.contains("/opt/scripts")); | ||
| } |
There was a problem hiding this comment.
assertFalse(evaluated != null && evaluated.contains(...)) passes for null, an empty string, the raw reference, or a truncated path, so it doesn't pin down the actual behavior. Could these assert the exact strings? For Script File:
#{secret}evaluates to""#{scripts.dir}/#{secret}evaluates to/opt/scripts/
Could you also add a case where processorNode.getParameterLookup() returns null? That's the common case of a processor whose group has no Parameter Context. #{scripts.dir}/file.groovy should evaluate to /file.groovy without throwing. The null guard in SensitivityMatchingParameterLookup handles this, but nothing currently tests it.
Summary
StandardSearchContext.getProperty()usedParameterLookup.EMPTY, so a Searchable processor callingevaluateAttributeExpressions()on a parameterized property lost the Parameter. ExecuteScript turned#{scripts.dir}/file.groovyinto/file.groovyand loggedFileNotFoundExceptionduring canvas search.getValue()still returns the raw configured value, keeping the raw-form search behavior from NIFI-141. Script Body and other raw text in search results never include Parameter values.evaluateAttributeExpressions(), and only when the Parameter sensitivity matches the Property sensitivity, consistent with runtime resolution inAbstractComponentNode.isResolveParameter. A sensitive Parameter is never resolved into a non-sensitive Property.Test plan
TestStandardSearchContext: resolves a matching Parameter on evaluation, keepsgetValue()raw, and excludes mismatched sensitivity in both directions. The resolution test fails onmainwithexpected </opt/scripts/file.groovy> but was </file.groovy>.SearchableMatcherTest,PropertyMatcherTestcheckstyle:check pmd:checkonnifi-web-apiJIRA: https://issues.apache.org/jira/browse/NIFI-16616
Made with Cursor