Skip to content

Commit 7cf51a4

Browse files
tooryxcopybara-github
authored andcommitted
Add a field to the network service proto of Tsunami to keep track of supported HTTP methods.
PiperOrigin-RevId: 591823049 Change-Id: I81dc68aa44023248538ecde5fa5f73fb96b9ff89
1 parent 55aa697 commit 7cf51a4

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

common/src/main/java/com/google/tsunami/common/data/NetworkServiceUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ public static boolean isWebService(Optional<String> serviceName) {
6868

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

7477
public static boolean isPlainHttp(NetworkService networkService) {

common/src/test/java/com/google/tsunami/common/data/NetworkServiceUtilsTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ public void isWebService_whenCapitalizedHttpService_ignoresCaseAndReturnsTrue()
105105
.isTrue();
106106
}
107107

108+
@Test
109+
public void isWebService_whenHasAtLeastOneHttpMethod_returnsTrue() {
110+
assertThat(
111+
NetworkServiceUtils.isWebService(
112+
NetworkService.newBuilder()
113+
.setServiceName("irrelevantService")
114+
.addSupportedHttpMethods("IrrelevantMethodName")
115+
.build()))
116+
.isTrue();
117+
}
118+
108119
@Test
109120
public void isWebService_whenNonWebService_returnsFalse() {
110121
assertThat(

proto/network_service.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ message NetworkService {
5858

5959
// List of supported SSL versions (e.g. TLSv1, SSLv3, ...) on the service.
6060
repeated string supported_ssl_versions = 9;
61+
62+
// List of supported HTTP methods (e.g. POST, GET, ...) on the service.
63+
repeated string supported_http_methods = 10;
6164
}
6265

6366
// Context information about a specific network service.

0 commit comments

Comments
 (0)