Skip to content

Commit d5ca046

Browse files
authored
Merge pull request #87 from tls-attacker/fixPullingImages
Fixed pulling of images
2 parents c3d4996 + 2dd883a commit d5ca046

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.LinkedList;
3131
import java.util.List;
3232
import java.util.Map;
33+
import java.util.Optional;
3334
import java.util.concurrent.TimeUnit;
3435
import java.util.function.UnaryOperator;
3536
import org.apache.logging.log4j.LogManager;
@@ -144,19 +145,13 @@ public void pull(ConnectionRole connectionRole) {
144145
labels.put(
145146
TlsImageLabels.CONNECTION_ROLE.getLabelName(),
146147
connectionRole.toString().toLowerCase());
147-
Image image =
148-
DOCKER.listImagesCmd().withLabelFilter(labels).exec().stream()
149-
.findFirst()
150-
.orElseThrow(TlsVersionNotFoundException::new);
151-
if (image != null) {
148+
Optional<Image> image =
149+
DOCKER.listImagesCmd().withLabelFilter(labels).exec().stream().findFirst();
150+
if (image.isPresent()) {
152151
LOGGER.warn("Not pulling image, image already exists!");
153152
return;
154153
}
155154

156-
// TODO: implement public docker repo when published
157-
LOGGER.warn(
158-
"Could not pull repository from Public Repository. Trying internal repository.");
159-
160155
String username = DockerClientManager.getDockerServerUsername();
161156
String password = DockerClientManager.getDockerServerPassword();
162157
if (username == null || password == null) {
@@ -173,11 +168,11 @@ public void pull(ConnectionRole connectionRole) {
173168
// we go with this
174169
// for now
175170
String loginCommand =
176-
"docker login -u "
177-
+ DockerClientManager.getDockerServerUsername()
178-
+ " -p "
171+
"echo "
179172
+ DockerClientManager.getDockerServerPassword()
180-
+ " "
173+
+ " | docker login -u "
174+
+ DockerClientManager.getDockerServerUsername()
175+
+ " --password-stdin "
181176
+ REPOSITORY_LOCATION;
182177
String pullCommand =
183178
"docker pull "

0 commit comments

Comments
 (0)