Compare commits

...

1 Commits

Author SHA1 Message Date
Dmytro Chmyga
64b033c51b patch(TPS-3315): password context values
* Throw runtime exception if password is used in plain text field

* Add release note
2019-08-05 15:34:50 +03:00
3 changed files with 154 additions and 0 deletions

68
PATCH_RELEASE_NOTE.md Normal file
View File

@@ -0,0 +1,68 @@
---
version: 7.2.1
module: https://talend.poolparty.biz/coretaxonomy/42
product:
- https://talend.poolparty.biz/coretaxonomy/23
---
# TPS-3162
| Info | Value |
| ---------------- | ---------------- |
| Patch Name | Patch\_20190805_TPS-3315\_v1-7.2.1 |
| Release Date | 2019-06-28 |
| Target Version | Talend-Studio-20190620\_1446-V7.2.1 |
| Product affected | Talend Studio |
## Introduction
This is a self-contained patch.
**NOTE**: For information on how to obtain this patch, reach out to your Support contact at Talend.
## Fixed issues
This patch contains the following fixes:
- TPS-3315 [7.2.1] Additional JDBC Parameter exposes the password when using a context variable of password type (TDI-42721)
## Prerequisites
Consider the following requirements for your system:
- Talend Studio 7.2.1 must be installed.
## Installation
### Installing the patch using Software update
1) Logon TAC and switch to Configuration->Software Update, then enter the correct values and save referring to the documentation: https://help.talend.com/reader/f7Em9WV_cPm2RRywucSN0Q/j9x5iXV~vyxMlUafnDejaQ
2) Switch to Software update page, where the new patch will be listed. The patch can be downloaded from here into the nexus repository.
3) On Studio Side: Logon Studio with remote mode, on the logon page the Update button is displayed: click this button to install the patch.
### Installing the patch using Talend Studio
1) Create a folder named "patches" under your studio installer directory and copy the patch .zip file to this folder.
2) Restart your studio: a window pops up, then click OK to install the patch, or restart the commandline and the patch will be installed automatically.
### Installing the patch using Commandline
Execute the following commands:
1. Talend-Studio-win-x86_64.exe -nosplash -application org.talend.commandline.CommandLine -consoleLog -data commandline-workspace startServer -p 8002 --talendDebug
2. initRemote {tac_url} -ul {TAC login username} -up {TAC login password}
3. checkAndUpdate -tu {TAC login username} -tup {TAC login password}
## Uninstallation
Backup the Affected files list below. Uninstall the patch by restore the backup files.
## Affected files for this patch
The following files are installed by this patch:
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/templates/Log4j/DBLogUtil.javajet
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/templates/Log4j/Log4jDBConnUtil.javajet

View File

@@ -3,6 +3,49 @@
<%@ include file="LogUtil.javajet"%>
<%
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
class DBConnLogUtil extends BasicLogUtil{
private DBConnLogUtil(){}

View File

@@ -7,6 +7,49 @@ imports="
%>
<%@ include file="Log4jFileUtil.javajet"%>
<%
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
class DefaultLog4jCodeGenerateUtil extends DefaultLog4jFileUtil{
String connection = "";