Skip to content

Commit b0b0588

Browse files
committed
Add code source for context
1 parent 79a901d commit b0b0588

File tree

1 file changed

+7
-6
lines changed
  • utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process

1 file changed

+7
-6
lines changed

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/Security.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,22 @@ internal fun <T> sandbox(file: URI, block: () -> T): T {
6060
PropertyPermission("org.mockito.internal.*", "read,write"),
6161
ReflectPermission("*"),
6262
)
63+
val allCodeSource = CodeSource(null, emptyArray<Certificate>())
6364
if (Files.exists(path)) {
6465
val policyFile = PolicyFile(file.toURL())
65-
val collection = policyFile.getPermissions(CodeSource(null, emptyArray<Certificate>()))
66+
val collection = policyFile.getPermissions(allCodeSource)
6667
perms += collection.elements().toList()
6768
}
68-
return sandbox(perms) { block() }
69+
return sandbox(perms, allCodeSource) { block() }
6970
}
7071

71-
internal fun <T> sandbox(permission: List<Permission>, block: () -> T): T {
72+
internal fun <T> sandbox(permission: List<Permission>, cs: CodeSource, block: () -> T): T {
7273
val perms = permission.fold(Permissions()) { acc, p -> acc.add(p); acc }
73-
return sandbox(perms) { block() }
74+
return sandbox(perms, cs) { block() }
7475
}
7576

76-
internal fun <T> sandbox(perms: PermissionCollection, block: () -> T): T {
77-
val acc = AccessControlContext(arrayOf(ProtectionDomain(null, perms)))
77+
internal fun <T> sandbox(perms: PermissionCollection, cs: CodeSource, block: () -> T): T {
78+
val acc = AccessControlContext(arrayOf(ProtectionDomain(cs, perms)))
7879
return AccessController.doPrivileged(
7980
PrivilegedAction {
8081
block()

0 commit comments

Comments
 (0)