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

Release | Fixed issued reported by SonarQube #1234

Merged
merged 4 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6202,7 +6202,7 @@ void writeRPCReaderUnicode(String sName, Reader re, long reLength, boolean bOut,

void sendEnclavePackage(String sql, ArrayList<byte[]> enclaveCEKs) throws SQLServerException {
if (null != con && con.isAEv2()) {
if (null != sql && "" != sql && null != enclaveCEKs && 0 < enclaveCEKs.size() && con.enclaveEstablished()) {
if (null != sql && "".equals(sql) && null != enclaveCEKs && 0 < enclaveCEKs.size() && con.enclaveEstablished()) {
rene-ye marked this conversation as resolved.
Show resolved Hide resolved
byte[] b = con.generateEnclavePackage(sql, enclaveCEKs);
if (null != b && 0 != b.length) {
this.writeShort((short) b.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,16 @@ void initBcryptECDH() throws SQLServerException {
/*
* Create our BCRYPT_ECCKEY_BLOB
*/
KeyPairGenerator kpg = null;
try {
kpg = KeyPairGenerator.getInstance("EC");
KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
kpg.initialize(new ECGenParameterSpec("secp384r1"));
} catch (GeneralSecurityException e) {
SQLServerException.makeFromDriverError(null, kpg, e.getLocalizedMessage(), "0", false);
}
KeyPair kp = kpg.generateKeyPair();
ECPublicKey publicKey = (ECPublicKey) kp.getPublic();
privateKey = kp.getPrivate();
ECPoint w = publicKey.getW();
try {
KeyPair kp = kpg.generateKeyPair();
ECPublicKey publicKey = (ECPublicKey) kp.getPublic();
privateKey = kp.getPrivate();
ECPoint w = publicKey.getW();
x = adjustBigInt(w.getAffineX().toByteArray());
y = adjustBigInt(w.getAffineY().toByteArray());
} catch (IOException e) {
} catch (GeneralSecurityException | IOException e) {
SQLServerException.makeFromDriverError(null, this, e.getLocalizedMessage(), "0", false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ public boolean verifyColumnMasterKeyMetadata(String masterKeyPath, boolean allow

KeyStoreProviderCommon.validateNonEmptyMasterKeyPath(masterKeyPath);
CertificateDetails certificateDetails = getCertificateDetails(masterKeyPath);
if (null == certificateDetails) {
return false;
}

try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
Expand All @@ -356,7 +359,6 @@ public boolean verifyColumnMasterKeyMetadata(String masterKeyPath, boolean allow
// value of allowEnclaveComputations is always true here
md.update("true".getBytes(java.nio.charset.StandardCharsets.UTF_16LE));
return rsaVerifySignature(md.digest(), signature, certificateDetails);

} catch (NoSuchAlgorithmException e) {
throw new SQLServerException(SQLServerException.getErrString("R_NoSHA256Algorithm"), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1047,9 +1047,9 @@ private ResultSet executeSPFkeys(String[] procParams) throws SQLException, SQLTi
cstmt.setString(i + 1, procParams[i]);
}
String currentDB = null;
if (null != procParams[2] && procParams[2] != "") {// pktable_qualifier
if (null != procParams[2] && !"".equals(procParams[2])) {// pktable_qualifier
currentDB = switchCatalogs(procParams[2]);
} else if (null != procParams[5] && procParams[5] != "") {// fktable_qualifier
} else if (null != procParams[5] && !"".equals(procParams[5])) {// fktable_qualifier
lilgreenbird marked this conversation as resolved.
Show resolved Hide resolved
currentDB = switchCatalogs(procParams[5]);
}
ResultSet rs = cstmt.executeQuery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ String constructTableTargets() {

String getFMTQuery() {
StringBuilder sb = new StringBuilder(FMT_ON);
if (prefix != "") {
if (!"".equals(prefix)) {
sb.append(prefix);
}
sb.append(SELECT);
Expand Down