Skip to content

Commit b68b58e

Browse files
committed
Validate boundaries of tsv
1 parent ab656cb commit b68b58e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

metafacture-flux/src/main/java/org/metafacture/flux/HelpPrinter.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public final class HelpPrinter {
5252
private static final String PATH_TO_EXAMPLES = "../metafacture-documentation/linksAndExamples.tsv";
5353
private static final Map<String, String[]> EXAMPLES_MAP = new HashMap<>();
5454
private static final int COLUMN_TO_PG_EXAMPLE = 3;
55-
private static final int REQUIRED_COLUMNS_OF_EXAMPLE = 2;
55+
private static final int MAX_COLUMNS_OF_EXAMPLE = COLUMN_TO_PG_EXAMPLE;
56+
private static final int MIN_COLUMNS_OF_EXAMPLE = 2;
5657

5758
private HelpPrinter() {
5859
// no instances
@@ -126,9 +127,11 @@ private static <T> void describe(final String name, final ObjectFactory<T> facto
126127
printSignature(out, moduleClass);
127128

128129
final String[] examplesEntry = EXAMPLES_MAP.get(name);
129-
if (!EXAMPLES_MAP.isEmpty() && (examplesEntry == null || examplesEntry.length < REQUIRED_COLUMNS_OF_EXAMPLE)) {
130+
if (!EXAMPLES_MAP.isEmpty() && (examplesEntry == null || examplesEntry.length < MIN_COLUMNS_OF_EXAMPLE ||
131+
examplesEntry.length > MAX_COLUMNS_OF_EXAMPLE)) {
130132
throw new MetafactureException(
131-
"Failed to load build infos: tsv with links hasn't at least " + REQUIRED_COLUMNS_OF_EXAMPLE +
133+
"Failed to load build infos: tsv with links hasn't at least " + MIN_COLUMNS_OF_EXAMPLE + " " +
134+
"or exceeds the number of allowed columns (i.e. " + MAX_COLUMNS_OF_EXAMPLE + ")" +
132135
" for the entry '" + name + "'");
133136
}
134137
if (examplesEntry != null && examplesEntry.length == COLUMN_TO_PG_EXAMPLE) {

0 commit comments

Comments
 (0)