Skip to content

Commit

Permalink
Add a field to the network service proto containing supported SSL ver…
Browse files Browse the repository at this point in the history
…sion. This information is used in the heuristic that defines if a web service uses SSL or not.

PiperOrigin-RevId: 591821277
Change-Id: I1a9b6ac2a67fee1edbe82489b1132d731dcde150
  • Loading branch information
tooryx authored and copybara-github committed Dec 18, 2023
1 parent 440bc4d commit 55aa697
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ public static boolean isWebService(NetworkService networkService) {

public static boolean isPlainHttp(NetworkService networkService) {
checkNotNull(networkService);
return isWebService(networkService)
&& IS_PLAIN_HTTP_BY_KNOWN_WEB_SERVICE_NAME.getOrDefault(
var isKnownPlainHttpService =
IS_PLAIN_HTTP_BY_KNOWN_WEB_SERVICE_NAME.getOrDefault(
Ascii.toLowerCase(networkService.getServiceName()), false);
var doesNotSupportAnySslVersion = networkService.getSupportedSslVersionsCount() == 0;
return isWebService(networkService) && isKnownPlainHttpService && doesNotSupportAnySslVersion;
}

public static String getServiceName(NetworkService networkService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ public void isPlainHttp_whenNonWebService_returnsFalse() {
.isFalse();
}

@Test
public void isPlainHttp_whenHttpServiceButHasSslVersions_returnsFalse() {
assertThat(
NetworkServiceUtils.isPlainHttp(
NetworkService.newBuilder()
.setServiceName("http")
.addSupportedSslVersions("SSLV3")
.build()))
.isFalse();
}

@Test
public void getServiceName_whenNonWebService_returnsServiceName() {
assertThat(
Expand Down
3 changes: 2 additions & 1 deletion proto/network_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ message NetworkService {
// in the uri binding representation, like: cpe:/a:openbsd:openssh:8.4p1
repeated string cpes = 8;

// TODO(magl): add ssl related information.
// List of supported SSL versions (e.g. TLSv1, SSLv3, ...) on the service.
repeated string supported_ssl_versions = 9;
}

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

0 comments on commit 55aa697

Please sign in to comment.