Skip to content

Commit

Permalink
another sensitive field + improve docs and test error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Bamieh committed Jan 27, 2021
1 parent 0dd8b14 commit 141b634
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@
The Usage Collector `stack_management` reports user changed settings.
All user changed UI Settings are automatically collected.

After adding a new setting you will be required -via our usage_collection functional tests- to update the [schema](./schema.ts) of the management collector and the [UsageStats](./types.ts) interface.
After adding a new setting you will be required to do the following steps:

If you forget our telemetry check will help you through the process! You can then run the checker with `--fix` flag to automatically fix the mappings
1. Update the [schema](./schema.ts) to include the setting name and schema type.
```
export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
'MY_UI_SETTING': { type: 'keyword' },
}
```

2. Update the [UsageStats interface](./types.ts) with the setting name and typescript type.
```
export interface UsageStats {
'MY_UI_SETTING': string;
}
```
3. Run the telemetry checker with `--fix` flag to automatically fix the mappings

```
node scripts/telemetry_check --fix
```

If you forget any of the steps our telemetry tools and tests will help you through the process!

## Sensitive fields

If the configured UI setting might contain user sensitive information simply add the property `sensitive: true` to the ui setting registration config.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
'notifications:banner': { type: 'keyword' },
'timelion:graphite.url': { type: 'keyword' },
'xpackDashboardMode:roles': { type: 'keyword' },
'securitySolution:ipReputationLinks': { type: 'keyword' },
// non-sensitive
'visualize:enableLabs': { type: 'boolean' },
'visualization:heatmap:maxBuckets': { type: 'long' },
'visualization:colorMapping': { type: 'text' },
'visualization:regionmap:showWarnings': { type: 'boolean' },
'visualization:dimmingOpacity': { type: 'float' },
'visualization:tileMap:maxPrecision': { type: 'long' },
'securitySolution:ipReputationLinks': { type: 'text' },
'csv:separator': { type: 'keyword' },
'visualization:tileMap:WMSdefaults': { type: 'text' },
'timelion:target_buckets': { type: 'long' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface UsageStats {
'notifications:banner': string;
'timelion:graphite.url': string;
'xpackDashboardMode:roles': string;
'securitySolution:ipReputationLinks': string;
/**
* non-sensitive settings
*/
Expand All @@ -36,7 +37,6 @@ export interface UsageStats {
'visualization:regionmap:showWarnings': boolean;
'visualization:dimmingOpacity': number;
'visualization:tileMap:maxPrecision': number;
'securitySolution:ipReputationLinks': string;
'csv:separator': string;
'visualization:tileMap:WMSdefaults': string;
'timelion:target_buckets': number;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4116,7 +4116,7 @@
"type": "long"
},
"securitySolution:ipReputationLinks": {
"type": "text"
"type": "keyword"
},
"csv:separator": {
"type": "keyword"
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/security_solution/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export const initUiSettings = (uiSettings: CoreSetup['uiSettings']) => {
'Array of URL templates to build the list of reputation URLs to be displayed on the IP Details page.',
}
),
sensitive: true,
category: [APP_ID],
requiresPageReload: true,
schema: schema.arrayOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
.filter((key) => key !== 'buildNum')
.filter((key) => typeof _.get(stackManagementSchema, key) === 'undefined');

expect(unreportedUISettings).to.eql([]);
if (unreportedUISettings.length) {
throw new Error(
`Detected the following unregistered UI Settings in the stack management collector:
${JSON.stringify(unreportedUISettings, null)}
Update the management collector schema and its UsageStats interface.
Refer to src/plugins/kibana_usage_collection/server/collectors/management/README.md for additional information.
`
);
}
});

it('registers all sensitive UI settings as boolean type', async () => {
it('registers all sensitive UI settings as keyword type', async () => {
const sensitiveSettings = Object.entries(registeredSettings)
.filter(([, config]) => config.sensitive)
.map(([key]) => key);
Expand All @@ -39,7 +47,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
.map((key) => ({ key, ..._.get(stackManagementSchema, key) }))
.filter((keyDescriptor) => keyDescriptor.type !== 'keyword');

expect(nonBooleanSensitiveProps).to.eql([]);
if (nonBooleanSensitiveProps.length) {
throw new Error(
`Detected the following sensitive UI Settings in the stack management collector not having a 'keyword' type:
${JSON.stringify(nonBooleanSensitiveProps, null)}
Update each setting in the management collector schema with ({ type: 'keyword' }).
Refer to src/plugins/kibana_usage_collection/server/collectors/management/README.md for additional information.
`
);
}
});
});
}

0 comments on commit 141b634

Please sign in to comment.