Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools(fabric2-all-in-one): fix multiple vulnerabilities - 2023-08-17 #2135

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ export class PluginLedgerConnectorFabric
req: RunTransactionRequest,
): Promise<RunTransactionResponse> {
const fnTag = `${this.className}#transact()`;

this.log.debug("%s ENTER", fnTag);
const {
channelName,
contractName,
Expand All @@ -1121,13 +1121,27 @@ export class PluginLedgerConnectorFabric
} = req;

try {
this.log.debug("%s Creating Fabric Gateway instance...", fnTag);
const gateway = await this.createGateway(req);
// const gateway = await this.createGatewayLegacy(req.signingCredential);
this.log.debug("%s Obtaining Fabric gateway network instance...", fnTag);
const network = await gateway.getNetwork(channelName);
// const channel = network.getChannel();
// const endorsers = channel.getEndorsers();
this.log.debug("%s Obtaining Fabric contract instance...", fnTag);
const contract = network.getContract(contractName);

const channel = network.getChannel();
const endorsers = channel.getEndorsers();

const endorsersMetadata = endorsers.map((x) => ({
mspid: x.mspid,
discovered: x.discovered,
endpoint: x.endpoint,
name: x.name,
hasChaincode: x.hasChaincode(contractName),
isTLS: x.isTLS(),
}));
this.log.debug("%s Endorsers metadata: %o", fnTag, endorsersMetadata);

let out: Buffer;
let success: boolean;
let transactionId = "";
Expand All @@ -1138,7 +1152,10 @@ export class PluginLedgerConnectorFabric
break;
}
case FabricContractInvocationType.Send: {
this.log.debug("%s Creating tx instance on %s", fnTag, contractName);
this.log.debug("%s Endorsing peers: %o", fnTag, req.endorsingPeers);
const tx = contract.createTransaction(fnName);
this.log.debug("%s Created TX OK %o", fnTag, tx);
if (req.endorsingPeers) {
const { endorsingPeers } = req;
const channel = network.getChannel();
Expand Down Expand Up @@ -1168,8 +1185,11 @@ export class PluginLedgerConnectorFabric
);
tx.setEndorsingPeers(endorsers);
}
this.log.debug("%s Submitting TX... (%o)", fnTag, params);
out = await tx.submit(...params);
this.log.debug("%s Submitted TX OK (%o)", fnTag, params);
transactionId = tx.getTransactionId();
this.log.debug("%s Obtained TX ID OK (%s)", fnTag, transactionId);
success = true;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ test(testCase, async (t: Test) => {
// does the same thing, it just waits 10 seconds for good measure so there
// might not be a way for us to avoid doing this, but if there is a way we
// absolutely should not have timeouts like this, anywhere...
await new Promise((resolve) => setTimeout(resolve, 10000));
await new Promise((resolve) => setTimeout(resolve, 30000));

const assetId = uuidv4();
const assetOwner = uuidv4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ test(testCase, async (t: Test) => {
// does the same thing, it just waits 10 seconds for good measure so there
// might not be a way for us to avoid doing this, but if there is a way we
// absolutely should not have timeouts like this, anywhere...
await new Promise((resolve) => setTimeout(resolve, 10000));
await new Promise((resolve) => setTimeout(resolve, 30000));

const assetId = uuidv4();
const assetOwner = uuidv4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ describe(testCase, () => {
const assets = JSON.parse(res.data.functionOutput);
const asset277 = assets.find((c: { ID: string }) => c.ID === assetId);
expect(asset277).toBeTruthy();
expect(asset277.owner).toBeTruthy();
expect(asset277.owner).toEqual(assetOwner);
expect(asset277.Owner).toBeTruthy();
expect(asset277.Owner).toEqual(assetOwner);
}

{
Expand Down Expand Up @@ -302,8 +302,8 @@ describe(testCase, () => {
const assets = JSON.parse(res.data.functionOutput);
const asset277 = assets.find((c: { ID: string }) => c.ID === assetId);
expect(asset277).toBeTruthy();
expect(asset277.owner).toBeTruthy();
expect(asset277.owner).toEqual(assetOwner);
expect(asset277.Owner).toBeTruthy();
expect(asset277.Owner).toEqual(assetOwner);
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ test("run-transaction-with-identities", async (t: Test) => {
});
t.true(resp.success);
const asset = JSON.parse(resp.functionOutput);
t.equal(asset.owner, "client2");
t.equal(asset.Owner, "client2");
}
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export interface LedgerStartOptions {

export const DEFAULT_FABRIC_2_AIO_IMAGE_NAME =
"ghcr.io/hyperledger/cactus-fabric2-all-in-one";
export const DEFAULT_FABRIC_2_AIO_IMAGE_VERSION = "2023-08-05-issue2358";
export const DEFAULT_FABRIC_2_AIO_FABRIC_VERSION = "2.2.13";
export const DEFAULT_FABRIC_2_AIO_IMAGE_VERSION = "2023-08-17-issue2057-pr2135";
export const DEFAULT_FABRIC_2_AIO_FABRIC_VERSION = "2.4.4";

/*
* Provides default options for Fabric container
Expand Down
20 changes: 9 additions & 11 deletions tools/docker/fabric-all-in-one/Dockerfile_v2.x
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# We need to use the older, more stable v18 here because of
# https://github.com/docker-library/docker/issues/170
FROM docker:24.0.5-dind

ARG FABRIC_VERSION=2.2.13
ARG FABRIC_VERSION=2.4.4
ARG FABRIC_NODEENV_VERSION=2.4.2
ARG CA_VERSION=1.4.9
ARG CA_VERSION=1.5.3
ARG COUCH_VERSION_FABRIC=0.4
ARG COUCH_VERSION=3.1.1
ARG COUCH_VERSION=3.2.2

WORKDIR /

Expand Down Expand Up @@ -172,10 +170,10 @@ RUN /bootstrap.sh ${FABRIC_VERSION} ${CA_VERSION} -d
# Update the image version used by the Fabric peers when installing chaincodes.
# This is necessary because the older (default) image uses NodeJS v12 and npm v6
# But we need at least NodeJS 16 and npm v7 for the dependency installation to work.
RUN sed -i "s/fabric-nodeenv:\$(TWO_DIGIT_VERSION)/fabric-nodeenv:${FABRIC_NODEENV_VERSION}/g" /fabric-samples/config/core.yaml
RUN sed -i "s/fabric-nodeenv:\$(TWO_DIGIT_VERSION)/fabric-nodeenv:${FABRIC_NODEENV_VERSION}/g" /fabric-samples/test-network/compose/docker/peercfg/core.yaml

# Set the log level of the peers and other containers to DEBUG instead of the default INFO
RUN sed -i "s/FABRIC_LOGGING_SPEC=INFO/FABRIC_LOGGING_SPEC=DEBUG/g" /fabric-samples/test-network/docker/docker-compose-test-net.yaml
RUN sed -i "s/FABRIC_LOGGING_SPEC=INFO/FABRIC_LOGGING_SPEC=DEBUG/g" /fabric-samples/test-network/compose/docker/docker-compose-test-net.yaml

# Update the docker-compose file of the fabric-samples repo so that the
# core.yaml configuration file of the peer containers can be customized.
Expand All @@ -185,13 +183,13 @@ RUN sed -i "s/FABRIC_LOGGING_SPEC=INFO/FABRIC_LOGGING_SPEC=DEBUG/g" /fabric-samp
# an error when the peer tries to install the dependencies as part of the
# chaincode installation.
RUN yq '.services."peer0.org1.example.com".volumes += "../..:/opt/gopath/src/github.com/hyperledger/fabric-samples"' \
--inplace /fabric-samples/test-network/docker/docker-compose-test-net.yaml
--inplace /fabric-samples/test-network/compose/docker/docker-compose-test-net.yaml
RUN yq '.services."peer0.org1.example.com".volumes += "../../config/core.yaml:/etc/hyperledger/fabric/core.yaml"' \
--inplace /fabric-samples/test-network/docker/docker-compose-test-net.yaml
--inplace /fabric-samples/test-network/compose/docker/docker-compose-test-net.yaml
RUN yq '.services."peer0.org2.example.com".volumes += "../..:/opt/gopath/src/github.com/hyperledger/fabric-samples"' \
--inplace /fabric-samples/test-network/docker/docker-compose-test-net.yaml
--inplace /fabric-samples/test-network/compose/docker/docker-compose-test-net.yaml
RUN yq '.services."peer0.org2.example.com".volumes += "../../config/core.yaml:/etc/hyperledger/fabric/core.yaml"' \
--inplace /fabric-samples/test-network/docker/docker-compose-test-net.yaml
--inplace /fabric-samples/test-network/compose/docker/docker-compose-test-net.yaml

# Install supervisord because we need to run the docker daemon and also the fabric network
# meaning that we have multiple processes to run.
Expand Down
Loading