Commit 0bf8b3bb authored by Francois Merlin's avatar Francois Merlin
Browse files

RELEASER-10 :-anonymise scm password in release log

parent e89c2459
......@@ -9,6 +9,8 @@ import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.JAXBException;
......@@ -34,6 +36,7 @@ import fr.paris.lutece.plugins.releaser.util.MapperJsonUtil;
import fr.paris.lutece.plugins.releaser.util.PluginUtils;
import fr.paris.lutece.plugins.releaser.util.ReleaserUtils;
import fr.paris.lutece.plugins.releaser.util.github.GitUtils;
import fr.paris.lutece.plugins.releaser.util.maven.MavenUtils;
import fr.paris.lutece.plugins.releaser.util.pom.PomUpdater;
import fr.paris.lutece.portal.business.user.AdminUser;
import fr.paris.lutece.portal.service.datastore.DatastoreService;
......@@ -114,9 +117,11 @@ public class WorkflowReleaseContextService implements IWorkflowReleaseContextSer
try
{
String strJsonContext = MapperJsonUtil.getJson( context );
//clean PWD in log before save in history
String strJsonContextClean= ReleaserUtils.cleanPWDInLog(strJsonContext);
DatastoreService.setDataValue( ReleaserUtils.getWorklowContextDataKey(
context.getComponent( ) != null ? context.getComponent( ).getArtifactId( ) : context.getSite( ).getArtifactId( ), context.getId( ) ),
strJsonContext );
strJsonContextClean );
}
catch( IOException e )
......
......@@ -3,6 +3,8 @@ package fr.paris.lutece.plugins.releaser.util;
import java.io.File;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
......@@ -451,5 +453,19 @@ public class ReleaserUtils
return cVersion1.compareTo( cVersion2 );
}
public static String cleanPWDInLog(String strLog)
{
Pattern pattern2 = Pattern.compile("(?<prot>https|http):\\/\\/(?<user>\\S+):(?<pwd>\\S+)@");
Matcher matcher2 = pattern2.matcher(strLog);
return matcher2.replaceAll("${prot}${user}:cleanpwd@");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment