Skip to content

Commit

Permalink
Fix UnsupportedOperationException: Refusing to marshal java.text.Simp…
Browse files Browse the repository at this point in the history
…leDateFormat for security reasons (#240)

* Added testcase to reproduce issue
* Re-apply fix from #170
  • Loading branch information
a-st authored Sep 29, 2023
1 parent c9c3596 commit 3c982cb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public abstract class AbstractParser extends PerformanceReportParser {
private static final Cache<String, PerformanceReport> CACHE = CacheBuilder.newBuilder().maximumSize(1000).softValues().build();

protected boolean isNumberDateFormat = false;
protected SimpleDateFormat format;
protected transient SimpleDateFormat format;

protected static final String[] DATE_FORMATS = new String[]{
"yyyy/MM/dd HH:mm:ss.SSS", "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd HH:mm:ss,SSS", "yyyy/mm/dd HH:mm:ss"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@ public boolean perform(AbstractBuild<?, ?> build,
}
}

@Test
public void testBuildWithFormattedTimeStamp() throws Exception {
final FreeStyleProject p = jenkinsRule.createFreeStyleProject();
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build,
Launcher launcher, BuildListener listener)
throws InterruptedException, IOException {
build.getWorkspace().child("test.csv").copyFrom(
getClass().getResource("/JMeterPublisher_formatted_timeStamp.csv"));
return true;
}
});
p.getPublishersList().add(new PerformancePublisher("test.csv"));

FreeStyleBuild b = jenkinsRule.assertBuildStatus(Result.SUCCESS, p.scheduleBuild2(0).get());
b.save();
}

@Test
public void testStandardResultsXML() throws Exception {
FreeStyleProject p = jenkinsRule.createFreeStyleProject();
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/JMeterPublisher_formatted_timeStamp.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,bytes
2014-02-24 07:42:21.256,1300,GET /ordermgmt/login - Login Page,501,FAIL,Thread Group 1-1,text,false,3478
2014-02-24 07:42:21.257,2000,GET /ordermgmt/pre-logout,200,OK,Thread Group 1-1,text,true,19714
2014-02-24 07:42:21.258,1000,GET /ordermgmt/pre-logout,200,OK,Thread Group 1-1,text,true,19714

0 comments on commit 3c982cb

Please sign in to comment.