diff --git a/pom.xml b/pom.xml
index c5a1f6893..f9393e163 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,7 +61,6 @@
4.3.1
4.1.65.Final
1.2.0
- 42.3.3
3.19.4
0.15.1
1.5.0
@@ -224,12 +223,6 @@
${opentest4j.version}
test
-
- org.postgresql
- postgresql
- ${postgresql.version}
- runtime
-
org.slf4j
slf4j-api
@@ -278,13 +271,6 @@
libsignal-server
0.16.0
-
- io.zonky.test.postgres
- embedded-postgres-binaries-bom
- 11.13.0
- pom
- import
-
org.apache.logging.log4j
log4j-bom
diff --git a/service/config/sample.yml b/service/config/sample.yml
index faf683410..26b0f34fc 100644
--- a/service/config/sample.yml
+++ b/service/config/sample.yml
@@ -185,12 +185,6 @@ gcpAttachments: # GCP Storage configuration
AAAAAAAA
-----END PRIVATE KEY-----
-abuseDatabase: # Postgresql database configuration
- driverClass: org.postgresql.Driver
- user: example
- password: password
- url: jdbc:postgresql://example.com:5432/abusedb
-
accountDatabaseCrawler:
chunkSize: 10 # accounts per run
chunkIntervalMs: 60000 # time per run
diff --git a/service/pom.xml b/service/pom.xml
index 5f9ddaada..7088e27d2 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -128,11 +128,6 @@
jdbi3-core
-
- org.liquibase
- liquibase-core
-
-
io.dropwizard.metrics
metrics-core
@@ -305,12 +300,6 @@
lettuce-core
-
- org.postgresql
- postgresql
- runtime
-
-
com.eatthepath
pushy
@@ -372,13 +361,6 @@
-
- io.zonky.test
- embedded-postgres
- 1.3.1
- test
-
-
com.almworks.sqlite4java
sqlite4java
diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java
index 54d86ba31..3d76a4f99 100644
--- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java
+++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java
@@ -143,11 +143,6 @@ public class WhisperServerConfiguration extends Configuration {
@JsonProperty
private RedisClusterConfiguration clientPresenceCluster;
- @Valid
- @NotNull
- @JsonProperty
- private DatabaseConfiguration abuseDatabase;
-
@Valid
@NotNull
@JsonProperty
@@ -337,10 +332,6 @@ public class WhisperServerConfiguration extends Configuration {
return rateLimitersCluster;
}
- public DatabaseConfiguration getAbuseDatabaseConfiguration() {
- return abuseDatabase;
- }
-
public RateLimitsConfiguration getLimitsConfiguration() {
return limits;
}
diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java
index 5b89060c0..124a48a32 100644
--- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java
+++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java
@@ -114,7 +114,6 @@ import org.whispersystems.textsecuregcm.limits.PushChallengeManager;
import org.whispersystems.textsecuregcm.limits.RateLimitChallengeManager;
import org.whispersystems.textsecuregcm.limits.RateLimitChallengeOptionManager;
import org.whispersystems.textsecuregcm.limits.RateLimiters;
-import org.whispersystems.textsecuregcm.liquibase.NameableMigrationsBundle;
import org.whispersystems.textsecuregcm.mappers.CompletionExceptionMapper;
import org.whispersystems.textsecuregcm.mappers.DeviceLimitExceededExceptionMapper;
import org.whispersystems.textsecuregcm.mappers.IOExceptionMapper;
@@ -244,13 +243,6 @@ public class WhisperServerService extends Application("abusedb", "abusedb.xml") {
- @Override
- public PooledDataSourceFactory getDataSourceFactory(WhisperServerConfiguration configuration) {
- return configuration.getAbuseDatabaseConfiguration();
- }
- });
}
@Override
@@ -308,12 +300,6 @@ public class WhisperServerService extends Application getExperimentEnrollmentConfiguration(
final String experimentName) {
return Optional.ofNullable(experiments.get(experimentName));
@@ -117,4 +121,7 @@ public class DynamicConfiguration {
return turn;
}
+ public DynamicAbusiveHostRulesConfiguration getAbusiveHostRules() {
+ return abusiveHostRules;
+ }
}
diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java
index 5af27d312..2ae19bbe9 100644
--- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java
+++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java
@@ -82,7 +82,6 @@ import org.whispersystems.textsecuregcm.push.GcmMessage;
import org.whispersystems.textsecuregcm.recaptcha.RecaptchaClient;
import org.whispersystems.textsecuregcm.sms.SmsSender;
import org.whispersystems.textsecuregcm.sms.TwilioVerifyExperimentEnrollmentManager;
-import org.whispersystems.textsecuregcm.storage.AbusiveHostRule;
import org.whispersystems.textsecuregcm.storage.AbusiveHostRules;
import org.whispersystems.textsecuregcm.storage.Account;
import org.whispersystems.textsecuregcm.storage.AccountsManager;
@@ -108,9 +107,7 @@ public class AccountController {
private final Logger logger = LoggerFactory.getLogger(AccountController.class);
private final MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate(Constants.METRICS_NAME);
private final Meter blockedHostMeter = metricRegistry.meter(name(AccountController.class, "blocked_host" ));
- private final Meter blockedPrefixMeter = metricRegistry.meter(name(AccountController.class, "blocked_prefix" ));
private final Meter countryFilterApplicable = metricRegistry.meter(name(AccountController.class, "country_filter_applicable"));
- private final Meter filteredHostMeter = metricRegistry.meter(name(AccountController.class, "filtered_host" ));
private final Meter countryFilteredHostMeter = metricRegistry.meter(name(AccountController.class, "country_limited_host" ));
private final Meter rateLimitedHostMeter = metricRegistry.meter(name(AccountController.class, "rate_limited_host" ));
private final Meter rateLimitedPrefixMeter = metricRegistry.meter(name(AccountController.class, "rate_limited_prefix" ));
@@ -246,7 +243,7 @@ public class AccountController {
if (requirement.isAutoBlock() && shouldAutoBlock(sourceHost)) {
logger.info("Auto-block: {}", sourceHost);
- abusiveHostRules.setBlockedHost(sourceHost, "Auto-Block");
+ abusiveHostRules.setBlockedHost(sourceHost);
}
return Response.status(402).build();
@@ -780,7 +777,10 @@ public class AccountController {
DynamicCaptchaConfiguration captchaConfig = dynamicConfigurationManager.getConfiguration()
.getCaptchaConfiguration();
boolean countryFiltered = captchaConfig.getSignupCountryCodes().contains(countryCode);
- if (shouldBlock(transport, forwardedFor, sourceHost, number)) {
+
+ if (abusiveHostRules.isBlocked(sourceHost)) {
+ blockedHostMeter.mark();
+ logger.info("Blocked host: {}, {}, {} ({})", transport, number, sourceHost, forwardedFor);
if (countryFiltered) {
// this host was caught in the abusiveHostRules filter, but
// would be caught by country filter as well
@@ -813,33 +813,6 @@ public class AccountController {
return new CaptchaRequirement(false, false);
}
- private boolean shouldBlock(final String transport, final String forwardedFor, final String sourceHost, final String number) {
- List abuseRules = abusiveHostRules.getAbusiveHostRulesFor(sourceHost);
-
- for (AbusiveHostRule abuseRule : abuseRules) {
- if (abuseRule.blocked()) {
- logger.info("Blocked host: {}, {}, {} ({}) matched rule: {}", transport, number, sourceHost, forwardedFor, abuseRule.host());
-
- // did we match based on an ip block or an exact match
- if (abuseRule.cidrPrefix().filter(i -> i < 32).isPresent()) {
- blockedPrefixMeter.mark();
- } else {
- blockedHostMeter.mark();
- }
- return true;
- }
-
- if (!abuseRule.regions().isEmpty()) {
- if (abuseRule.regions().stream().noneMatch(number::startsWith)) {
- logger.info("Restricted host: {}, {}, {} ({}) matched rule: {}/{}", transport, number, sourceHost, forwardedFor, abuseRule.host(), abuseRule.regions());
- filteredHostMeter.mark();
- return true;
- }
- }
- }
- return false;
- }
-
@Timed
@DELETE
@Path("/me")
diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/liquibase/AbstractLiquibaseCommand.java b/service/src/main/java/org/whispersystems/textsecuregcm/liquibase/AbstractLiquibaseCommand.java
deleted file mode 100644
index e3de6627d..000000000
--- a/service/src/main/java/org/whispersystems/textsecuregcm/liquibase/AbstractLiquibaseCommand.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2013-2020 Signal Messenger, LLC
- * SPDX-License-Identifier: AGPL-3.0-only
- */
-
-package org.whispersystems.textsecuregcm.liquibase;
-
-import com.codahale.metrics.MetricRegistry;
-import net.sourceforge.argparse4j.inf.Namespace;
-
-import java.sql.SQLException;
-
-import io.dropwizard.Configuration;
-import io.dropwizard.cli.ConfiguredCommand;
-import io.dropwizard.db.DatabaseConfiguration;
-import io.dropwizard.db.ManagedDataSource;
-import io.dropwizard.db.PooledDataSourceFactory;
-import io.dropwizard.setup.Bootstrap;
-import liquibase.Liquibase;
-import liquibase.exception.LiquibaseException;
-import liquibase.exception.ValidationFailedException;
-
-public abstract class AbstractLiquibaseCommand extends ConfiguredCommand {
-
- private final DatabaseConfiguration strategy;
- private final Class configurationClass;
- private final String migrations;
-
- protected AbstractLiquibaseCommand(String name,
- String description,
- String migrations,
- DatabaseConfiguration strategy,
- Class configurationClass) {
- super(name, description);
- this.migrations = migrations;
- this.strategy = strategy;
- this.configurationClass = configurationClass;
- }
-
- @Override
- protected Class getConfigurationClass() {
- return configurationClass;
- }
-
- @Override
- @SuppressWarnings("UseOfSystemOutOrSystemErr")
- protected void run(Bootstrap bootstrap, Namespace namespace, T configuration) throws Exception {
- final PooledDataSourceFactory dbConfig = strategy.getDataSourceFactory(configuration);
- dbConfig.asSingleConnectionPool();
-
- try (final CloseableLiquibase liquibase = openLiquibase(dbConfig, namespace)) {
- run(namespace, liquibase);
- } catch (ValidationFailedException e) {
- e.printDescriptiveError(System.err);
- throw e;
- }
- }
-
- private CloseableLiquibase openLiquibase(final PooledDataSourceFactory dataSourceFactory, final Namespace namespace)
- throws ClassNotFoundException, SQLException, LiquibaseException
- {
- final ManagedDataSource dataSource = dataSourceFactory.build(new MetricRegistry(), "liquibase");
- return new CloseableLiquibase(dataSource, migrations);
- }
-
- protected abstract void run(Namespace namespace, Liquibase liquibase) throws Exception;
-
-}
diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/liquibase/CloseableLiquibase.java b/service/src/main/java/org/whispersystems/textsecuregcm/liquibase/CloseableLiquibase.java
deleted file mode 100644
index a377a6b63..000000000
--- a/service/src/main/java/org/whispersystems/textsecuregcm/liquibase/CloseableLiquibase.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2013-2020 Signal Messenger, LLC
- * SPDX-License-Identifier: AGPL-3.0-only
- */
-
-package org.whispersystems.textsecuregcm.liquibase;
-
-import java.sql.SQLException;
-
-import io.dropwizard.db.ManagedDataSource;
-import liquibase.Liquibase;
-import liquibase.database.jvm.JdbcConnection;
-import liquibase.exception.LiquibaseException;
-import liquibase.resource.ClassLoaderResourceAccessor;
-
-
-public class CloseableLiquibase extends Liquibase implements AutoCloseable {
- private final ManagedDataSource dataSource;
-
- public CloseableLiquibase(ManagedDataSource dataSource, String migrations)
- throws LiquibaseException, ClassNotFoundException, SQLException
- {
- super(migrations,
- new ClassLoaderResourceAccessor(),
- new JdbcConnection(dataSource.getConnection()));
- this.dataSource = dataSource;
- }
-
- @Override
- public void close() throws Exception {
- dataSource.stop();
- }
-}
diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/liquibase/DbMigrateCommand.java b/service/src/main/java/org/whispersystems/textsecuregcm/liquibase/DbMigrateCommand.java
deleted file mode 100644
index 88b9a39ab..000000000
--- a/service/src/main/java/org/whispersystems/textsecuregcm/liquibase/DbMigrateCommand.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2013-2020 Signal Messenger, LLC
- * SPDX-License-Identifier: AGPL-3.0-only
- */
-
-package org.whispersystems.textsecuregcm.liquibase;
-
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Joiner;
-import net.sourceforge.argparse4j.impl.Arguments;
-import net.sourceforge.argparse4j.inf.Namespace;
-import net.sourceforge.argparse4j.inf.Subparser;
-
-import java.io.OutputStreamWriter;
-import java.util.List;
-
-import io.dropwizard.Configuration;
-import io.dropwizard.db.DatabaseConfiguration;
-import liquibase.Liquibase;
-
-public class DbMigrateCommand extends AbstractLiquibaseCommand {
-
- public DbMigrateCommand(String migration, DatabaseConfiguration strategy, Class configurationClass) {
- super("migrate", "Apply all pending change sets.", migration, strategy, configurationClass);
- }
-
- @Override
- public void configure(Subparser subparser) {
- super.configure(subparser);
-
- subparser.addArgument("-n", "--dry-run")
- .action(Arguments.storeTrue())
- .dest("dry-run")
- .setDefault(Boolean.FALSE)
- .help("output the DDL to stdout, don't run it");
-
- subparser.addArgument("-c", "--count")
- .type(Integer.class)
- .dest("count")
- .help("only apply the next N change sets");
-
- subparser.addArgument("-i", "--include")
- .action(Arguments.append())
- .dest("contexts")
- .help("include change sets from the given context");
- }
-
- @Override
- @SuppressWarnings("UseOfSystemOutOrSystemErr")
- public void run(Namespace namespace, Liquibase liquibase) throws Exception {
- final String context = getContext(namespace);
- final Integer count = namespace.getInt("count");
- final Boolean dryRun = namespace.getBoolean("dry-run");
- if (count != null) {
- if (dryRun) {
- liquibase.update(count, context, new OutputStreamWriter(System.out, Charsets.UTF_8));
- } else {
- liquibase.update(count, context);
- }
- } else {
- if (dryRun) {
- liquibase.update(context, new OutputStreamWriter(System.out, Charsets.UTF_8));
- } else {
- liquibase.update(context);
- }
- }
- }
-
- private String getContext(Namespace namespace) {
- final List