Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/setup-docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as config from "../config";
import * as yaml from "js-yaml";
import { getBuildInfo } from "../version/buildUtil";
import parseFabloConfig from "../utils/parseFabloConfig";
import { shellQuote } from "../utils/shellQuote";
import {
ChaincodeConfig,
ChannelConfig,
Expand Down Expand Up @@ -229,7 +230,10 @@ export default class SetupDocker extends Command {
for (const script of scripts) {
const templatePath = getTemplatePath(this.templatesDir, script);
const destPath = getDestinationPath(this.outputDir, script);
await renderTemplate(templatePath, destPath, config as unknown as Record<string, unknown>);
await renderTemplate(templatePath, destPath, {
...(config as unknown as Record<string, unknown>),
shellQuote,
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"<%= chaincode.name %>" <% -%>
"<%= chaincode.version %>" <% -%>
"<%= chaincode.channel.ordererHead.fullAddress %>" <% -%>
"<%- chaincode.endorsement || '' %>" <% -%>
<%- shellQuote(chaincode.endorsement || '') %> <% -%>
"false" <% -%>
"" <% -%>
"<%= chaincode.privateDataConfigFile || '' %>" <% -%>
Expand All @@ -28,7 +28,7 @@ chaincodeCommit <% -%>
"<%= chaincode.name %>" <% -%>
"<%= chaincode.version %>" <% -%>
"<%= chaincode.channel.ordererHead.fullAddress %>" <% -%>
"<%- chaincode.endorsement || '' %>" <% -%>
<%- shellQuote(chaincode.endorsement || '') %> <% -%>
"false" <% -%>
"" <% -%>
"<%= chaincode.channel.orgs.map((o) => o.headPeer.fullAddress).join(',') %>" <% -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ printHeadline "Packaging chaincode '<%= chaincode.name %>'" "U1F60E"
"<%= !global.tls ? '' : `crypto-orderer/tlsca.${chaincode.channel.ordererHead.domain}-cert.pem` %>" <% -%>
"<%= instance.containerName %>" <% -%>
"<%= chaincode.chaincodeMountPath ?? "" %>" <% -%>
"<%- chaincode.chaincodeStartCommand ?? "" %>"
<%- shellQuote(chaincode.chaincodeStartCommand ?? '') %>
<% } -%>
<% }) -%>
chaincodeApprove <% -%>
Expand All @@ -68,7 +68,7 @@ printHeadline "Packaging chaincode '<%= chaincode.name %>'" "U1F60E"
"<%= chaincode.name %>" <% -%>
"$version" <% -%>
"<%= chaincode.channel.ordererHead.fullAddress %>" <% -%>
"<%- chaincode.endorsement || '' %>" <% -%>
<%- shellQuote(chaincode.endorsement || '') %> <% -%>
"<%= chaincode.initRequired %>" <% -%>
"<%= !global.tls ? '' : `crypto-orderer/tlsca.${chaincode.channel.ordererHead.domain}-cert.pem` %>" <% -%>
"<%= chaincode.privateDataConfigFile || '' %>" <% -%>
Expand All @@ -83,7 +83,7 @@ chaincodeCommit <% -%>
"<%= chaincode.name %>" <% -%>
"$version" <% -%>
"<%= chaincode.channel.ordererHead.fullAddress %>" <% -%>
"<%- chaincode.endorsement || '' %>" <% -%>
<%- shellQuote(chaincode.endorsement || '') %> <% -%>
"<%= chaincode.initRequired %>" <% -%>
"<%= !global.tls ? '' : `crypto-orderer/tlsca.${chaincode.channel.ordererHead.domain}-cert.pem` %>" <% -%>
"<%= chaincode.channel.orgs.map((o) => o.headPeer.fullAddress).join(',') %>" <% -%>
Expand Down
7 changes: 7 additions & 0 deletions src/utils/shellQuote.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function shellQuote(value: unknown): string {
return `"${String(value ?? "")
.replace(/\\/g, "\\\\")
.replace(/"/g, '\\"')
.replace(/\$/g, "\\$")
.replace(/`/g, "\\`")}"`;
}
Loading