Skip to content

Commit

Permalink
Fixed minor style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardo-doyensec committed Jan 18, 2024
1 parent b9d4851 commit 9d53673
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.common.flogger.GoogleLogger;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.google.tsunami.common.data.NetworkServiceUtils;
import com.google.tsunami.common.net.http.HttpClient;
import com.google.tsunami.common.net.http.HttpHeaders;
Expand All @@ -44,7 +45,6 @@ public final class RabbitMQCredentialTester extends CredentialTester {
private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();
private final HttpClient httpClient;

private static final String RABBITMQ_SERVICE = "rabbitmq";
private static final String RABBITMQ_PAGE_TITLE = "RabbitMQ Management";
private static final String RABBITMQ_SERVER_HEADER = "Cowboy";
private static final String RABBITMQ_WWW_HEADER = "Basic realm=\"RabbitMQ Management\"";
Expand Down Expand Up @@ -78,7 +78,7 @@ private static String buildTargetUrl(NetworkService networkService, String path)

// Checks if the response body contains the title element of rabbitmq management page.
// Custom fingerprint phase.
private static boolean bodyContainsRabbitMQElements(String responseBody) {
private static boolean bodyContainsRabbitMqElements(String responseBody) {
Document doc = Jsoup.parse(responseBody);
String title = doc.title();

Expand Down Expand Up @@ -117,7 +117,7 @@ public boolean canAccept(NetworkService networkService) {
&& response.headers().get("server").get().trim().equals(RABBITMQ_SERVER_HEADER)
&& response
.bodyString()
.map(RabbitMQCredentialTester::bodyContainsRabbitMQElements)
.map(RabbitMQCredentialTester::bodyContainsRabbitMqElements)
.orElse(false);
url = buildTargetUrl(networkService, "api/overview");
response = httpClient.send(get(url).withEmptyHeaders().build());
Expand Down Expand Up @@ -191,7 +191,7 @@ private static boolean bodyContainsSuccessfulLoginElements(String responseBody)
} else {
return false;
}
} catch (Exception e) {
} catch (JsonSyntaxException e) {
logger.atWarning().withCause(e).log(
"An error occurred while parsing the json response: %s", responseBody);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class RabbitMQCredentialTesterTest {

private static final String WEAK_CRED_AUTH_1 = "Basic dXNlcjoxMjM0";
private static final String WEAK_CRED_AUTH_2 = "Basic cm9vdDpwYXNz";
private static final ServiceContext.Builder RABBITMQ_SERVICE_CONTEXT =
private static final ServiceContext.Builder rabbitmqServiceContext =
ServiceContext.newBuilder()
.setWebServiceContext(
WebServiceContext.newBuilder()
Expand All @@ -84,7 +84,7 @@ public void detect_weakCredentialsExists_returnsWeakCredentials() throws Excepti
.setNetworkEndpoint(
forHostnameAndPort(mockWebServer.getHostName(), mockWebServer.getPort()))
.setServiceName("http")
.setServiceContext(RABBITMQ_SERVICE_CONTEXT)
.setServiceContext(rabbitmqServiceContext)
.setSoftware(Software.newBuilder().setName("http"))
.build();

Expand All @@ -105,7 +105,7 @@ public void detect_weakCredentialsExist_returnsAllWeakCredentials() throws Excep
.setNetworkEndpoint(
forHostnameAndPort(mockWebServer.getHostName(), mockWebServer.getPort()))
.setServiceName("http")
.setServiceContext(RABBITMQ_SERVICE_CONTEXT)
.setServiceContext(rabbitmqServiceContext)
.build();
assertThat(
tester.testValidCredentials(
Expand All @@ -126,7 +126,7 @@ public void detect_noWeakCredentials_returnsNoCredentials() throws Exception {
.setNetworkEndpoint(
forHostnameAndPort(mockWebServer.getHostName(), mockWebServer.getPort()))
.setServiceName("http")
.setServiceContext(RABBITMQ_SERVICE_CONTEXT)
.setServiceContext(rabbitmqServiceContext)
.build();
assertThat(tester.testValidCredentials(targetNetworkService, ImmutableList.of(WRONG_CRED_1)))
.isEmpty();
Expand Down

0 comments on commit 9d53673

Please sign in to comment.