Skip to content

Commit

Permalink
NIFI-11744 Added Required Permission to Reference Remote Resources
Browse files Browse the repository at this point in the history
- Applied Required Permission to components supporting URL Resource References

Signed-off-by: Matt Burgess <[email protected]>
  • Loading branch information
exceptionfactory authored and mattyb149 committed Jun 23, 2023
1 parent 2052f15 commit 5325787
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public enum RequiredPermission {
ACCESS_KEYTAB("access-keytab", "access keytab"),
ACCESS_TICKET_CACHE("access-ticket-cache", "access ticket cache"),
ACCESS_ENVIRONMENT_CREDENTIALS("access-environment-credentials", "access environment credentials"),
EXPORT_NIFI_DETAILS("export-nifi-details", "export nifi details");
EXPORT_NIFI_DETAILS("export-nifi-details", "export nifi details"),
REFERENCE_REMOTE_RESOURCES("reference-remote-resources", "reference remote resources");

private String permissionIdentifier;
private String permissionLabel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.apache.nifi.annotation.behavior.InputRequirement;
import org.apache.nifi.annotation.behavior.PrimaryNodeOnly;
import org.apache.nifi.annotation.behavior.RequiresInstanceClassLoading;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.behavior.Stateful;
import org.apache.nifi.annotation.behavior.TriggerSerially;
import org.apache.nifi.annotation.behavior.WritesAttribute;
Expand Down Expand Up @@ -65,6 +67,7 @@
import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.PropertyValue;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.components.resource.ResourceCardinality;
Expand Down Expand Up @@ -151,6 +154,14 @@
+ "application/json")
})
@RequiresInstanceClassLoading
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Database Driver Location can reference resources over HTTP"
)
}
)
public class CaptureChangeMySQL extends AbstractSessionFactoryProcessor {

// Random invalid constant used as an indicator to not set the binlog position on the client (thereby using the latest available)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
package org.apache.nifi.jms.cf;

import org.apache.nifi.annotation.behavior.DynamicProperty;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.SeeAlso;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.annotation.lifecycle.OnDisabled;
import org.apache.nifi.annotation.lifecycle.OnEnabled;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.expression.ExpressionLanguageScope;
Expand Down Expand Up @@ -61,6 +64,14 @@
+ "property and 'com.ibm.mq.jms.MQConnectionFactory.setTransportType(int)' would imply 'transportType' property.",
expressionLanguageScope = ExpressionLanguageScope.VARIABLE_REGISTRY)
@SeeAlso(classNames = {"org.apache.nifi.jms.processors.ConsumeJMS", "org.apache.nifi.jms.processors.PublishJMS"})
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Client Library Location can reference resources over HTTP"
)
}
)
public class JMSConnectionFactoryProvider extends AbstractControllerService implements JMSConnectionFactoryProviderDefinition, VerifiableControllerService {
private static final String ESTABLISH_CONNECTION = "Establish Connection";
private static final String VERIFY_JMS_INTERACTION = "Verify JMS Interaction";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.apache.nifi.annotation.behavior.DynamicProperty;
import org.apache.nifi.annotation.behavior.InputRequirement;
import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.behavior.WritesAttribute;
import org.apache.nifi.annotation.behavior.WritesAttributes;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
Expand All @@ -27,6 +29,7 @@
import org.apache.nifi.annotation.lifecycle.OnScheduled;
import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.expression.ExpressionLanguageScope;
Expand Down Expand Up @@ -94,6 +97,14 @@
"properties of the processor. For more information, see the Additional Details page.",
expressionLanguageScope = ExpressionLanguageScope.VARIABLE_REGISTRY)
@SeeAlso(value = { PublishJMS.class, JMSConnectionFactoryProvider.class })
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Client Library Location can reference resources over HTTP"
)
}
)
public class ConsumeJMS extends AbstractJMSProcessor<JMSConsumer> {

public static final String JMS_MESSAGETYPE = "jms.messagetype";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
import org.apache.nifi.annotation.behavior.ReadsAttribute;
import org.apache.nifi.annotation.behavior.ReadsAttributes;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.behavior.SystemResource;
import org.apache.nifi.annotation.behavior.SystemResourceConsideration;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.SeeAlso;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.jms.cf.JMSConnectionFactoryProvider;
Expand Down Expand Up @@ -102,6 +105,14 @@
expressionLanguageScope = ExpressionLanguageScope.VARIABLE_REGISTRY)
@SeeAlso(value = { ConsumeJMS.class, JMSConnectionFactoryProvider.class })
@SystemResourceConsideration(resource = SystemResource.MEMORY)
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Client Library Location can reference resources over HTTP"
)
}
)
public class PublishJMS extends AbstractJMSProcessor<JMSPublisher> {

static final PropertyDescriptor MESSAGE_BODY = new PropertyDescriptor.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import io.krakens.grok.api.exception.GrokException;
import org.apache.nifi.annotation.behavior.EventDriven;
import org.apache.nifi.annotation.behavior.InputRequirement;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.behavior.SideEffectFree;
import org.apache.nifi.annotation.behavior.SupportsBatching;
import org.apache.nifi.annotation.behavior.WritesAttribute;
Expand All @@ -33,6 +35,7 @@
import org.apache.nifi.annotation.lifecycle.OnScheduled;
import org.apache.nifi.annotation.lifecycle.OnStopped;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.components.resource.ResourceCardinality;
Expand Down Expand Up @@ -77,6 +80,14 @@
@WritesAttribute(attribute = "grok.XXX", description = "When operating in flowfile-attribute mode, each of the Grok identifier that is matched in the flowfile " +
"will be added as an attribute, prefixed with \"grok.\" For example," +
"if the grok identifier \"timestamp\" is matched, then the value will be added to an attribute named \"grok.timestamp\"")})
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Patterns can reference resources over HTTP"
)
}
)
public class ExtractGrok extends AbstractProcessor {

public static final String FLOWFILE_ATTRIBUTE = "flowfile-attribute";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.networknt.schema.ValidationMessage;
import org.apache.nifi.annotation.behavior.InputRequirement;
import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.behavior.SideEffectFree;
import org.apache.nifi.annotation.behavior.SupportsBatching;
import org.apache.nifi.annotation.behavior.SystemResource;
Expand All @@ -36,6 +38,7 @@
import org.apache.nifi.annotation.lifecycle.OnScheduled;
import org.apache.nifi.components.DescribedValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.components.resource.ResourceCardinality;
import org.apache.nifi.components.resource.ResourceType;
import org.apache.nifi.flowfile.FlowFile;
Expand Down Expand Up @@ -64,6 +67,14 @@
})
@CapabilityDescription("Validates the contents of FlowFiles against a configurable JSON Schema. See json-schema.org for specification standards.")
@SystemResourceConsideration(resource = SystemResource.MEMORY, description = "Validating JSON requires reading FlowFile content into memory")
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Schema configuration can reference resources over HTTP"
)
}
)
public class ValidateJson extends AbstractProcessor {
public enum SchemaVersion implements DescribedValue {
DRAFT_4("Draft Version 4", "Draft 4", VersionFlag.V4),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.apache.nifi.annotation.behavior.EventDriven;
import org.apache.nifi.annotation.behavior.InputRequirement;
import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.behavior.SideEffectFree;
import org.apache.nifi.annotation.behavior.SupportsBatching;
import org.apache.nifi.annotation.behavior.SystemResource;
Expand All @@ -29,6 +31,7 @@
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.annotation.lifecycle.OnScheduled;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.components.resource.ResourceCardinality;
import org.apache.nifi.components.resource.ResourceType;
import org.apache.nifi.expression.ExpressionLanguageScope;
Expand Down Expand Up @@ -81,6 +84,14 @@
+ "to ensure the XML syntax is correct and well-formed, e.g. all opening tags are properly closed.")
@SystemResourceConsideration(resource = SystemResource.MEMORY, description = "While this processor supports processing XML within attributes, it is strongly discouraged to hold "
+ "large amounts of data in attributes. In general, attribute values should be as small as possible and hold no more than a couple hundred characters.")
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Schema configuration can reference resources over HTTP"
)
}
)
public class ValidateXml extends AbstractProcessor {

public static final String ERROR_ATTRIBUTE_KEY = "validatexml.invalid.error";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
import org.apache.nifi.annotation.behavior.DynamicProperties;
import org.apache.nifi.annotation.behavior.DynamicProperty;
import org.apache.nifi.annotation.behavior.RequiresInstanceClassLoading;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.behavior.SupportsSensitiveDynamicProperties;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.PropertyValue;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.controller.ConfigurationContext;
Expand Down Expand Up @@ -86,6 +89,14 @@
description = "JDBC driver property name prefixed with 'SENSITIVE.' handled as a sensitive property.")
})
@RequiresInstanceClassLoading
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Database Driver Location can reference resources over HTTP"
)
}
)
public class DBCPConnectionPool extends AbstractDBCPConnectionPool implements DBCPService, VerifiableControllerService {
/**
* Property Name Prefix for Sensitive Dynamic Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.annotation.behavior.DynamicProperty;
import org.apache.nifi.annotation.behavior.RequiresInstanceClassLoading;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.behavior.SupportsSensitiveDynamicProperties;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.annotation.lifecycle.OnDisabled;
import org.apache.nifi.annotation.lifecycle.OnEnabled;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.PropertyValue;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.components.resource.ResourceCardinality;
import org.apache.nifi.components.resource.ResourceType;
import org.apache.nifi.controller.AbstractControllerService;
Expand Down Expand Up @@ -60,6 +63,14 @@
description = "Specifies a property name and value to be set on the JDBC connection(s). "
+ "If Expression Language is used, evaluation will be performed upon the controller service being enabled. "
+ "Note that no flow file input (attributes, e.g.) is available for use in Expression Language constructs for these properties.")
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Database Driver Location can reference resources over HTTP"
)
}
)
public class HikariCPConnectionPool extends AbstractControllerService implements DBCPService {
/**
* Property Name Prefix for Sensitive Dynamic Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.nifi.annotation.behavior.DynamicProperty;
import org.apache.nifi.annotation.behavior.RequiresInstanceClassLoading;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.annotation.lifecycle.OnDisabled;
import org.apache.nifi.annotation.lifecycle.OnEnabled;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.PropertyValue;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.components.resource.ResourceCardinality;
Expand Down Expand Up @@ -76,6 +79,14 @@
@DynamicProperty(name = "The name of a Hadoop configuration property.", value = "The value of the given Hadoop configuration property.",
description = "These properties will be set on the Hadoop configuration after loading any provided configuration files.",
expressionLanguageScope = ExpressionLanguageScope.VARIABLE_REGISTRY)
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Database Driver Location can reference resources over HTTP"
)
}
)
public class HadoopDBCPConnectionPool extends AbstractControllerService implements DBCPService {

private static final String ALLOW_EXPLICIT_KEYTAB = "NIFI_ALLOW_EXPLICIT_KEYTAB";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.nifi.annotation.behavior.DynamicProperty;
import org.apache.nifi.annotation.behavior.RequiresInstanceClassLoading;
import org.apache.nifi.annotation.behavior.Restricted;
import org.apache.nifi.annotation.behavior.Restriction;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.annotation.lifecycle.OnDisabled;
import org.apache.nifi.annotation.lifecycle.OnEnabled;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.RequiredPermission;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.components.resource.ResourceCardinality;
Expand Down Expand Up @@ -93,6 +96,14 @@
"configuration.")
@DynamicProperty(name="The name of an HBase configuration property.", value="The value of the given HBase configuration property.",
description="These properties will be set on the HBase configuration after loading any provided configuration files.")
@Restricted(
restrictions = {
@Restriction(
requiredPermission = RequiredPermission.REFERENCE_REMOTE_RESOURCES,
explanation = "Client JAR Location can reference resources over HTTP"
)
}
)
public class HBase_2_ClientService extends AbstractControllerService implements HBaseClientService {
private static final String ALLOW_EXPLICIT_KEYTAB = "NIFI_ALLOW_EXPLICIT_KEYTAB";

Expand Down
Loading

0 comments on commit 5325787

Please sign in to comment.