Skip to content

Commit

Permalink
Coalesce nullable string values in usage data to "NULL" strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner committed Apr 19, 2021
1 parent ec84e09 commit a501b8c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('CoreUsageDataService', () => {
"disableEmbedding": false,
"permissionsPolicyConfigured": false,
"referrerPolicy": "no-referrer-when-downgrade",
"strictTransportSecurity": null,
"strictTransportSecurity": "NULL",
"xContentTypeOptions": "nosniff",
},
"socketTimeout": 120000,
Expand Down
7 changes: 4 additions & 3 deletions src/core/server/core_usage_data/core_usage_data_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,10 @@ export class CoreUsageDataService implements CoreService<CoreUsageDataSetup, Cor
truststoreConfigured: isConfigured.record(http.ssl.truststore),
},
securityResponseHeaders: {
strictTransportSecurity: http.securityResponseHeaders.strictTransportSecurity,
xContentTypeOptions: http.securityResponseHeaders.xContentTypeOptions,
referrerPolicy: http.securityResponseHeaders.referrerPolicy,
// ES does not index `null` and it cannot be searched, so we coalesce these to string values instead
strictTransportSecurity: http.securityResponseHeaders.strictTransportSecurity ?? 'NULL',
xContentTypeOptions: http.securityResponseHeaders.xContentTypeOptions ?? 'NULL',
referrerPolicy: http.securityResponseHeaders.referrerPolicy ?? 'NULL',
permissionsPolicyConfigured: isConfigured.string(
http.securityResponseHeaders.permissionsPolicy ?? undefined
),
Expand Down
6 changes: 3 additions & 3 deletions src/core/server/core_usage_data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ export interface CoreConfigUsageData {
clientAuthentication: 'none' | 'optional' | 'required';
};
securityResponseHeaders: {
strictTransportSecurity: string | null;
xContentTypeOptions: string | null;
referrerPolicy: string | null;
strictTransportSecurity: string;
xContentTypeOptions: string;
referrerPolicy: string;
permissionsPolicyConfigured: boolean;
disableEmbedding: boolean;
};
Expand Down

0 comments on commit a501b8c

Please sign in to comment.