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

Clear sensitive data from trade ProcessModel #6283

Merged
merged 1 commit into from Jul 12, 2022
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
7 changes: 5 additions & 2 deletions core/src/main/java/bisq/core/trade/model/bisq_v1/Trade.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,15 @@ public static protobuf.Trade.TradePeriodState toProtoMessage(Trade.TradePeriodSt
// Persistable
// Immutable
@Getter
private final ProcessModel processModel;
@Getter
private final boolean isCurrencyForTakerFeeBtc;
@Getter
private final long tradeTxFeeAsLong;
@Getter
private final long takerFeeAsLong;

// Mutable
@Getter
private ProcessModel processModel;
@Nullable
@Getter
@Setter
Expand Down Expand Up @@ -710,6 +710,9 @@ public void maybeClearSensitiveData() {
if (contract != null && contract.maybeClearSensitiveData()) {
change += "contract;";
}
if (processModel != null && processModel.maybeClearSensitiveData()) {
change += "processModel;";
}
if (contractAsJson != null) {
String edited = contract.sanitizeContractAsJson(contractAsJson);
if (!edited.equals(contractAsJson)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ public static byte[] hashOfPaymentAccountPayload(PaymentAccountPayload paymentAc
transient private Transaction depositTx;

// Persistable Immutable
private final TradingPeer tradingPeer;
private final String offerId;
private final PubKeyRing pubKeyRing;

// Persistable Mutable
private TradingPeer tradingPeer;
@Nullable
@Setter
private String takeOfferFeeTxId;
Expand Down Expand Up @@ -343,6 +343,15 @@ public void setDepositTxMessageState(MessageState messageState) {
}
}

public boolean maybeClearSensitiveData() {
boolean changed = false;
if (tradingPeer.getPaymentAccountPayload() != null || tradingPeer.getContractAsJson() != null) {
// If tradingPeer was null in persisted data from some error cases we set a new one to not cause nullPointers
this.tradingPeer = new TradingPeer();
changed = true;
}
return changed;
}

///////////////////////////////////////////////////////////////////////////////////////////
// Delegates
Expand Down