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

kie-issues#329: Remove jsonpath@1.1.1 (CVE-2023-26115) #1898

Merged
merged 2 commits into from
Oct 25, 2023
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
7 changes: 3 additions & 4 deletions ui-packages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"axios": "^0.21.1",
"camel-case": "^3.0.0",
"graphql": "^15.5.3",
"jsonpath": "^1.0.2",
"lodash": "^4.17.15",
"lower-case": "^1.1.4",
"monaco-editor": "0.27.0",
Expand Down Expand Up @@ -125,6 +124,7 @@
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-test-renderer": "^16.10.2",
"replace-in-file-webpack-plugin": "1.0.6",
"sass": "^1.54.5",
"sass-loader": "^10.3.1",
"start-server-and-test": "^1.12.0",
Expand All @@ -143,8 +143,7 @@
"webpack-dev-server": "^4.8.0",
"webpack-merge": "^4.2.2",
"webpack-node-externals": "^3.0.0",
"yarn": "1.22.10",
"replace-in-file-webpack-plugin": "1.0.6"
"yarn": "1.22.10"
},
"resolutions": {
"@patternfly/react-core": "4.157.3",
Expand All @@ -153,7 +152,7 @@
"axios": "0.21.2",
"d3": "^7.0.0",
"d3-ease": "^3.0.1",
"d3-interpolate":"^3.0.1",
"d3-interpolate": "^3.0.1",
"fast-xml-parser": "^4.2.4",
"minimatch": "^3.0.5"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ import {
KogitoEmptyStateType
} from '../../Atoms/KogitoEmptyState/KogitoEmptyState';
import '@patternfly/patternfly/patternfly-addons.css';
import _ from 'lodash';
import isEmpty from 'lodash/isEmpty';
import filter from 'lodash/filter';
import sample from 'lodash/sample';
import keys from 'lodash/keys';
import get from 'lodash/get';
import reduce from 'lodash/reduce';
import isFunction from 'lodash/isFunction';
import uuidv4 from 'uuid';
import jp from 'jsonpath';
import { OUIAProps, componentOuiaProps } from '@kogito-apps/ouia-tools';

export interface DataTableColumn {
Expand All @@ -45,9 +50,7 @@ interface IOwnProps {

const getCellData = (dataObj: Record<string, unknown>, path: string) => {
if (dataObj && path) {
return !_.isEmpty(jp.value(dataObj, path))
? jp.value(dataObj, path)
: 'N/A';
return get(dataObj, path) ?? 'N/A';
} else {
return 'N/A';
}
Expand All @@ -57,7 +60,7 @@ const getColumns = (data: any[], columns: DataTableColumn[]) => {
let columnList: ICell[] = [];
if (data) {
columnList = columns
? _.filter(columns, (column) => !_.isEmpty(column.path)).map((column) => {
? filter(columns, (column) => !isEmpty(column.path)).map((column) => {
return {
title: column.label,
data: column.path,
Expand All @@ -77,8 +80,8 @@ const getColumns = (data: any[], columns: DataTableColumn[]) => {
transforms: column.isSortable ? [sortable] : undefined
} as ICell;
})
: _.filter(_.keys(_.sample(data)), (key) => key !== '__typename').map(
(key) => ({ title: key, data: `$.${key}` } as ICell)
: filter(keys(sample(data)), (key) => key !== '__typename').map(
(key) => ({ title: key, data: key } as ICell)
);
}
return columnList;
Expand All @@ -89,7 +92,7 @@ const getRows = (data: any[], columns: ICell[]) => {
if (data) {
rowList = data.map((rowData) => {
return {
cells: _.reduce(
cells: reduce(
columns,
(result, column: ICell) => {
if (column.data) {
Expand Down Expand Up @@ -124,17 +127,17 @@ const DataTable: React.FC<IOwnProps & OUIAProps> = ({
const [columnList, setColumnList] = useState<ICell[]>([]);

useEffect(() => {
if (!_.isEmpty(data)) {
if (!isEmpty(data)) {
const cols = getColumns(data, columns);
if (!_.isEmpty(cols)) {
if (!isEmpty(cols)) {
setColumnList(cols);
setRows(getRows(data, cols));
}
}
}, [data]);

const onSort = (event, index, direction) => {
if (_.isFunction(onSorting)) {
if (isFunction(onSorting)) {
onSorting(index, direction);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,24 @@ const stateColumnTransformer = (value) => {
const columns: DataTableColumn[] = [
{
label: 'ProcessId',
path: '$.processId'
path: 'processId'
},
{
label: 'Name',
path: '$.name',
path: 'name',
isSortable: true
},
{
label: 'Priority',
path: '$.priority'
path: 'priority'
},
{
label: 'ProcessInstanceId',
path: '$.processInstanceId'
path: 'processInstanceId'
},
{
label: 'State',
path: '$.state',
path: 'state',
bodyCellTransformer: stateColumnTransformer,
isSortable: true
}
Expand Down
Loading