Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Commit 2fded7e

Browse files
committed
Whitelist all aliases for localhost in tests
Relates to actions/runner-images#3353
1 parent 15196bc commit 2fded7e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

engine/src/test/groovy/de/gesellix/docker/engine/OkDockerClientSpec.groovy

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,18 @@ class OkDockerClientSpec extends Specification {
10411041
def whitelist = ["localhost",
10421042
"127.0.0.1",
10431043
"stratum.antpool.com"]
1044-
return host in whitelist || host.endsWith(".internal")
1044+
def isWindows = System.properties['os.name'].toLowerCase().contains('windows')
1045+
def hosts = isWindows ? new File("${System.getenv("SystemRoot")}\\System32\\drivers\\etc\\hosts") : new File("/etc/hosts")
1046+
if (hosts.isFile()) {
1047+
whitelist.addAll(hosts.readLines()
1048+
.grep({ it.startsWith("127.0.0.1 ") })
1049+
.collect({ it.substring("127.0.0.1 ".length()).toLowerCase() }))
1050+
}
1051+
def isAllowed = host.toLowerCase() in whitelist || host.endsWith(".internal")
1052+
if (!isAllowed) {
1053+
println("$host not in $whitelist")
1054+
}
1055+
return isAllowed
10451056
}
10461057
}
10471058
}

0 commit comments

Comments
 (0)