Compare commits

...

9 Commits

Author SHA1 Message Date
apoltavtsev
b9fc01bbcb Typo is corrected 2020-06-08 22:15:43 +02:00
apoltavtsev
00efd48ca5 TESB-28826 Secure Context Parameters are cleaned according to TESB-27727 2020-06-07 14:52:59 +02:00
apoltavtsev
fadc2489c1 fix(TESB-28826): cleaning password context parameters 2020-04-20 07:12:46 +02:00
apoltavtsev
ac08d743c9 Code generation for context parameter with password type is updated 2020-04-15 23:51:32 +02:00
apoltavtsev
cf43ee3e57 Extra password type object is removed 2020-04-15 23:42:30 +02:00
apoltavtsev
a869a40ea6 Code generation for context parameters with password is updated 2020-04-15 23:40:45 +02:00
apoltavtsev
bb7c804a6b Extra password object is removed 2020-04-15 23:37:49 +02:00
apoltavtsev
53bd78df24 Minor style corrections 2020-04-15 21:58:33 +02:00
apoltavtsev
0075499118 fix(TESB-28826): Set type "Password" for password context parameters 2020-04-15 21:54:06 +02:00
4 changed files with 50 additions and 0 deletions

View File

@@ -59,6 +59,9 @@ public class ContextUtils {
"instanceof", "return", "transient", "catch", "extends", "int", "short", "try", "char", "final", "interface", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
"static", "void", "class", "finally", "long", "strictfp", "volatile", "const", "float", "native", "super", "while")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
private static final Set<String> SECURE_SENSITIVE_CONTEXT_NAMES_EXP = new HashSet<String>(Arrays.asList("resource_webhook_payload", "resource_file_[\\w]+",
"resource_directory_[\\w]+", "connection_[a-zA-Z0-9]+_[\\w]"));
/**
*
* ggu Comment method "isJavaKeyWords".
@@ -77,6 +80,23 @@ public class ContextUtils {
return false;
}
/**
*
* ggu Comment method "isJavaKeyWords".
*
*/
public static boolean isSecureSensitiveParam (final String name) {
for (String regexp : SECURE_SENSITIVE_CONTEXT_NAMES_EXP) {
if (name.matches(regexp)) {
return true;
}
}
return false;
}
/**
*
* update the JobContextParameter form repository ContextItem by context name.

View File

@@ -240,6 +240,11 @@ public class ContextParameterJavaTypeManager {
if (javaType == null) {
return null;
}
if(javaType.equals(JavaTypesManager.PASSWORD)) {
return "Password";
}
Class primitiveClass = javaType.getPrimitiveClass();
Class nullableClass = javaType.getNullableClass();
if (nullable) {

View File

@@ -64,6 +64,8 @@ public interface TalendProcessArgumentConstant {
static final String ARG_AVOID_BRANCH_NAME = "AVOID_BRANCH_NAME";
static final String ARG_CLEAR_PASSWORD_CONTEXT_PARAMETERS = "CLEAR_PASSWORD_CONTEXT_PARAMETERS";
static final String CMD_ARG_STATS_PORT_PARAM = "stat_port";
static final String CMD_ARG_TRACE_PORT_PARAM = "trace_port";

View File

@@ -78,6 +78,7 @@ import org.talend.core.model.components.EComponentType;
import org.talend.core.model.components.IComponent;
import org.talend.core.model.components.IComponentsFactory;
import org.talend.core.model.components.IComponentsService;
import org.talend.core.model.context.ContextUtils;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.general.Project;
import org.talend.core.model.metadata.IMetadataColumn;
@@ -1005,6 +1006,7 @@ public class ProcessorUtilities {
if (context.getName().equals(currentContext.getName())) {
// override parameter value before generate current context
IContext checkedContext = checkNeedOverrideContextParameterValue(currentContext, jobInfo);
checkedContext = checkCleanSecureContextParameterValue(checkedContext, jobInfo);
processor.setContext(checkedContext); // generate current context.
} else {
processor.setContext(context);
@@ -1078,6 +1080,27 @@ public class ProcessorUtilities {
return context;
}
private static IContext checkCleanSecureContextParameterValue(IContext currentContext, JobInfo jobInfo) {
if (jobInfo.getArgumentsMap() == null
|| jobInfo.getArgumentsMap().get(TalendProcessArgumentConstant.ARG_CLEAR_PASSWORD_CONTEXT_PARAMETERS) == null
|| !Boolean.parseBoolean((ProcessUtils.getOptionValue(jobInfo.getArgumentsMap(), TalendProcessArgumentConstant.ARG_CLEAR_PASSWORD_CONTEXT_PARAMETERS,
(String) null)))) {
return currentContext;
}
IContext context = currentContext.clone();
List<IContextParameter> contextParameterList = context.getContextParameterList();
for (IContextParameter contextParameter : contextParameterList) {
if (PasswordEncryptUtil.isPasswordType(contextParameter.getType())
|| ContextUtils.isSecureSensitiveParam(contextParameter.getName())) {
contextParameter.setValue("");
}
}
return context;
}
private static void generateDataSet(IProcess process, IProcessor processor) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService =