Skip to content

Commit

Permalink
Whitelist full agent config output fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang committed Mar 4, 2020
1 parent 8e9ae8c commit 01d1c61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export type FullAgentConfigDatasource = Pick<Datasource, 'name' | 'namespace' |
export interface FullAgentConfig {
id: string;
outputs: {
[key: string]: Omit<Output, 'is_default' | 'config' | 'name' | 'id'> & {
[key: string]: Pick<Output, 'type' | 'hosts' | 'ca_sha256' | 'api_key'> & {
[key: string]: any;
};
};
Expand Down
12 changes: 7 additions & 5 deletions x-pack/plugins/ingest_manager/server/services/agent_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,20 +302,22 @@ class AgentConfigService {
return null;
}

const agentConfig = {
const agentConfig: FullAgentConfig = {
id: config.id,
outputs: {
// TEMPORARY as we only support a default output
...[
await outputService.get(soClient, await outputService.getDefaultOutputId(soClient)),
].reduce((outputs, { config: outputConfig, is_default, name, id: outputId, ...output }) => {
].reduce((outputs, { config: outputConfig, name, type, hosts, ca_sha256, api_key }) => {
outputs[name] = {
...output,
type: output.type as any,
type,
hosts,
ca_sha256,
api_key,
...outputConfig,
};
return outputs;
}, {} as any),
}, {} as FullAgentConfig['outputs']),
},
datasources: (config.datasources as Datasource[]).map(ds =>
this.storedDatasourceToAgentDatasource(ds)
Expand Down

0 comments on commit 01d1c61

Please sign in to comment.