Skip to content

Commit c81775f

Browse files
committed
Fixed NPE and empty pseudo-parameters
1 parent c57ab59 commit c81775f

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/main/java/de/rub/nds/tls/subject/docker/DockerTlsServerInstance.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,16 @@ protected CreateContainerCmd prepareCreateContainerCmd(CreateContainerCmd cmd) {
7979
} else {
8080
host = hostInfo.getHostname();
8181
}
82-
exposedImplementationPort =
83-
new ExposedPort(hostInfo.getPort(), hostInfo.getType().toInternetProtocol());
84-
return super.prepareCreateContainerCmd(cmd)
85-
.withCmd(
86-
parameterProfile.toParameters(
87-
host,
88-
hostInfo.getPort(),
89-
imageProperties,
90-
additionalParameters,
91-
parallelize,
92-
insecureConnection))
82+
exposedImplementationPort = new ExposedPort(hostInfo.getPort(), hostInfo.getType().toInternetProtocol());
83+
String[] additionalCmds = parameterProfile.toParameters(host, hostInfo.getPort(), imageProperties,
84+
additionalParameters, parallelize, insecureConnection);
85+
if (additionalCmds.length > 0 && !additionalCmds[0].isEmpty()) {
86+
return super.prepareCreateContainerCmd(cmd).withCmd(additionalCmds)
9387
.withExposedPorts(exposedImplementationPort);
88+
} else {
89+
return super.prepareCreateContainerCmd(cmd).withExposedPorts(exposedImplementationPort);
90+
}
91+
9492
}
9593

9694
@Override

src/main/java/de/rub/nds/tls/subject/params/ParameterProfile.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,28 @@ public String[] toParameters(
114114
boolean parallelize,
115115
boolean insecureConnection) {
116116
StringBuilder finalParams = new StringBuilder();
117-
for (Parameter param : parameterList) {
118-
if (supportsInsecure()) {
119-
if ((insecureConnection && param.getType() == ParameterType.CA_CERTIFICATE)
117+
if (parameterList != null) {
118+
for (Parameter param : parameterList) {
119+
if (supportsInsecure()) {
120+
if ((insecureConnection && param.getType() == ParameterType.CA_CERTIFICATE)
120121
|| (!insecureConnection && param.getType() == ParameterType.INSECURE)) {
121-
// do not add CA param if we use insecure, do not add insecure
122-
// if not wanted
123-
continue;
122+
// do not add CA param if we use insecure, do not add insecure
123+
// if not wanted
124+
continue;
125+
}
124126
}
125-
}
126127

127-
if (!parallelize && param.getType() == ParameterType.PARALLELIZE) {
128-
// do not add parallelize if not wanted
129-
continue;
130-
}
131-
if (param.getCmdParameter().equals("")) {
132-
// do not add empty commands that cause a blank space
133-
continue;
128+
if (!parallelize && param.getType() == ParameterType.PARALLELIZE) {
129+
// do not add parallelize if not wanted
130+
continue;
131+
}
132+
if (param.getCmdParameter().equals("")) {
133+
// do not add empty commands that cause a blank space
134+
continue;
135+
}
136+
finalParams.append(param.getCmdParameter());
137+
finalParams.append(" ");
134138
}
135-
finalParams.append(param.getCmdParameter());
136-
finalParams.append(" ");
137139
}
138140
if (additionalParameters != null) {
139141
finalParams.append(additionalParameters);

0 commit comments

Comments
 (0)