Skip to content

Commit

Permalink
Add a field to the network service proto of Tsunami to keep track of …
Browse files Browse the repository at this point in the history
…supported HTTP methods.

PiperOrigin-RevId: 591823049
Change-Id: I81dc68aa44023248538ecde5fa5f73fb96b9ff89
  • Loading branch information
tooryx authored and copybara-github committed Dec 18, 2023
1 parent 55aa697 commit 7cf51a4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public static boolean isWebService(Optional<String> serviceName) {

public static boolean isWebService(NetworkService networkService) {
checkNotNull(networkService);
return isWebService(Optional.of(networkService.getServiceName()));
// A web-service is a service that is either flagged as http by nmap or one that supports at
// least one HTTP method.
return (networkService.getSupportedHttpMethodsCount() > 0)
|| isWebService(Optional.of(networkService.getServiceName()));
}

public static boolean isPlainHttp(NetworkService networkService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ public void isWebService_whenCapitalizedHttpService_ignoresCaseAndReturnsTrue()
.isTrue();
}

@Test
public void isWebService_whenHasAtLeastOneHttpMethod_returnsTrue() {
assertThat(
NetworkServiceUtils.isWebService(
NetworkService.newBuilder()
.setServiceName("irrelevantService")
.addSupportedHttpMethods("IrrelevantMethodName")
.build()))
.isTrue();
}

@Test
public void isWebService_whenNonWebService_returnsFalse() {
assertThat(
Expand Down
3 changes: 3 additions & 0 deletions proto/network_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ message NetworkService {

// List of supported SSL versions (e.g. TLSv1, SSLv3, ...) on the service.
repeated string supported_ssl_versions = 9;

// List of supported HTTP methods (e.g. POST, GET, ...) on the service.
repeated string supported_http_methods = 10;
}

// Context information about a specific network service.
Expand Down

0 comments on commit 7cf51a4

Please sign in to comment.