Avatar of srikotesh
srikotesh
 asked on

How to resolve path traversal issue in java

Hi Experts,

//Path Traversal Issue
				
String configuration = path +File.separator+"data"+File.separator+temp+File.separator+id+type+"."+frmt;
File newFilePath = new File(configuration);

Open in new window


please suggest how to change the above to resolve path traversal issue.
Java

Avatar of undefined
Last Comment
rrz

8/22/2022 - Mon
CEHJ

ASKER CERTIFIED SOLUTION
dpearson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CEHJ

That is of course true. But that will only help when you have condensed your tokens, which will require concatenation. You should probably log debug the result of the concatenation such that the reasons for any surprises are instantly visible
SOLUTION
rrz

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
CEHJ

Ah well done - wasn't familiar with that
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
rrz

@CEHJ, thank you.