Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…y-track#2610, DependencyTrack/dependency-track#2660

Co-authored-by: Enora Germond <enora.germond@deveryware.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
  • Loading branch information
nscuro and Enora Germond committed Apr 18, 2023
1 parent 798aff3 commit c6ba6dc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Expand Up @@ -35,9 +35,9 @@ public enum ConfigPropertyConstants {
EMAIL_SMTP_TRUSTCERT("email", "smtp.trustcert", "false", PropertyType.BOOLEAN, "Flag to enable/disable the trust of the certificate presented by the SMTP server"),
INTERNAL_COMPONENTS_GROUPS_REGEX("internal-components", "groups.regex", null, PropertyType.STRING, "Regex that matches groups of internal components"),
INTERNAL_COMPONENTS_NAMES_REGEX("internal-components", "names.regex", null, PropertyType.STRING, "Regex that matches names of internal components"),
JIRA_URL("jira", "jira.url", null, PropertyType.URL, "The base URL of the JIRA instance"),
JIRA_USERNAME("jira", "jira.username", null, PropertyType.STRING, "The optional username to authenticate with when creating an Jira issue"),
JIRA_PASSWORD("jira", "jira.password", null, PropertyType.ENCRYPTEDSTRING, "The optional password for the username used for authentication"),
JIRA_URL("integrations", "jira.url", null, PropertyType.URL, "The base URL of the JIRA instance"),
JIRA_USERNAME("integrations", "jira.username", null, PropertyType.STRING, "The optional username to authenticate with when creating an Jira issue"),
JIRA_PASSWORD("integrations", "jira.password", null, PropertyType.ENCRYPTEDSTRING, "The optional password for the username used for authentication"),
SCANNER_INTERNAL_ENABLED("scanner", "internal.enabled", "true", PropertyType.BOOLEAN, "Flag to enable/disable the internal analyzer"),
SCANNER_INTERNAL_FUZZY_ENABLED("scanner", "internal.fuzzy.enabled", "false", PropertyType.BOOLEAN, "Flag to enable/disable non-exact fuzzy matching using the internal analyzer"),
SCANNER_INTERNAL_FUZZY_EXCLUDE_PURL("scanner", "internal.fuzzy.exclude.purl", "true", PropertyType.BOOLEAN, "Flag to enable/disable fuzzy matching on components that have a Package URL (PURL) defined"),
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/org/dependencytrack/upgrade/v480/v480Updater.java
Expand Up @@ -24,6 +24,7 @@
import alpine.server.util.DbUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class v480Updater extends AbstractUpgradeItem {

Expand All @@ -36,6 +37,11 @@ public String getSchemaVersion() {

@Override
public void executeUpgrade(final AlpineQueryManager qm, final Connection connection) throws Exception {
changeJdbcTypeOfComponentAuthorColumn(connection);
setJiraPropertyValuesFromJiraToIntegrationGroup(connection);
}

private void changeJdbcTypeOfComponentAuthorColumn(Connection connection) throws Exception {
// Fixes https://github.com/DependencyTrack/dependency-track/issues/2488
// The JDBC type "CLOB" is mapped to the type CLOB for H2, MEDIUMTEXT for MySQL, and TEXT for PostgreSQL and SQL Server.
LOGGER.info("Changing JDBC type of \"COMPONENT\".\"AUTHOR\" from VARCHAR to CLOB");
Expand All @@ -56,4 +62,14 @@ public void executeUpgrade(final AlpineQueryManager qm, final Connection connect
DbUtil.executeUpdate(connection, "ALTER TABLE \"COMPONENT\" RENAME COLUMN \"AUTHOR_V48\" TO \"AUTHOR\"");
}
}
}

private void setJiraPropertyValuesFromJiraToIntegrationGroup(Connection connection) throws Exception {
LOGGER.info("Setting Jira property values from Groupname 'jira' to Groupname 'integrations'");
try (final PreparedStatement ps = connection.prepareStatement("""
UPDATE "CONFIGPROPERTY" SET "GROUPNAME" = 'integrations'
WHERE "GROUPNAME" = 'jira' AND "PROPERTYNAME" LIKE 'jira.%'
""")) {
ps.executeUpdate();
}
}
}

0 comments on commit c6ba6dc

Please sign in to comment.