Skip to content

Commit

Permalink
Added maximum string length constraint. (jenkinsci#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucascz37 committed Dec 5, 2023
1 parent 82fed4c commit e175dc7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public FormValidation doCheckTrendsLimit(@QueryParameter String value) {
return isValidInteger(value);
}

public FormValidation doMaxStringLengthConstraint(@QueryParameter String value) {
return isValidInteger(value);
}

public FormValidation doCheckFailedStepsNumber(@QueryParameter String value) {
return isValidInteger(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Set;
import java.util.UUID;

import com.fasterxml.jackson.core.StreamReadConstraints;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.AbortException;
import hudson.Extension;
Expand Down Expand Up @@ -78,6 +79,7 @@ public class CucumberReportPublisher extends Recorder implements SimpleBuildStep
private boolean undefinedAsNotFailingStatus;

private int trendsLimit;
private int maxStringLengthConstraint;
private String sortingMethod;
private List<Classification> classifications;
private String customJsFiles;
Expand Down Expand Up @@ -158,6 +160,14 @@ public void setTrendsLimit(int trendsLimit) {
this.trendsLimit = trendsLimit;
}

public int getMaxStringLengthConstraint() {
return maxStringLengthConstraint;
}

public void setMaxStringLengthConstraint(int maxStringLengthConstraint) {
this.maxStringLengthConstraint = maxStringLengthConstraint;
}

public String getFileExcludePattern() {
return fileExcludePattern;
}
Expand Down Expand Up @@ -559,6 +569,8 @@ private void generateReport(Run<?, ?> build, FilePath workspace, TaskListener li

setFailingStatuses(configuration);

StreamReadConstraints.overrideDefaultStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(maxStringLengthConstraint).build());

ReportBuilder reportBuilder = new ReportBuilder(jsonFilesToProcess, configuration);
Reportable result = reportBuilder.generateReports();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
field="trendsLimit">
<f:textbox default="0"/>
</f:entry>
<f:entry
title="${%maxStringLengthConstraint.title}"
field="maxStringLengthConstraint">
<f:textbox default="20000000"/>
</f:entry>
</f:section>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ fileIncludePattern.title=File Include Pattern
classificationsFilePattern.title=Classifications File Pattern
fileExcludePattern.title=File Exclude Pattern
trendsLimit.title=Limit for trends
maxStringLengthConstraint.title=Maximum string size (Stream read constraint of JacksonCore)
# ===
buildResult=Build Result
buildResult.description=This section allows to configure when the build is marked as failed or unstable. Result is changed when any of below rule is enabled.
Expand Down

0 comments on commit e175dc7

Please sign in to comment.