Skip to content

Commit

Permalink
Merge branch 'exception-list-packager' of github.com:madirey/kibana i…
Browse files Browse the repository at this point in the history
…nto exception-list-packager
  • Loading branch information
madirey committed Jul 1, 2020
2 parents d517fea + 2f74e05 commit 287222c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('buildEventTypeSignal', () => {
const expectedEndpointExceptions = {
exceptions_list: [
{
field: 'server.domain.text',
field: 'server.domain',
operator: 'included',
type: 'exact_caseless',
value: 'DOMAIN',
Expand All @@ -114,7 +114,7 @@ describe('buildEventTypeSignal', () => {
value: '192.168.1.1',
},
{
field: 'host.hostname.text',
field: 'host.hostname',
operator: 'included',
type: 'exact_caseless_any',
value: ['estc', 'kibana'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function translateEntry(
case 'match': {
const e = (entry as unknown) as EntryMatch;
translatedEntry = {
field: e.field,
field: e.field.endsWith('.text') ? e.field.substring(0, e.field.length - 5) : e.field,
operator: e.operator,
type: e.field.endsWith('.text') ? 'exact_caseless' : 'exact_cased',
value: e.value,
Expand All @@ -145,7 +145,7 @@ function translateEntry(
{
const e = (entry as unknown) as EntryMatchAny;
translatedEntry = {
field: e.field,
field: e.field.endsWith('.text') ? e.field.substring(0, e.field.length - 5) : e.field,
operator: e.operator,
type: e.field.endsWith('.text') ? 'exact_caseless_any' : 'exact_cased_any',
value: e.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ describe('manifest', () => {
expect(manifest1.toEndpointFormat()).toStrictEqual({
artifacts: {
'endpoint-exceptionlist-linux-1.0.0': {
sha256: '222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
sha256: '70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
size: 268,
url:
'/api/endpoint/artifacts/download/endpoint-exceptionlist-linux-1.0.0/222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'/api/endpoint/artifacts/download/endpoint-exceptionlist-linux-1.0.0/70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
},
'endpoint-exceptionlist-macos-1.0.0': {
sha256: '222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
sha256: '70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
size: 268,
url:
'/api/endpoint/artifacts/download/endpoint-exceptionlist-macos-1.0.0/222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'/api/endpoint/artifacts/download/endpoint-exceptionlist-macos-1.0.0/70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
},
'endpoint-exceptionlist-windows-1.0.0': {
sha256: '222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
sha256: '70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
size: 268,
url:
'/api/endpoint/artifacts/download/endpoint-exceptionlist-windows-1.0.0/222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'/api/endpoint/artifacts/download/endpoint-exceptionlist-windows-1.0.0/70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
},
},
manifest_version: 'abcd',
Expand All @@ -82,9 +82,9 @@ describe('manifest', () => {
expect(manifest1.toSavedObject()).toStrictEqual({
created: now.getTime(),
ids: [
'endpoint-exceptionlist-linux-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'endpoint-exceptionlist-macos-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'endpoint-exceptionlist-windows-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'endpoint-exceptionlist-linux-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
'endpoint-exceptionlist-macos-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
'endpoint-exceptionlist-windows-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
],
});
});
Expand All @@ -94,12 +94,12 @@ describe('manifest', () => {
expect(diffs).toEqual([
{
id:
'endpoint-exceptionlist-linux-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'endpoint-exceptionlist-linux-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
type: 'delete',
},
{
id:
'endpoint-exceptionlist-linux-1.0.0-03114bf3dc2258f0def5beaf675242b68b428c96eefab5f6c5533f0d8e4deb0b',
'endpoint-exceptionlist-linux-1.0.0-69328f83418f4957470640ed6cc605be6abb5fe80e0e388fd74f9764ad7ed5d1',
type: 'add',
},
]);
Expand All @@ -115,15 +115,15 @@ describe('manifest', () => {
const entries = manifest1.getEntries();
const keys = Object.keys(entries);
expect(keys).toEqual([
'endpoint-exceptionlist-linux-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'endpoint-exceptionlist-macos-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'endpoint-exceptionlist-windows-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'endpoint-exceptionlist-linux-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
'endpoint-exceptionlist-macos-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
'endpoint-exceptionlist-windows-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
]);
});

test('Manifest returns true if contains artifact', async () => {
const found = manifest1.contains(
'endpoint-exceptionlist-macos-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466'
'endpoint-exceptionlist-macos-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c'
);
expect(found).toEqual(true);
});
Expand All @@ -132,17 +132,17 @@ describe('manifest', () => {
const manifest = Manifest.fromArtifacts(artifacts, '1.0.0', 'v0');
expect(
manifest.contains(
'endpoint-exceptionlist-linux-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466'
'endpoint-exceptionlist-linux-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c'
)
).toEqual(true);
expect(
manifest.contains(
'endpoint-exceptionlist-macos-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466'
'endpoint-exceptionlist-macos-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c'
)
).toEqual(true);
expect(
manifest.contains(
'endpoint-exceptionlist-windows-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466'
'endpoint-exceptionlist-windows-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c'
)
).toEqual(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('manifest_entry', () => {

test('Correct doc_id is returned', () => {
expect(manifestEntry.getDocId()).toEqual(
'endpoint-exceptionlist-windows-1.0.0-222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466'
'endpoint-exceptionlist-windows-1.0.0-70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c'
);
});

Expand All @@ -34,7 +34,7 @@ describe('manifest_entry', () => {

test('Correct sha256 is returned', () => {
expect(manifestEntry.getSha256()).toEqual(
'222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466'
'70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c'
);
});

Expand All @@ -44,7 +44,7 @@ describe('manifest_entry', () => {

test('Correct url is returned', () => {
expect(manifestEntry.getUrl()).toEqual(
'/api/endpoint/artifacts/download/endpoint-exceptionlist-windows-1.0.0/222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466'
'/api/endpoint/artifacts/download/endpoint-exceptionlist-windows-1.0.0/70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c'
);
});

Expand All @@ -54,10 +54,10 @@ describe('manifest_entry', () => {

test('Correct record is returned', () => {
expect(manifestEntry.getRecord()).toEqual({
sha256: '222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
sha256: '70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
size: 268,
url:
'/api/endpoint/artifacts/download/endpoint-exceptionlist-windows-1.0.0/222c07e7741e5d8371958fadc5636141bfa330926886b54b233e6a4ecac86466',
'/api/endpoint/artifacts/download/endpoint-exceptionlist-windows-1.0.0/70d2e0ee5db0073b242df9af32e64447b932b73c3e66de3a922c61a4077b1a9c',
});
});
});
Expand Down

0 comments on commit 287222c

Please sign in to comment.