Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SECURITY SOLUTION] fix name without a category or if field end with .text #78655

Merged
merged 1 commit into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,29 @@ describe('Index Fields', () => {
readFromDocValues: false,
esTypes: [],
},
{
aggregatable: true,
category: 'agent',
esTypes: [],
indexes: ['auditbeat'],
name: 'agent.user.name',
readFromDocValues: false,
searchable: true,
type: 'string',
},
{
aggregatable: true,
category: 'client',
description:
'Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet.',
esTypes: [],
example: 15169,
indexes: ['auditbeat'],
name: 'client.as.number.text',
readFromDocValues: false,
searchable: true,
type: 'string',
},
])
);
});
Expand All @@ -149,18 +172,19 @@ describe('Index Fields', () => {
);
expect(fields).toEqual([
{
category: 'base',
description: 'Each document has an _id that uniquely identifies it',
example: 'Y-6TfmcB0WOhS6qyMv3s',
name: '_id',
type: 'string',
searchable: true,
aggregatable: false,
readFromDocValues: false,
category: 'base',
indexes: ['auditbeat'],
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'base',
description:
'An index is like a ‘database’ in a relational database. It has a mapping which defines multiple types. An index is a logical namespace which maps to one or more primary shards and can have zero or more replica shards.',
example: 'auditbeat-8.0.0-2019.02.19-000001',
Expand All @@ -169,212 +193,234 @@ describe('Index Fields', () => {
searchable: true,
aggregatable: true,
readFromDocValues: false,
category: 'base',
indexes: ['auditbeat'],
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'base',
description:
'Date/time when the event originated. This is the date/time extracted from the event, typically representing when the event was generated by the source. If the event source has no original timestamp, this value is typically populated by the first time the event was received by the pipeline. Required field for all events.',
example: '2016-05-23T08:05:34.853Z',
name: '@timestamp',
type: 'date',
searchable: true,
aggregatable: true,
category: 'base',
indexes: ['auditbeat'],
readFromDocValues: true,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'agent',
description:
'Ephemeral identifier of this agent (if one exists). This id normally changes across restarts, but `agent.id` does not.',
example: '8a4f500f',
name: 'agent.ephemeral_id',
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['auditbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'agent',
description:
'Custom name of the agent. This is a name that can be given to an agent. This can be helpful if for example two Filebeat instances are running on the same host but a human readable separation is needed on which Filebeat instance data is coming from. If no name is given, the name is often left empty.',
example: 'foo',
name: 'agent.name',
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['auditbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'agent',
description:
'Type of the agent. The agent type stays always the same and should be given by the agent used. In case of Filebeat the agent would always be Filebeat also if two Filebeat instances are run on the same machine.',
example: 'filebeat',
name: 'agent.type',
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['auditbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'agent',
description: 'Version of the agent.',
example: '6.0.0-rc2',
name: 'agent.version',
type: 'string',
searchable: true,
aggregatable: true,
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'agent',
name: 'agent.user.name',
searchable: true,
type: 'string',
aggregatable: true,
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'client',
description:
'Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet.',
example: 15169,
name: 'client.as.number.text',
type: 'string',
searchable: true,
aggregatable: true,
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'base',
description: 'Each document has an _id that uniquely identifies it',
example: 'Y-6TfmcB0WOhS6qyMv3s',
name: '_id',
type: 'string',
searchable: true,
aggregatable: false,
category: 'base',
indexes: ['filebeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'base',
description:
'An index is like a ‘database’ in a relational database. It has a mapping which defines multiple types. An index is a logical namespace which maps to one or more primary shards and can have zero or more replica shards.',
example: 'auditbeat-8.0.0-2019.02.19-000001',
name: '_index',
type: 'string',
searchable: true,
aggregatable: true,
category: 'base',
indexes: ['filebeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'base',
description:
'Date/time when the event originated. This is the date/time extracted from the event, typically representing when the event was generated by the source. If the event source has no original timestamp, this value is typically populated by the first time the event was received by the pipeline. Required field for all events.',
example: '2016-05-23T08:05:34.853Z',
name: '@timestamp',
type: 'date',
searchable: true,
aggregatable: true,
category: 'base',
indexes: ['filebeat'],
readFromDocValues: true,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'agent',
description:
'Deprecated - use agent.name or agent.id to identify an agent. Hostname of the agent. ',
name: 'agent.hostname',
searchable: true,
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['filebeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'agent',
description:
'Custom name of the agent. This is a name that can be given to an agent. This can be helpful if for example two Filebeat instances are running on the same host but a human readable separation is needed on which Filebeat instance data is coming from. If no name is given, the name is often left empty.',
example: 'foo',
name: 'agent.name',
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['filebeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'agent',
description: 'Version of the agent.',
example: '6.0.0-rc2',
name: 'agent.version',
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['filebeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'base',
description: 'Each document has an _id that uniquely identifies it',
example: 'Y-6TfmcB0WOhS6qyMv3s',
name: '_id',
type: 'string',
searchable: true,
aggregatable: false,
category: 'base',
indexes: ['packetbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['packetbeat'],
},
{
category: 'base',
description:
'An index is like a ‘database’ in a relational database. It has a mapping which defines multiple types. An index is a logical namespace which maps to one or more primary shards and can have zero or more replica shards.',
example: 'auditbeat-8.0.0-2019.02.19-000001',
name: '_index',
type: 'string',
searchable: true,
aggregatable: true,
category: 'base',
indexes: ['packetbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['packetbeat'],
},
{
category: 'base',
description:
'Date/time when the event originated. This is the date/time extracted from the event, typically representing when the event was generated by the source. If the event source has no original timestamp, this value is typically populated by the first time the event was received by the pipeline. Required field for all events.',
example: '2016-05-23T08:05:34.853Z',
name: '@timestamp',
type: 'date',
searchable: true,
aggregatable: true,
category: 'base',
indexes: ['packetbeat'],
readFromDocValues: true,
esTypes: [],
indexes: ['packetbeat'],
},
{
category: 'agent',
description:
'Unique identifier of this agent (if one exists). Example: For Beats this would be beat.id.',
example: '8a4f500d',
name: 'agent.id',
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['packetbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['packetbeat'],
},
{
category: 'agent',
description:
'Type of the agent. The agent type stays always the same and should be given by the agent used. In case of Filebeat the agent would always be Filebeat also if two Filebeat instances are run on the same machine.',
example: 'filebeat',
name: 'agent.type',
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['packetbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['packetbeat'],
},
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,17 @@ export const createFieldItem = (
indexesAliasIdx: number
): IndexField => {
const alias = indexesAlias[indexesAliasIdx];
const splitIndexName = index.name.split('.');
const indexName =
splitIndexName[splitIndexName.length - 1] === 'text'
? splitIndexName.slice(0, splitIndexName.length - 1).join('.')
: index.name;
const beatIndex = fieldsBeat[indexName] ?? {};
if (isEmpty(beatIndex.category)) {
beatIndex.category = splitIndexName[0];
}
return {
...(fieldsBeat[index.name] ?? {}),
...beatIndex,
...index,
indexes: [alias],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ export const mockAuditbeatIndexField: FieldDescriptor[] = [
readFromDocValues: false,
esTypes: [],
},
{
name: 'agent.user.name',
searchable: true,
type: 'string',
aggregatable: true,
readFromDocValues: false,
esTypes: [],
},
{
name: 'client.as.number.text',
searchable: true,
type: 'string',
aggregatable: true,
readFromDocValues: false,
esTypes: [],
},
];

export const mockFilebeatIndexField: FieldDescriptor[] = [
Expand Down