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

remove: used tooling - spotbugs #677

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,3 @@ CREDENTIAL_ROOT=/path/to/credhub/repo/plus/src/test/resources ./scripts/run_test

Assuming it works, that will generate some test client certificates for testing mutual TLS (in `certs/` in the acceptance test directory) and run the acceptance test suite against your locally running credhub server.

#### Setting up FindBugs in Intellij

1. Goto Preferences -> Plugins
1. Search for and install FindBugs
1. Goto Preferences -> Other Settings -> FindBugs-IDEA
1. Click on import button and import config/findbugs/findbugs-idea.xml
1. Click `+` under `Plugins` and select `Find Security Bugs`
1. Click on filters
1. Click `+` under `Exclude filter files` and select config/findbugs/findbugs-filter.xml

1 change: 0 additions & 1 deletion applications/credhub-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ apply plugin: 'spring-cloud-contract'
apply from: "${rootDir.toPath()}/spring-cloud-contract-config.gradle"
apply from: "${rootDir.toPath()}/kotlin.gradle"
apply from: "${rootDir.toPath()}/ktlint.gradle"
apply from: "${rootDir.toPath()}/spotbugs.gradle"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.utils.AuthConstants;
import org.cloudfoundry.credhub.CertificateStringConstants;
import org.cloudfoundry.credhub.CredHubApp;
Expand Down Expand Up @@ -44,10 +43,6 @@
@ActiveProfiles(value = "unit-test", resolver = DatabaseProfileResolver.class)
@SpringBootTest(classes = CredHubApp.class)
@Transactional
@SuppressFBWarnings(
value = "SS_SHOULD_BE_STATIC",
justification = "Test files generally don't need static fields."
)
public class AuthConfigurationTest {

private final String dataApiPath = "/api/v1/data";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.cloudfoundry.credhub.config;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.FlywayException;
import org.junit.Before;
Expand All @@ -23,7 +22,6 @@ public class FlywayMigrationStrategyConfigurationTest {
private ResultSet mockResultSetLegacyTable;
private ResultSet mockResultSetNewTable;

@SuppressFBWarnings(value = {"OBL_UNSATISFIED_OBLIGATION"}, justification = "Ignore that database objects/resources might fail to be cleaned up as they are just mocks")
@Before
public void setUp() throws Exception {
instanceToTest = spy(FlywayMigrationStrategyConfiguration.class);
Expand Down
1 change: 0 additions & 1 deletion backends/credhub/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ apply from: "${rootDir.toPath()}/kotlin.gradle"
apply from: "${rootDir.toPath()}/ktlint.gradle"
apply from: "${rootDir.toPath()}/checkstyle-config.gradle"
apply from: "${rootDir.toPath()}/pmd-config.gradle"
apply from: "${rootDir.toPath()}/spotbugs.gradle"
apply plugin: "com.google.protobuf"

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.cloudfoundry.credhub.regenerate

import com.fasterxml.jackson.databind.JsonNode
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import org.cloudfoundry.credhub.ErrorMessages
import org.cloudfoundry.credhub.PermissionOperation
import org.cloudfoundry.credhub.PermissionOperation.READ
Expand All @@ -26,10 +25,6 @@ import org.springframework.context.annotation.Profile
import org.springframework.stereotype.Service
import java.util.TreeSet

@SuppressFBWarnings(
value = ["NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"],
justification = "This will be refactored into safer non-nullable types"
)
@Service
@Profile("!remote")
class DefaultRegenerateHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.CredhubTestApp;
import org.cloudfoundry.credhub.domain.UserCredentialVersion;
import org.cloudfoundry.credhub.entities.EncryptionKeyCanary;
Expand All @@ -32,10 +31,6 @@
@RunWith(SpringRunner.class)
@ActiveProfiles(value = {"unit-test", }, resolver = DatabaseProfileResolver.class)
@SpringBootTest(classes = CredhubTestApp.class)
@SuppressFBWarnings(
value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
justification = "Let's refactor this class into kotlin"
)
public class UserSaltMigrationTest {
@Autowired
private Flyway flyway;
Expand All @@ -48,13 +43,6 @@ public class UserSaltMigrationTest {
private String databaseName;
private List<EncryptionKeyCanary> canaries;

@SuppressFBWarnings(
value = {
"NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
"ODR_OPEN_DATABASE_RESOURCE",
},
justification = "Ignore that jdbcTemplate methods might return null or that the DB connection may be left open."
)
@Before
public void beforeEach() throws Exception {
canaries = encryptionKeyCanaryRepository.findAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.List;
import java.util.UUID;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider;
import org.cloudfoundry.credhub.ErrorMessages;
import org.cloudfoundry.credhub.PermissionOperation;
Expand Down Expand Up @@ -66,7 +65,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@SuppressFBWarnings
public class DefaultCertificatesHandlerTest {

private static final String CREDENTIAL_NAME = "/test/credential";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.List;
import java.util.UUID;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.ErrorMessages;
import org.cloudfoundry.credhub.PermissionOperation;
import org.cloudfoundry.credhub.TestHelper;
Expand Down Expand Up @@ -72,7 +71,6 @@
import static org.mockito.Mockito.when;

@RunWith(JUnit4.class)
@SuppressFBWarnings
public class DefaultCredentialsHandlerTest {
private static final String CREDENTIAL_NAME = "/test/credential";
private static final Instant VERSION1_CREATED_AT = Instant.ofEpochMilli(555555555);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.CredhubTestApp;
import org.cloudfoundry.credhub.data.CertificateMigration;
import org.cloudfoundry.credhub.entity.CertificateCredentialVersionData;
Expand All @@ -35,7 +34,6 @@
)
@SpringBootTest(classes = CredhubTestApp.class)
@Transactional
@SuppressFBWarnings
public class CertificateMigrationTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.CredhubTestApp;
import org.cloudfoundry.credhub.PermissionOperation;
import org.cloudfoundry.credhub.helpers.JsonTestHelper;
Expand Down Expand Up @@ -58,10 +57,6 @@
)
@SpringBootTest(classes = CredhubTestApp.class)
@Transactional
@SuppressFBWarnings(
value = "SS_SHOULD_BE_STATIC",
justification = "Test files generally don't need static fields."
)
public class CredentialFindTest {

private final String credentialName = "/my-namespace/subTree/credential-name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.CredhubTestApp;
import org.cloudfoundry.credhub.data.EncryptionKeyCanaryDataService;
import org.cloudfoundry.credhub.domain.Encryptor;
Expand Down Expand Up @@ -68,10 +67,6 @@
)
@SpringBootTest(classes = CredhubTestApp.class)
@Transactional
@SuppressFBWarnings(
value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
justification = "Let's refactor this class into kotlin"
)
public class CredentialRegenerateTest {
private static final Instant FROZEN_TIME = Instant.ofEpochSecond(1400011001L);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.CredhubTestApp;
import org.cloudfoundry.credhub.ErrorMessages;
import org.cloudfoundry.credhub.utils.DatabaseProfileResolver;
Expand All @@ -40,10 +39,6 @@
@ActiveProfiles(value = "unit-test", resolver = DatabaseProfileResolver.class)
@SpringBootTest(classes = CredhubTestApp.class)
@Transactional
@SuppressFBWarnings(
value = "SS_SHOULD_BE_STATIC",
justification = "Test files generally don't need static fields."
)
public class CredentialSetErrorHandlingTest {

private final String CREDENTIAL_NAME = "/my-namespace/secretForErrorHandlingSetTest/credential-name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.springframework.web.context.WebApplicationContext;

import com.fasterxml.jackson.databind.ObjectMapper;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.CredhubTestApp;
import org.cloudfoundry.credhub.config.EncryptionKeyMetadata;
import org.cloudfoundry.credhub.config.EncryptionKeyProvider;
Expand Down Expand Up @@ -75,13 +74,6 @@
@SpringBootTest(classes = CredhubTestApp.class)
@RunWith(SpringRunner.class)
@Transactional
@SuppressFBWarnings(
value = {
"SS_SHOULD_BE_STATIC",
"NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
},
justification = "Test files generally don't need static fields."
)
public class EncryptionKeyRotatorTest {

private final String passwordName = "/test-password";
Expand Down Expand Up @@ -389,10 +381,6 @@ private void createCredentialWithOriginalKey() {
credentialVersionDataService.save(credentialWithCurrentKey);
}

@SuppressFBWarnings(
value = "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT",
justification = "False positive - leave mockito settings alone"
)
private void setActiveKey(final int index) throws Exception {
final List<EncryptionKeyMetadata> keys = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.CredhubTestApp;
import org.cloudfoundry.credhub.domain.Encryptor;
import org.cloudfoundry.credhub.domain.ValueCredentialVersion;
Expand Down Expand Up @@ -39,10 +38,6 @@
)
@Transactional
@TestPropertySource(properties = "security.authorization.acls.enabled=true")
@SuppressFBWarnings(
value = "SS_SHOULD_BE_STATIC",
justification = "Test files generally don't need static fields."
)
public class LegacyCredentialTest {
private final String CREDENTIAL_NAME = "/some-cred";
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.CredhubTestApp;
import org.cloudfoundry.credhub.ErrorMessages;
import org.cloudfoundry.credhub.PermissionOperation;
Expand Down Expand Up @@ -68,7 +67,6 @@
@TestPropertySource(properties = {"certificates.concatenate_cas=false", })
@SpringBootTest(classes = CredhubTestApp.class)
@Transactional
@SuppressFBWarnings
public class CredentialsGetIntegrationTest {

private static final Instant FROZEN_TIME = Instant.ofEpochSecond(1400011001L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.cloudfoundry.credhub.CredhubTestApp;
import org.cloudfoundry.credhub.domain.JsonCredentialVersion;
import org.cloudfoundry.credhub.domain.ValueCredentialVersion;
Expand Down Expand Up @@ -104,10 +103,6 @@ public void POST_replacesTheCredHubRefWithTheCredentialValue() throws Exception
.value(equalTo("secret2-value")));
}

@SuppressFBWarnings(
value = "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT",
justification = "False positive - leave mockito settings alone"
)
@Test
public void POST_whenAReferencedCredentialIsNotJsonType_throwsAnError() throws Exception {
final ValueCredentialVersion valueCredential = mock(ValueCredentialVersion.class);
Expand Down
1 change: 0 additions & 1 deletion backends/remote/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ apply from: "${rootDir.toPath()}/kotlin.gradle"
apply from: "${rootDir.toPath()}/ktlint.gradle"
apply from: "${rootDir.toPath()}/checkstyle-config.gradle"
apply from: "${rootDir.toPath()}/pmd-config.gradle"
apply from: "${rootDir.toPath()}/spotbugs.gradle"

repositories {
mavenCentral()
Expand Down
1 change: 0 additions & 1 deletion backends/shared-backend-configuration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ apply from: "${rootDir.toPath()}/kotlin.gradle"
apply from: "${rootDir.toPath()}/ktlint.gradle"
apply from: "${rootDir.toPath()}/checkstyle-config.gradle"
apply from: "${rootDir.toPath()}/pmd-config.gradle"
apply from: "${rootDir.toPath()}/spotbugs.gradle"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package db.migration.common

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import org.cloudfoundry.credhub.utils.UuidUtil
import org.flywaydb.core.api.migration.BaseJavaMigration
import org.flywaydb.core.api.migration.Context
Expand All @@ -10,7 +9,6 @@ import java.sql.Types
import java.util.UUID

class V20_1__set_uuid_in_encryption_key_canary : BaseJavaMigration() {
@SuppressFBWarnings(value = ["NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"], justification = "The database will definitely exist")
@Throws(Exception::class)
override fun migrate(context: Context) {
val jdbcTemplate = JdbcTemplate(SingleConnectionDataSource(context.connection, true))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package db.migration.common

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import org.cloudfoundry.credhub.utils.UuidUtil
import org.flywaydb.core.api.migration.BaseJavaMigration
import org.flywaydb.core.api.migration.Context
Expand All @@ -9,7 +8,6 @@ import org.springframework.jdbc.datasource.SingleConnectionDataSource
import java.sql.Types

class V25_1__add_secret_name_relation : BaseJavaMigration() {
@SuppressFBWarnings(value = ["NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"], justification = "The database will definitely exist")
@Throws(Exception::class)
override fun migrate(context: Context) {
val jdbcTemplate = JdbcTemplate(SingleConnectionDataSource(context.connection, true))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package db.migration.common

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import org.cloudfoundry.credhub.utils.UuidUtil
import org.flywaydb.core.api.migration.BaseJavaMigration
import org.flywaydb.core.api.migration.Context
Expand All @@ -9,7 +8,6 @@ import org.springframework.jdbc.datasource.SingleConnectionDataSource
import java.sql.Types

class V35_1__migrate_operation_audit_record_table : BaseJavaMigration() {
@SuppressFBWarnings(value = ["NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"], justification = "The database will definitely exist")
@Throws(Exception::class)
override fun migrate(context: Context) {
val jdbcTemplate = JdbcTemplate(SingleConnectionDataSource(context.connection, true))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package db.migration.common

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import org.cloudfoundry.credhub.CryptSaltFactory
import org.cloudfoundry.credhub.utils.UuidUtil
import org.flywaydb.core.api.migration.BaseJavaMigration
Expand All @@ -13,7 +12,6 @@ import java.sql.ResultSet
import java.util.UUID

class V41_1__set_salt_in_existing_user_credentials : BaseJavaMigration() {
@SuppressFBWarnings(value = ["NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"], justification = "The database will definitely exist")
@Throws(Exception::class)
override fun migrate(context: Context) {
val jdbcTemplate = JdbcTemplate(SingleConnectionDataSource(context.connection, true))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package db.migration.common

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import org.cloudfoundry.credhub.utils.UuidUtil
import org.flywaydb.core.api.migration.BaseJavaMigration
import org.flywaydb.core.api.migration.Context
Expand All @@ -9,7 +8,6 @@ import org.springframework.jdbc.datasource.SingleConnectionDataSource
import java.sql.Types

class V44_2__migrate_encypted_values_to_encryped_value_table : BaseJavaMigration() {
@SuppressFBWarnings(value = ["NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"], justification = "The database will definitely exist")
@Throws(Exception::class)
override fun migrate(context: Context) {
val jdbcTemplate = JdbcTemplate(SingleConnectionDataSource(context.connection, true))
Expand Down
Loading