Skip to content

Commit

Permalink
fix: fix allowed_env_substitutions parsed error
Browse files Browse the repository at this point in the history
SmallRyeConfig getValue doesn't allow the provided configured value to
be empty, therefore use getOptionalValue instead.

See also: microprofile/microprofile-config#407

Fixes #303
  • Loading branch information
beiertu-mms committed Jan 11, 2024
1 parent a5756b5 commit 78675b6
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -94,9 +87,10 @@ public CdxgenClient() {
this.recursiveDefault = config.getValue("analysis.recursive_default", Boolean.TYPE);
this.failOnError = config.getValue("cdxgen.fail_on_error", Boolean.TYPE);

this.allowedEnvSubstitutions = Arrays.stream(
config.getValue("app.allowed_env_substitutions", String.class).split(",")
).map(String::trim).toList();
this.allowedEnvSubstitutions = config.getOptionalValue("app.allowed_env_substitutions", String.class)
.filter(str -> !str.isBlank())
.map(str -> Arrays.stream(str.split(",")).map(String::trim).toList())
.orElse(Collections.emptyList());

// https://github.com/AppThreat/cdxgen#environment-variables
this.cdxgenEnv = Map.of(
Expand Down

0 comments on commit 78675b6

Please sign in to comment.