Skip to content

Commit

Permalink
Merge branch 'main' of github.com:elastic/kibana into 147629-update-s…
Browse files Browse the repository at this point in the history
…ynt-service-endpoints
  • Loading branch information
shahzad31 committed Apr 17, 2023
2 parents f486a20 + 4edb583 commit 861893a
Show file tree
Hide file tree
Showing 47 changed files with 1,137 additions and 288 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ test/plugin_functional/plugins/saved_objects_hidden_from_http_apis_type @elastic
test/plugin_functional/plugins/saved_objects_hidden_type @elastic/kibana-core
src/plugins/saved_objects_management @elastic/kibana-core
src/plugins/saved_objects @elastic/kibana-core
packages/kbn-saved-objects-settings @elastic/appex-sharedux
src/plugins/saved_objects_tagging_oss @elastic/appex-sharedux
x-pack/plugins/saved_objects_tagging @elastic/appex-sharedux
src/plugins/saved_search @elastic/kibana-data-discovery
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@
"@kbn/saved-objects-hidden-type-plugin": "link:test/plugin_functional/plugins/saved_objects_hidden_type",
"@kbn/saved-objects-management-plugin": "link:src/plugins/saved_objects_management",
"@kbn/saved-objects-plugin": "link:src/plugins/saved_objects",
"@kbn/saved-objects-settings": "link:packages/kbn-saved-objects-settings",
"@kbn/saved-objects-tagging-oss-plugin": "link:src/plugins/saved_objects_tagging_oss",
"@kbn/saved-objects-tagging-plugin": "link:x-pack/plugins/saved_objects_tagging",
"@kbn/saved-search-plugin": "link:src/plugins/saved_search",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-saved-objects-settings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/saved-objects-settings

Contains constants for some of saved objects related ui settings that had to be re-used between plugins without causing circular dependencies.
10 changes: 10 additions & 0 deletions packages/kbn-saved-objects-settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const PER_PAGE_SETTING = 'savedObjects:perPage';
export const LISTING_LIMIT_SETTING = 'savedObjects:listingLimit';
13 changes: 13 additions & 0 deletions packages/kbn-saved-objects-settings/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

module.exports = {
preset: '@kbn/test/jest_node',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-saved-objects-settings'],
};
5 changes: 5 additions & 0 deletions packages/kbn-saved-objects-settings/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/saved-objects-settings",
"owner": "@elastic/appex-sharedux"
}
6 changes: 6 additions & 0 deletions packages/kbn-saved-objects-settings/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/saved-objects-settings",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
17 changes: 17 additions & 0 deletions packages/kbn-saved-objects-settings/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node"
]
},
"include": [
"**/*.ts",
],
"exclude": [
"target/**/*"
],
"kbn_references": []
}
2 changes: 1 addition & 1 deletion src/plugins/content_management/server/rpc/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { schema } from '@kbn/config-schema';
import type { IRouter } from '@kbn/core/server';

import { LISTING_LIMIT_SETTING, PER_PAGE_SETTING } from '@kbn/saved-objects-finder-plugin/common';
import { LISTING_LIMIT_SETTING, PER_PAGE_SETTING } from '@kbn/saved-objects-settings';
import { ProcedureName } from '../../../common';
import type { ContentRegistry } from '../../core';
import { MSearchService } from '../../core/msearch';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/content_management/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@kbn/object-versioning",
"@kbn/core-saved-objects-api-server-mocks",
"@kbn/core-saved-objects-api-server",
"@kbn/saved-objects-finder-plugin",
"@kbn/saved-objects-settings",
],
"exclude": [
"target/**/*",
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/saved_objects_finder/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
* Side Public License, v 1.
*/

export const PER_PAGE_SETTING = 'savedObjects:perPage';
export const LISTING_LIMIT_SETTING = 'savedObjects:listingLimit';
export { PER_PAGE_SETTING, LISTING_LIMIT_SETTING } from '@kbn/saved-objects-settings';
export type { SavedObjectCommon, FindQueryHTTP, FindResponseHTTP, FinderAttributes } from './types';
1 change: 1 addition & 0 deletions src/plugins/saved_objects_finder/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@kbn/config-schema",
"@kbn/core-ui-settings-browser",
"@kbn/core-http-browser",
"@kbn/saved-objects-settings",
],
"exclude": [
"target/**/*",
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,8 @@
"@kbn/saved-objects-management-plugin/*": ["src/plugins/saved_objects_management/*"],
"@kbn/saved-objects-plugin": ["src/plugins/saved_objects"],
"@kbn/saved-objects-plugin/*": ["src/plugins/saved_objects/*"],
"@kbn/saved-objects-settings": ["packages/kbn-saved-objects-settings"],
"@kbn/saved-objects-settings/*": ["packages/kbn-saved-objects-settings/*"],
"@kbn/saved-objects-tagging-oss-plugin": ["src/plugins/saved_objects_tagging_oss"],
"@kbn/saved-objects-tagging-oss-plugin/*": ["src/plugins/saved_objects_tagging_oss/*"],
"@kbn/saved-objects-tagging-plugin": ["x-pack/plugins/saved_objects_tagging"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { EuiBadge, EuiIcon, EuiTextColor, useEuiFontSize } from '@elastic/eui';
import { EuiBadge, EuiIcon, EuiTextColor } from '@elastic/eui';
import React from 'react';
import { css } from '@emotion/react';
import { float } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
Expand All @@ -21,10 +21,6 @@ interface SeverityStatusBadgeProps {
score: float;
}

interface ExploitsStatusBadgeProps {
totalExploits: number;
}

export const CVSScoreBadge = ({ score, version }: CVSScoreBadgeProps) => {
const color = getCvsScoreColor(score);
const versionDisplay = version ? `v${version.split('.')[0]}` : null;
Expand Down Expand Up @@ -60,28 +56,15 @@ export const SeverityStatusBadge = ({ score, status }: SeverityStatusBadgeProps)
const color = getCvsScoreColor(score);

return (
<>
<EuiIcon type="dot" color={color} />
{status}
</>
);
};

export const ExploitsStatusBadge = ({ totalExploits }: ExploitsStatusBadgeProps) => {
const xxsFontSize = useEuiFontSize('xxs').fontSize;

return (
<EuiBadge
color={'hollow'}
iconType="bug"
<div
css={css`
.euiBadge__text {
font-weight: 400;
font-size: ${xxsFontSize};
}
display: flex;
flex-direction: row;
align-items: center;
`}
>
{totalExploits}
</EuiBadge>
<EuiIcon type="dot" color={color} />
{status}
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,7 @@ export interface VulnerabilityRecord {
sequence: number;
outcome: string;
};
vulnerability: {
score: {
version: string;
impact: number;
base: number;
};
cwe: string[];
id: string;
title: string;
reference: string;
severity: string;
cvss: {
nvd: {
V3Vector: string;
V3Score: number;
};
redhat?: {
V3Vector: string;
V3Score: number;
};
ghsa?: {
V3Vector: string;
V3Score: number;
};
};
data_source: {
ID: string;
Name: string;
URL: string;
};
enumeration: string;
description: string;
classification: string;
scanner: {
vendor: string;
};
package: {
version: string;
name: string;
fixed_version: string;
};
};
vulnerability: Vulnerability;
ecs: {
version: string;
};
Expand Down Expand Up @@ -116,3 +75,58 @@ export interface VulnerabilityRecord {
commit_time: string;
};
}

export interface Vulnerability {
published_at: string;
score: {
version: string;
impact: number;
base: number;
};
cwe: string[];
id: string;
title: string;
reference: string;
severity: string;
cvss: {
nvd: VectorScoreBase;
redhat?: VectorScoreBase;
ghsa?: VectorScoreBase;
};
data_source: {
ID: string;
Name: string;
URL: string;
};
enumeration: string;
description: string;
classification: string;
scanner: {
vendor: string;
};
package: {
version: string;
name: string;
fixed_version: string;
};
}

export interface VectorScoreBase {
V3Score?: number;
V3Vector?: string;
V2Score?: number;
V2Vector?: string;
}

export type Vendor = 'NVD' | 'Red Hat' | 'GHSA';

export interface CVSScoreProps {
vectorBaseScore: VectorScoreBase;
vendor: string;
}

export interface Vector {
version: string;
vector: string;
score: number | undefined;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { EuiDataGridColumn } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { VectorScoreBase, Vector } from './types';

export const vulnerabilitiesColumns = {
actions: 'actions',
Expand Down Expand Up @@ -85,3 +86,29 @@ export const getVulnerabilitiesColumnsGrid = (): EuiDataGridColumn[] => {
},
];
};

export const getVectorScoreList = (vectorBaseScore: VectorScoreBase) => {
const result: Vector[] = [];
const v2Vector = vectorBaseScore?.V2Vector;
const v2Score = vectorBaseScore?.V2Score;
const v3Vector = vectorBaseScore?.V3Vector;
const v3Score = vectorBaseScore?.V3Score;

if (v2Vector) {
result.push({
version: '2.0',
vector: v2Vector,
score: v2Score,
});
}

if (v3Vector) {
result.push({
version: '2.0',
vector: v3Vector,
score: v3Score,
});
}

return result;
};
Loading

0 comments on commit 861893a

Please sign in to comment.