Skip to content

Commit

Permalink
Bump version to flyway-9.20.1
Browse files Browse the repository at this point in the history
Please see the GH release for the release notes

Closes #3700 Fix beta module releases (E.G. flyway-gcp-spanner)

Upgrade AWS SDK to fix SNYK issue CVE-2023-34462

Update Maven Version check to use Maven Metadata to avoid website deprecation issues

Upgrade Google Cloud Secretmanager to fix SNYK-JAVA-COMGOOGLEGUAVA-5710356

Upgrade Google Cloud Storage to fix SNYK-JAVA-COMGOOGLEGUAVA-5710356

Update AWS Java SDK to fix SNYK-JAVA-IONETTY-5725787
  • Loading branch information
rg-buildmonkey committed Jul 12, 2023
1 parent 5bda08d commit 9abeef6
Show file tree
Hide file tree
Showing 45 changed files with 227 additions and 1,149 deletions.
9 changes: 2 additions & 7 deletions Dockerfile_tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:11.0.14.1_1-jdk as flyway
FROM eclipse-temurin:17-jre-focal as flyway
RUN apt-get update \
&& apt-get install -y python3-pip \
&& pip3 install sqlfluff==1.2.1
Expand All @@ -17,10 +17,5 @@ CMD ["/flyway/mvnw"]

FROM flyway as redgate

RUN curl -L https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -o packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb
RUN apt-get update \
&& apt-get install -y apt-transport-https \
&& apt-get update \
&& apt-get install -y dotnet-runtime-6.0
&& apt-get install -y --no-install-recommends libc6 libgcc1 libgssapi-krb5-2 libicu66 libssl1.1 libstdc++6 zlib1g
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ More information can be found on [the check command page](Commands/check).

This tutorial exemplifies the scenario where you have access to both your target DB (`url`) and a build DB (`buildUrl`).

## Install prerequisites

Flyway Check requires .Net 6 so make sure you have this installed. You can download it from [here](https://dotnet.microsoft.com/en-us/download/dotnet/6.0).

## Download the latest version of Flyway Enterprise CLI

First, [download the latest version of the Flyway Enterprise CLI](Usage/Command-line) and extract its contents.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,37 @@
</div>
<div class="col-md-9">

<div class="release">
<h2 id="9.20.1">Flyway 9.20.1 (2023-07-12)</h2>

<h3>Changes</h3>
<ul>
<li>Update Maven Version check to use Maven Metadata to avoid website deprecation issues</li>
</ul>

<h3>New features</h3>
<ul>
<li>Added table feedback for SQL Plus</li>
</ul>

<h3>Java compatibility</h3>
<ul>
<li>Upgrade AWS SDK to fix SNYK issue CVE-2023-34462</li>
<li>Upgrade google-cloud-spanner to fix SNYK issue SNYK-JAVA-COMGOOGLEGUAVA-5710356</li>
<li>Upgrade Google Cloud Secretmanager to 2.22.5 to fix SNYK-JAVA-COMGOOGLEGUAVA-5710356</li>
<li>Upgrade Google Cloud Storage to 2.22.5 to fix SNYK-JAVA-COMGOOGLEGUAVA-5710356</li>
<li>Update AWS Java SDK to 2.20.69 to fix SNYK-JAVA-IONETTY-5725787</li>
<li>
<a href="https://github.com/flyway/flyway/issues/3690">Issue 3690</a>
flyway-core now has a dependency on jackson-dataformat-toml.
</li>
</ul>

<p>
Thanks to froque for reporting these issues.
</p>
</div>

<div class="release">
<h2 id="9.20.0">Flyway 9.20.0 (2023-06-20)</h2>

Expand Down
2 changes: 1 addition & 1 deletion documentation/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

flywayVersion: 9.20.0
flywayVersion: 9.20.1
enterpriseUrl: https://download.red-gate.com/maven/release/org/flywaydb/enterprise
kramdown:
smart_quotes: ["apos", "apos", "quot", "quot"]
Expand Down
11 changes: 8 additions & 3 deletions flyway-commandline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-parent</artifactId>
<version>9.20.0</version>
<version>9.20.1</version>
</parent>
<artifactId>flyway-commandline</artifactId>
<packaging>jar</packaging>
Expand All @@ -30,7 +30,7 @@



<flyway-gcp-spanner.version>9.20.0-beta</flyway-gcp-spanner.version>
<flyway-gcp-spanner.version>9.20.1-beta</flyway-gcp-spanner.version>
<jre.version>17.0.6</jre.version>
</properties>
<dependencies>
Expand Down Expand Up @@ -319,9 +319,14 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.14.0</version>
<version>${version.jackson}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>${version.jackson}</version>
</dependency>



Expand Down
1 change: 1 addition & 0 deletions flyway-commandline/src/main/assembly/component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<includes>
<include>org.apache.commons:commons-text</include>
<include>com.fasterxml.jackson.dataformat:jackson-dataformat-toml</include>
<include>com.fasterxml.jackson.dataformat:jackson-dataformat-xml</include>
<include>org.slf4j:slf4j-nop</include>
</includes>
</dependencySet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,93 +15,59 @@
*/
package org.flywaydb.commandline;

import com.google.gson.Gson;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import lombok.AccessLevel;
import lombok.Cleanup;
import lombok.CustomLog;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.flywaydb.core.api.MigrationVersion;
import org.flywaydb.core.internal.license.VersionPrinter;
import org.flywaydb.core.internal.util.FlywayDbWebsiteLinks;

import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.URL;

@CustomLog
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MavenVersionChecker {
private static class MavenResponse {
public MavenDoc[] docs;
}

private static class MavenDoc {
public String latestVersion;

// 'g' is the key for the group id in the Maven REST API
public String g;
@Setter
@Getter
@NoArgsConstructor
private static class MavenVersioning {
private String release;
}

private static class MavenObject {
public MavenResponse response;
@Setter
@Getter
@NoArgsConstructor
private static class MavenMetadata {
private MavenVersioning versioning;
}

private static final String FLYWAY_URL = "https://search.maven.org/solrsearch/select?q=a:flyway-core";
private static final String FLYWAY_URL =

private static boolean canConnectToMaven() {
try {
InetAddress address = InetAddress.getByName("maven.org");
return address.isReachable(500);
} catch (Exception e) {
return false;
}
}
"https://repo1.maven.org/maven2/org/flywaydb/flyway-core/maven-metadata.xml";

public static void checkForVersionUpdates() {
if (!canConnectToMaven()) {
return;
}

try {
URL url = new URL(FLYWAY_URL);
@Cleanup(value = "disconnect") HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(1000);

StringBuilder response = new StringBuilder();

try (BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line;
while ((line = rd.readLine()) != null) {
response.append(line).append('\r');
}
}

MavenObject obj = new Gson().fromJson(response.toString(), MavenObject.class);

public static void checkForVersionUpdates() {
try {
MigrationVersion current = MigrationVersion.fromVersion(VersionPrinter.getVersion());
MigrationVersion latest = null;

String groupID = "org.flywaydb";

MavenMetadata metadata = new XmlMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.readValue(new URL(FLYWAY_URL), MavenMetadata.class);



MavenDoc[] mavenDocs = obj.response.docs;
for (MavenDoc mavenDoc : mavenDocs) {
if (mavenDoc.g.equals(groupID)) {
latest = MigrationVersion.fromVersion(mavenDoc.latestVersion);
break;
}
}
MigrationVersion latest = MigrationVersion.fromVersion(metadata.getVersioning().getRelease());

if (current.compareTo(latest) < 0) {
LOG.warn("This version of Flyway is out of date. Upgrade to Flyway " + latest + ": "
+ FlywayDbWebsiteLinks.STAYING_UP_TO_DATE + "\n");
}
} catch (Exception ignored) {
} catch (Exception e) {
LOG.debug("Unable to check for updates: " + e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,26 @@ public Configuration getConfiguration(CommandLineArguments commandLineArguments)
ConfigurationModel config = TomlUtils.loadConfigurationFiles(existingFiles, workingDirectory);

ConfigurationModel commandLineArgumentsModel = TomlUtils.loadConfigurationFromCommandlineArgs(commandLineArguments.getConfiguration());
config = config.merge(TomlUtils.loadConfigurationFromEnvironment())
ConfigurationModel environmentVariablesModel = TomlUtils.loadConfigurationFromEnvironment();
config = config.merge(environmentVariablesModel)
.merge(commandLineArgumentsModel);

if (commandLineArgumentsModel.getEnvironments().containsKey(ClassicConfiguration.TEMP_ENVIRONMENT_NAME)) {
if (commandLineArgumentsModel.getEnvironments().containsKey(ClassicConfiguration.TEMP_ENVIRONMENT_NAME) ||
environmentVariablesModel.getEnvironments().containsKey(ClassicConfiguration.TEMP_ENVIRONMENT_NAME)) {
EnvironmentModel defaultEnv = config.getEnvironments().get(config.getFlyway().getEnvironment());
config.getEnvironments().put(config.getFlyway().getEnvironment(), defaultEnv.merge(commandLineArgumentsModel.getEnvironments().get(ClassicConfiguration.TEMP_ENVIRONMENT_NAME)));

if (environmentVariablesModel.getEnvironments().containsKey(ClassicConfiguration.TEMP_ENVIRONMENT_NAME)) {
config.getEnvironments().put(config.getFlyway().getEnvironment(), defaultEnv.merge(environmentVariablesModel.getEnvironments().get(ClassicConfiguration.TEMP_ENVIRONMENT_NAME)));
}

if (commandLineArgumentsModel.getEnvironments().containsKey(ClassicConfiguration.TEMP_ENVIRONMENT_NAME)) {
config.getEnvironments().put(config.getFlyway().getEnvironment(), defaultEnv.merge(commandLineArgumentsModel.getEnvironments().get(ClassicConfiguration.TEMP_ENVIRONMENT_NAME)));
}

config.getEnvironments().remove(ClassicConfiguration.TEMP_ENVIRONMENT_NAME);
}


config.getFlyway().getLocations().add("filesystem:" + new File(workingDirectory, "sql").getAbsolutePath());

List<String> jarDirs = new ArrayList<>();
Expand Down Expand Up @@ -103,7 +115,7 @@ public Configuration getConfiguration(CommandLineArguments commandLineArguments)
}
try {
ConfigurationExtension newConfigurationExtension = objectMapper.convertValue(values, configurationExtension.getClass());
MergeUtils.mergeModel(configurationExtension, newConfigurationExtension);
MergeUtils.mergeModel(newConfigurationExtension, configurationExtension);
} catch (IllegalArgumentException e) {
Matcher matcher = ANY_WORD_BETWEEN_TWO_QUOTES_PATTERN.matcher(e.getMessage());
if (matcher.find()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.flywaydb.core.api.FlywayException;
import org.flywaydb.core.api.configuration.ClassicConfiguration;
import org.flywaydb.core.api.configuration.Configuration;
import org.flywaydb.core.api.output.InfoOutput;
import org.flywaydb.core.extensibility.RgDomainChecker;
import org.flywaydb.core.extensibility.RootTelemetryModel;
import org.flywaydb.core.internal.configuration.models.ConfigurationModel;
import org.flywaydb.core.internal.database.base.Database;
import org.flywaydb.core.internal.jdbc.JdbcConnectionFactory;
import org.flywaydb.core.internal.license.VersionPrinter;
Expand All @@ -32,19 +34,31 @@
import java.util.Comparator;
import java.util.List;

import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class TelemetryUtils {

public static RootTelemetryModel populateRootTelemetry(RootTelemetryModel rootTelemetryModel, Configuration configuration, boolean isRedgateEmployee) {
rootTelemetryModel.setRedgateEmployee(isRedgateEmployee);

if(configuration != null) {
if (configuration != null) {
ClassicConfiguration classicConfiguration = new ClassicConfiguration(configuration);
if (classicConfiguration.getDataSource() != null) {
try (JdbcConnectionFactory jdbcConnectionFactory = new JdbcConnectionFactory(classicConfiguration.getDataSource(), classicConfiguration, null);
Database database = jdbcConnectionFactory.getDatabaseType().createDatabase(configuration, false, jdbcConnectionFactory, null)) {
rootTelemetryModel.setDatabaseEngine(database.getDatabaseType().getName());
rootTelemetryModel.setDatabaseVersion(database.getVersion().toString());
ConfigurationModel modernConfig = configuration.getModernConfig();
if (modernConfig != null) {
if (StringUtils.hasText(modernConfig.getId())) {
String hashedProjectId = hashProjectId(modernConfig.getId());
rootTelemetryModel.setProjectId(hashedProjectId);
}
}
return rootTelemetryModel;
}
}
Expand All @@ -55,14 +69,32 @@ public static RootTelemetryModel populateRootTelemetry(RootTelemetryModel rootTe
return rootTelemetryModel;
}

public static boolean isRedgateEmployee(PluginRegister pluginRegister, Configuration configuration) {
RgDomainChecker domainChecker = pluginRegister.getPlugin(RgDomainChecker.class);
if (domainChecker == null) {
return false;
}
return domainChecker.isInDomain(configuration);
static String hashProjectId(String projectId) {
if (projectId == null) {
return null;
}
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(projectId.getBytes(StandardCharsets.UTF_8));
byte[] hash = md.digest("fur".getBytes(StandardCharsets.UTF_8));
BigInteger number = new BigInteger(1, hash);
String result = number.toString(16);
while (result.length() < 64) {
result = "0" + result;
}
return result;
} catch (Exception e) {
throw new FlywayException(e);
}
}

public static boolean isRedgateEmployee(PluginRegister pluginRegister, Configuration configuration) {
RgDomainChecker domainChecker = pluginRegister.getPlugin(RgDomainChecker.class);
if (domainChecker == null) {
return false;
}
return domainChecker.isInDomain(configuration);
}

/**
* @param infos a List of InfoOutput
Expand All @@ -81,7 +113,6 @@ public static String getOldestMigration(List<InfoOutput> infos) {
infos.stream().filter(output -> StringUtils.hasText(output.installedOnUTC))
.forEach(output -> migrationDates.add(output.installedOnUTC));


if (!migrationDates.isEmpty()) {
migrationDates.sort(Comparator.naturalOrder());
return migrationDates.get(0);
Expand Down
2 changes: 1 addition & 1 deletion flyway-community-db-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-parent</artifactId>
<version>9.20.0</version>
<version>9.20.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 1 addition & 3 deletions flyway-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-parent</artifactId>
<version>9.20.0</version>
<version>9.20.1</version>
</parent>
<artifactId>flyway-core</artifactId>
<packaging>jar</packaging>
Expand Down Expand Up @@ -52,8 +52,6 @@
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-toml</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
Expand Down
Loading

0 comments on commit 9abeef6

Please sign in to comment.