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

Upgraded third-party dependencies to the latest versions and fixed CVE vulnerabilities #34409

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
wrapperVersion=3.9.9
linghengqian marked this conversation as resolved.
Show resolved Hide resolved
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
5 changes: 5 additions & 0 deletions db-protocol/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
linghengqian marked this conversation as resolved.
Show resolved Hide resolved

<dependency>
<groupId>io.netty</groupId>
Expand Down
6 changes: 6 additions & 0 deletions db-protocol/mysql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,11 @@
<artifactId>shardingsphere-mysql-dialect-exception</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions db-protocol/opengauss/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@
<artifactId>opengauss-jdbc</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions db-protocol/postgresql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@
<artifactId>postgresql</artifactId>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import org.apache.shardingsphere.encrypt.rewrite.token.generator.fixture.EncryptGeneratorFixtureBuilder;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.subquery.SubquerySegment;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -38,7 +40,7 @@ class EncryptInsertSelectSupportedCheckerTest {
@Test
void assertIsCheck() {
InsertStatementContext sqlStatementContext = mock(InsertStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getSqlStatement().getInsertSelect().isPresent()).thenReturn(true);
when(sqlStatementContext.getSqlStatement().getInsertSelect()).thenReturn(Optional.of(mock(SubquerySegment.class)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Why does updating some third-party dependencies cause a large number of unit tests to change? Where is the original issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new version of mock will prompt that the thenReturn type is wrong, and Optional.of(mock(SubquerySegment.class)) is required to return

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This involves a problem. The new version of mockito does not support JDK8, so it makes no sense to do so.

assertTrue(new EncryptInsertSelectSupportedChecker().isCheck(sqlStatementContext));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.shardingsphere.encrypt.checker.sql.projection;

import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.binder.context.segment.select.projection.impl.ColumnProjection;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
Expand Down Expand Up @@ -76,8 +77,13 @@ void assertCheckWhenShorthandExpandContainsSubqueryTable() {

@Test
void assertCheckWhenCombineStatementContainsEncryptColumn() {
EncryptRule encryptRule = mock(EncryptRule.class, RETURNS_DEEP_STUBS);
when(encryptRule.findQueryEncryptor("foo_tbl", "foo_col_1")).thenReturn(Optional.of(mock(EncryptAlgorithm.class)));
when(encryptRule.findQueryEncryptor("foo_tbl", "foo_col_2")).thenReturn(Optional.of(mock(EncryptAlgorithm.class)));
when(encryptRule.findQueryEncryptor("bar_tbl", "bar_col_1")).thenReturn(Optional.of(mock(EncryptAlgorithm.class)));
when(encryptRule.findQueryEncryptor("bar_tbl", "bar_col_2")).thenReturn(Optional.of(mock(EncryptAlgorithm.class)));
SelectStatementContext sqlStatementContext = mockSelectStatementContext();
assertThrows(UnsupportedSQLOperationException.class, () -> new EncryptSelectProjectionSupportedChecker().check(mock(EncryptRule.class, RETURNS_DEEP_STUBS), null, null, sqlStatementContext));
assertThrows(UnsupportedSQLOperationException.class, () -> new EncryptSelectProjectionSupportedChecker().check(encryptRule, null, null, sqlStatementContext));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import org.apache.shardingsphere.encrypt.rewrite.token.generator.fixture.EncryptGeneratorFixtureBuilder;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.WithSegment;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -38,7 +40,7 @@ class EncryptWithClauseSupportedCheckerTest {
@Test
void assertIsCheck() {
SelectStatementContext sqlStatementContext = mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getWith().isPresent()).thenReturn(true);
when(sqlStatementContext.getWith()).thenReturn(Optional.of(mock(WithSegment.class)));
assertTrue(new EncryptWithClauseSupportedChecker().isCheck(sqlStatementContext));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.shardingsphere.encrypt.rule.column.EncryptColumn;
import org.apache.shardingsphere.encrypt.rule.table.EncryptTable;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.database.h2.type.H2DatabaseType;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.assignment.ColumnAssignmentSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.assignment.SetAssignmentSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simple.LiteralExpressionSegment;
Expand Down Expand Up @@ -57,7 +58,7 @@ class EncryptAssignmentTokenGeneratorTest {

@BeforeEach
void setup() {
tokenGenerator = new EncryptAssignmentTokenGenerator(mockEncryptRule(), null, null);
tokenGenerator = new EncryptAssignmentTokenGenerator(mockEncryptRule(), "testDataBaseName", new H2DatabaseType());
when(tablesContext.getSimpleTables().iterator().next().getTableName().getIdentifier().getValue()).thenReturn("table");
when(assignmentSegment.getColumns().get(0).getIdentifier().getValue()).thenReturn("columns");
when(setAssignmentSegment.getAssignments()).thenReturn(Collections.singleton(assignmentSegment));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private EncryptRule mockEncryptRule() {
EncryptColumn encryptColumn = mock(EncryptColumn.class, RETURNS_DEEP_STUBS);
when(encryptColumn.getAssistedQuery()).thenReturn(Optional.empty());
when(encryptTable1.getEncryptColumn("mobile")).thenReturn(encryptColumn);
when(result.findEncryptTable("t_order").isPresent()).thenReturn(true);
when(result.findEncryptTable("t_order")).thenReturn(Optional.of(mock(EncryptTable.class)));
when(result.getEncryptTable("t_order").isEncryptColumn("order_id")).thenReturn(true);
return result;
}
Expand Down
6 changes: 6 additions & 0 deletions features/shadow/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@
<artifactId>shardingsphere-infra-algorithm-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions features/shadow/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,11 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ void assertRetrieveWithColumnOwner() {
when(columnSegment.getColumnBoundInfo().getOriginalTable().getValue()).thenReturn("foo_tbl");
OwnerSegment ownerSegment = new OwnerSegment(0, 0, new IdentifierValue("foo"));
ownerSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
when(columnSegment.getOwner()).thenReturn(Optional.of(ownerSegment));
when(ColumnExtractor.extract(expressionSegment)).thenReturn(Collections.singleton(columnSegment));
when(ShadowExtractor.extractValues(expressionSegment, Collections.singletonList("foo"))).thenReturn(Optional.of(Collections.singleton("foo")));
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("foo_tbl"));
Expand All @@ -81,7 +80,6 @@ void assertRetrieveWithoutColumnOwner() {
when(sqlStatementContext.getWhereSegments()).thenReturn(Arrays.asList(whereSegment, mock(WhereSegment.class, RETURNS_DEEP_STUBS)));
ColumnSegment columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
when(columnSegment.getColumnBoundInfo().getOriginalTable().getValue()).thenReturn("foo_tbl");
when(columnSegment.getOwner()).thenReturn(Optional.empty());
when(ColumnExtractor.extract(expressionSegment)).thenReturn(Collections.singleton(columnSegment));
when(ShadowExtractor.extractValues(expressionSegment, Collections.singletonList("foo"))).thenReturn(Optional.of(Collections.singleton("foo")));
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("foo_tbl"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void assertRangeDoShardingByDays() {
"SQL Date values do not have a time component.");
assertThat(createAlgorithm("yyyy-MM-dd", "2021-06-01",
"2021-07-31", "yyyyMMdd", stepAmount, null)
.doSharding(availableTargetNames, shardingValueAsSqlDate).size(),
.doSharding(availableTargetNames, shardingValueAsSqlDate).size(),
is(expectSize));
final RangeShardingValue<Comparable<?>> shardingValueAsString = createShardingValue(
DateTimeFormatterFactory.getStandardFormatter().format(lower),
Expand All @@ -252,8 +252,8 @@ void assertRangeDoShardingByDaysInLocalDate() {
}
Collection<String> actualAsLocalDate = createAlgorithm("yyyy-MM-dd", "2021-06-01",
"2021-07-31", "yyyyMMdd", stepAmount, null)
.doSharding(availableTargetNames,
createShardingValue(LocalDate.of(2021, 6, 15), LocalDate.of(2021, 7, 31)));
.doSharding(availableTargetNames,
createShardingValue(LocalDate.of(2021, 6, 15), LocalDate.of(2021, 7, 31)));
assertThat(actualAsLocalDate.size(), is(24));
}

Expand Down Expand Up @@ -283,7 +283,7 @@ void assertRangeDoShardingByYears() {
}
Collection<String> actual = createAlgorithm("yyyy", "2000",
"2022", "yyyy", 2, "Years")
.doSharding(availableTargetNames, createShardingValue(Year.of(2001), Year.of(2013)));
.doSharding(availableTargetNames, createShardingValue(Year.of(2001), Year.of(2013)));
assertThat(actual.size(), is(7));
}

Expand All @@ -297,8 +297,8 @@ void assertRangeDoShardingByYearsInYearMonth() {
}
Collection<String> actualAsYearMonth = createAlgorithm("yyyy-MM", "2016-01",
"2021-12", "yyyyMM", 2, "Years")
.doSharding(availableTargetNames,
createShardingValue(YearMonth.of(2016, 1), YearMonth.of(2020, 1)));
.doSharding(availableTargetNames,
createShardingValue(YearMonth.of(2016, 1), YearMonth.of(2020, 1)));
assertThat(actualAsYearMonth.size(), is(3));
}

Expand Down Expand Up @@ -329,7 +329,7 @@ private IntervalShardingAlgorithm createAlgorithm(final String datetimePattern,
new Property("sharding-suffix-pattern", shardingSuffixPattern),
new Property("datetime-interval-amount", Integer.toString(datetimeIntervalAmount)));
if (null != datetimeIntervalUnit) {
props.put("datetime-interval-unit", datetimeIntervalUnit);
props.setProperty("datetime-interval-unit", datetimeIntervalUnit);
}
return (IntervalShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "INTERVAL", props);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ class ShardingDALResultMergerTest {

@Test
void assertMergeForShowDatabasesStatement() throws SQLException {
SQLStatementContext sqlStatementContext = mockSQLStatementContext(new MySQLShowDatabasesStatement());
SQLStatementContext sqlStatementContext = mock(SQLStatementContext.class, withSettings().extraInterfaces(TableAvailable.class).defaultAnswer(RETURNS_DEEP_STUBS));
when(sqlStatementContext.getSqlStatement()).thenReturn(new MySQLShowDatabasesStatement());
when(sqlStatementContext.getDatabaseType()).thenReturn(databaseType);
assertThat(resultMerger.merge(queryResults, sqlStatementContext, mock(), mock()), instanceOf(LocalDataMergedResult.class));
}

Expand Down
6 changes: 6 additions & 0 deletions infra/algorithm/type/key-generator/type/uuid/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@
<artifactId>shardingsphere-infra-algorithm-key-generator-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions infra/algorithm/type/load-balancer/type/round-robin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@
<artifactId>shardingsphere-infra-algorithm-load-balancer-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
8 changes: 8 additions & 0 deletions infra/exception/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@
</parent>
<artifactId>shardingsphere-infra-exception-core</artifactId>
<name>${project.artifactId}</name>

<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
5 changes: 5 additions & 0 deletions infra/exception/dialect/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
5 changes: 5 additions & 0 deletions infra/exception/dialect/type/mysql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@
<artifactId>shardingsphere-infra-exception-dialect-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
5 changes: 5 additions & 0 deletions infra/exception/dialect/type/postgresql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,10 @@
<artifactId>postgresql</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions infra/parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
5 changes: 5 additions & 0 deletions infra/rewrite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.binder.context.type.TableAvailable;
import org.apache.shardingsphere.infra.hint.HintValueContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
Expand All @@ -39,6 +38,7 @@
import org.mockito.quality.Strictness;

import java.util.Collections;
import java.util.Optional;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -81,7 +81,7 @@ void setUp() {
@Test
void assertInsertStatementContext() {
InsertStatementContext statementContext = mock(InsertStatementContext.class, RETURNS_DEEP_STUBS);
when(((TableAvailable) statementContext).getTablesContext().getDatabaseName().isPresent()).thenReturn(false);
when(statementContext.getTablesContext().getDatabaseName()).thenReturn(Optional.empty());
when(statementContext.getInsertSelectContext()).thenReturn(null);
QueryContext queryContext = mock(QueryContext.class, RETURNS_DEEP_STUBS);
when(queryContext.getSqlStatementContext()).thenReturn(statementContext);
Expand All @@ -95,7 +95,7 @@ void assertInsertStatementContext() {
@Test
void assertNotInsertStatementContext() {
SelectStatementContext statementContext = mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
when(((TableAvailable) statementContext).getTablesContext().getDatabaseName().isPresent()).thenReturn(false);
when(statementContext.getTablesContext().getDatabaseName()).thenReturn(Optional.empty());
QueryContext queryContext = mock(QueryContext.class, RETURNS_DEEP_STUBS);
when(queryContext.getSqlStatementContext()).thenReturn(statementContext);
when(queryContext.getSql()).thenReturn("SELECT * FROM tbl WHERE id = ?");
Expand Down
Loading
Loading