Skip to content

Commit 0b84f3a

Browse files
committed
add json sanitization
1 parent bf55b7b commit 0b84f3a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

plugins/hypervisors/kvm/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
<artifactId>hash4j</artifactId>
7373
<version>0.29.0</version>
7474
</dependency>
75+
<dependency>
76+
<groupId>com.mikesamuel</groupId>
77+
<artifactId>json-sanitizer</artifactId>
78+
<version>1.2.3</version>
79+
</dependency>
7580
<dependency>
7681
<groupId>com.linbit.linstor.api</groupId>
7782
<artifactId>java-linstor</artifactId>

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtValidateKbossVmCommandWrapper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.cloud.utils.script.Script;
3131
import com.google.gson.JsonObject;
3232
import com.google.gson.JsonParser;
33+
import com.google.json.JsonSanitizer;
3334
import org.apache.cloudstack.backup.ValidateKbossVmAnswer;
3435
import org.apache.cloudstack.backup.ValidateKbossVmCommand;
3536
import org.libvirt.Domain;
@@ -164,9 +165,10 @@ private String runScript(ValidateKbossVmCommand command, Domain vm) throws Libvi
164165
}
165166
logger.debug("Running validation script [{}] with arguments [{}] on dummy validation VM [{}].", script, arguments, vm.getName());
166167
String guestCommand = String.format(GUEST_EXEC_COMMAND, script, arguments);
168+
String sanitizedGuestCommand = JsonSanitizer.sanitize(guestCommand);
167169
String execResult;
168170
try {
169-
execResult = vm.qemuAgentCommand(guestCommand, command.getScriptTimeout(), 0);
171+
execResult = vm.qemuAgentCommand(sanitizedGuestCommand, command.getScriptTimeout(), 0);
170172
} catch (LibvirtException ex) {
171173
return ex.getMessage();
172174
}

0 commit comments

Comments
 (0)