Skip to content

Commit

Permalink
Merge pull request apache#4330 from bamaer/4326
Browse files Browse the repository at this point in the history
prevent self-references for child workflows and pipelines apache#2578 apache#4326
  • Loading branch information
hansva authored Sep 24, 2024
2 parents 95d443d + 03c4c0d commit 71e74a8
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ public IAction open() {
fdLogFileUpdateInterval.right = new FormAttachment(100, 0);
fdLogFileUpdateInterval.top = new FormAttachment(wlLogFileUpdateInterval, 0, SWT.CENTER);
wLogFileUpdateInterval.setLayoutData(fdLogFileUpdateInterval);
lastLogControl = wLogFileUpdateInterval;

FormData fdLogFileGroup = new FormData();
fdLogFileGroup.left = new FormAttachment(0, 0);
Expand Down Expand Up @@ -463,7 +462,6 @@ public IAction open() {
fdParameters.top = new FormAttachment(lastControl, margin);
fdParameters.bottom = new FormAttachment(wOK, -margin * 2);
wParameters.setLayoutData(fdParameters);
lastControl = wParameters;

getData();

Expand Down Expand Up @@ -601,6 +599,21 @@ private void ok() {
return;
}
action.setName(wName.getText());

if (Utils.isEmpty(wFilename.getText())) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "Repeat.Dialog.FilenameMissing.Header"));
mb.setMessage(BaseMessages.getString(PKG, "Repeat.Dialog.FilenameMissing.Message"));
mb.open();
return;
}
if (isSelfReferencing()) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "Repeat.Dialog.SelfReference.Header"));
mb.setMessage(BaseMessages.getString(PKG, "Repeat.Dialog.SelfReference.Message"));
mb.open();
return;
}
action.setFilename(wFilename.getText());
action.setVariableName(wVariableName.getText());
action.setVariableValue(wVariableValue.getText());
Expand Down Expand Up @@ -641,4 +654,10 @@ private void ok() {

dispose();
}

private boolean isSelfReferencing() {
return variables
.resolve(wFilename.getText())
.equals(variables.resolve(workflowMeta.getFilename()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Repeat.Delay.Label=Delay in seconds
Repeat.Description=Repeat execution of a workflow or a pipeline
Repeat.Dialog.ActionMissing.Header=Warning
Repeat.Dialog.ActionMissing.Message=The name of the Action is missing!
Repeat.Dialog.FilenameMissing.Header=Warning
Repeat.Dialog.FilenameMissing.Message=The workflow or pipeline to repeat is missing.
Repeat.Dialog.SelfReference.Header=Warning
Repeat.Dialog.SelfReference.Message=This workflow can''t repeat itself. Please select another workflow to repeat.
Repeat.FileToRepeat.Label=File to repeat (.hpl or .hwf)
Repeat.KeepVariableValues.Label=Keep variable values after executions
Repeat.keywords=repeat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ protected void cancel() {
@VisibleForTesting
protected void getInfo(ActionWorkflow action) {
action.setName(wName.getText());

action.setFileName(wPath.getText());
action.setRunConfiguration(wRunConfiguration.getText());

Expand Down Expand Up @@ -347,6 +348,21 @@ public void ok() {
mb.open();
return;
}
if (Utils.isEmpty(wPath.getText())) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "ActionWorkflowDialog.FilenameMissing.Header"));
mb.setMessage(BaseMessages.getString(PKG, "ActionWorkflowDialog.FilenameMissing.Message"));
mb.open();
return;
}
if (isSelfReferencing()) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "ActionWorkflowDialog.SelfReference.Header"));
mb.setMessage(BaseMessages.getString(PKG, "ActionWorkflowDialog.SelfReference.Message"));
mb.open();
return;
}

getInfo(action);
action.setChanged();
dispose();
Expand All @@ -361,4 +377,8 @@ protected String getName() {
protected String getPath() {
return wPath.getText();
}

private boolean isSelfReferencing() {
return variables.resolve(wPath.getText()).equals(variables.resolve(workflowMeta.getFilename()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ ActionWorkflow.WorkflowFile.Label=Workflow\:
ActionWorkflowDialog.Exception.UnableToLoadWorkflow.Message=It was not possible to load the specified workflow
ActionWorkflowDialog.Exception.UnableToLoadWorkflow.Title=Error loading workflow
ActionWorkflowError.Recursive=Endless loop detected\: A Action in this workflow called is calling itself. The filename is [{0}]
ActionWorkflowDialog.FilenameMissing.Header=Warning
ActionWorkflowDialog.FilenameMissing.Message=The workflow filename is missing
ActionWorkflowDialog.SelfReference.Header=Warning
ActionWorkflowDialog.SelfReference.Message=This workflow can''t run itself. Please select another workflow to run.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ public void callExtensionPoint(
if (projectConfig == null) {
return;
}
String homeFolder = variables.resolve(projectConfig.getProjectHome());
String homeFolder;

if (variables != null) {
homeFolder = variables.resolve(projectConfig.getProjectHome());
} else {
homeFolder = projectConfig.getProjectHome();
}

try {
if (StringUtils.isNotEmpty(homeFolder)) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.gui.Point;
import org.apache.hop.core.row.value.ValueMetaFactory;
import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.pipeline.PipelineMeta;
Expand All @@ -43,6 +44,7 @@
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.dialog.BaseDialog;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.gui.WindowProperty;
import org.apache.hop.ui.core.widget.ColumnInfo;
Expand Down Expand Up @@ -268,6 +270,22 @@ public void widgetSelected(SelectionEvent e) {

private void ok() {
transformName = wTransformName.getText();
if (Utils.isEmpty(wFilename.getText())) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "KafkaConsumerInputDialog.FilenameMissing.Header"));
mb.setMessage(
BaseMessages.getString(PKG, "KafkaConsumerInputDialog.FilenameMissing.Message"));
mb.open();
return;
}
if (isSelfReferencing()) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "KafkaConsumerInputDialog.SelfReference.Header"));
mb.setMessage(BaseMessages.getString(PKG, "KafkaConsumerInputDialog.SelfReference.Message"));
mb.open();
return;
}

updateMeta(meta);
dispose();
}
Expand Down Expand Up @@ -948,4 +966,10 @@ protected void populateSubTransforms(Event event) {
log.logError("Error getting transform names from Kafka pipeline", e);
}
}

private boolean isSelfReferencing() {
return variables
.resolve(wFilename.getText())
.equals(variables.resolve(pipelineMeta.getFilename()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ KafkaConsumerInputMeta.Injection.TRANSFORMATION_PATH=The path to the sub-pipelin
KafkaConsumerInputMeta.Injection.VALUES=The value(s) of the Kafka consumer configuration properties.
KafkaConsumerInputMeta.keyword=kafka,consumer,input
KafkaConsumerInputMeta.UnableToCreateValueType=Unable to create output field value for {0}
KafkaConsumerInputDialog.FilenameMissing.Header=Warning
KafkaConsumerInputDialog.FilenameMissing.Message=The Kafka pipeline filename is missing.
KafkaConsumerInputDialog.SelfReference.Header=Warning
KafkaConsumerInputDialog.SelfReference.Message=This pipeline can''t be used as the Kafka pipeline. Please choose another Kafka pipeline.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.hop.ui.core.dialog.BaseDialog;
import org.apache.hop.ui.core.dialog.EnterMappingDialog;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.widget.ColumnInfo;
import org.apache.hop.ui.core.widget.ColumnsResizer;
Expand Down Expand Up @@ -778,6 +779,21 @@ private void ok() {
return;
}

if (Utils.isEmpty(wPath.getText())) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.FilenameMissing.Header"));
mb.setMessage(BaseMessages.getString(PKG, "SimpleMappingDialog.FilenameMissing.Message"));
mb.open();
return;
}
if (isSelfReferencing()) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.SelfReference.Header"));
mb.setMessage(BaseMessages.getString(PKG, "SimpleMappingDialog.SelfReference.Message"));
mb.open();
return;
}

transformName = wTransformName.getText(); // return value
String pipelinePath = wPath.getText();
mappingMeta.setFilename(pipelinePath);
Expand Down Expand Up @@ -819,4 +835,8 @@ private void collectInformation() {
// tabs...
}
}

private boolean isSelfReferencing() {
return variables.resolve(wPath.getText()).equals(variables.resolve(pipelineMeta.getFilename()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,7 @@ SimpleMappingMeta.Exception.UnableToLoadPipelineNameOrDirNotGiven=Unable to load
SimpleMappingMeta.InfoStream.Description=These rows are used as parameters.
SimpleMappingMeta.keyword=simple,mapping
SimpleMappingMeta.ReferencedObject.Description=Mapping (sub-pipeline)
SimpleMappingDialog.FilenameMissing.Header=Warning
SimpleMappingDialog.FilenameMissing.Message=The mapping pipeline filename is empty.
SimpleMappingDialog.SelfReference.Header=Warning
SimpleMappingDialog.SelfReference.Message=This pipeline can''t map to itself. Please choose another pipeline.
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,20 @@ private void ok() {
PKG, CONST_META_INJECT_DIALOG_ERROR_LOADING_SPECIFIED_PIPELINE_MESSAGE),
e);
}
if (Utils.isEmpty(wPath.getText())) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "MetaInjectDialog.FilenameMissing.Header"));
mb.setMessage(BaseMessages.getString(PKG, "MetaInjectDialog.FilenameMissing.Message"));
mb.open();
return;
}
if (isSelfReferencing()) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "MetaInjectDialog.SelfReference.Header"));
mb.setMessage(BaseMessages.getString(PKG, "MetaInjectDialog.SelfReference.Message"));
mb.open();
return;
}

getInfo(metaInjectMeta);
dispose();
Expand Down Expand Up @@ -1327,4 +1341,8 @@ private void enterMapping() {
}
}
}

private boolean isSelfReferencing() {
return variables.resolve(wPath.getText()).equals(variables.resolve(pipelineMeta.getFilename()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,7 @@ MetaInjectMeta.Exception.UnableToLoadTrans=It was not possible to load the speci
MetaInjectMeta.keyword=meta,inject,mdi
MetaInjectMeta.ReferencedObject.Description=Pipeline template
MetaInjectMeta.ReferencedObjectAfterInjection.Description=Pipeline template after injection
MetaInjectDialog.FilenameMissing.Header=Warning
MetaInjectDialog.FilenameMissing.Message=The template pipeline filename is missing
MetaInjectDialog.SelfReference.Header=Warning
MetaInjectDialog.SelfReference.Message=This pipeline can''t inject into itself. Please select another template pipeline.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.hop.ui.core.dialog.BaseDialog;
import org.apache.hop.ui.core.dialog.EnterMappingDialog;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.widget.ColumnInfo;
import org.apache.hop.ui.core.widget.ColumnsResizer;
Expand Down Expand Up @@ -387,8 +388,6 @@ protected Image getImage() {
}

private void selectPipelineFile() {
String curFile = variables.resolve(wPath.getText());

String parentFolder = null;
try {
parentFolder =
Expand Down Expand Up @@ -959,7 +958,7 @@ private void addExecutionResultTab() {
tiExecutionFilesRetrievedField = wExectionResults.table.getItem(index++);
tiExecutionExitStatusField = wExectionResults.table.getItem(index++);
tiExecutionLogTextField = wExectionResults.table.getItem(index++);
tiExecutionLogChannelIdField = wExectionResults.table.getItem(index++);
tiExecutionLogChannelIdField = wExectionResults.table.getItem(index);

tiExecutionTimeField.setText(
FIELD_DESCRIPTION,
Expand Down Expand Up @@ -1231,6 +1230,21 @@ private void ok() {

transformName = wTransformName.getText(); // return value

if (Utils.isEmpty(wPath.getText())) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "PipelineExecutorDialog.FilenameMissing.Header"));
mb.setMessage(BaseMessages.getString(PKG, "PipelineExecutorDialog.FilenameMissing.Message"));
mb.open();
return;
}
if (isSelfReferencing()) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "PipelineExecutorDialog.SelfReference.Header"));
mb.setMessage(BaseMessages.getString(PKG, "PipelineExecutorDialog.SelfReference.Message"));
mb.open();
return;
}

try {
loadPipeline();
} catch (HopException e) {
Expand Down Expand Up @@ -1344,4 +1358,8 @@ private void collectInformation() {
pipelineExecutorMeta.getOutputRowsPrecision()[i] = Const.toInt(item.getText(4), -1);
}
}

private boolean isSelfReferencing() {
return variables.resolve(wPath.getText()).equals(variables.resolve(pipelineMeta.getFilename()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ PipelineExecutorMeta.ResultFilesStream.Description=This output will contain the
PipelineExecutorMeta.ResultRowsStream.Description=This output will contain the result rows after execution
PipelineExecutorMeta.ResultStream.Description=This output will contain the execution results
PipelineExecutorMeta.ValueMetaInterfaceCreation=Could not create ValueMetaInterface: {0}
PipelineExecutorDialog.FilenameMissing.Header=Warning
PipelineExecutorDialog.FilenameMissing.Message=The pipeline filename to execute is empty.
PipelineExecutorDialog.SelfReference.Header=Warning
PipelineExecutorDialog.SelfReference.Message=This pipeline can''t execute itself. Please choose another pipeline.

0 comments on commit 71e74a8

Please sign in to comment.