This is an automated email from the ASF dual-hosted git repository.
gongzhongqiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new c4f3d4efe [Improve] maven build args improvement (#3366)
c4f3d4efe is described below
commit c4f3d4efef9e541b219ac2cb9d9494e130068135
Author: benjobs <[email protected]>
AuthorDate: Thu Nov 30 22:27:12 2023 +0800
[Improve] maven build args improvement (#3366)
* [Improve] maven build args improvement
* [Improve] exception message improvement
* [Bug] maven danger args bug fixed
---------
Co-authored-by: benjobs <[email protected]>
---
.../streampark/console/core/entity/Project.java | 53 ++++++++-
.../src/main/resources/db/data-h2.sql | 4 +-
.../streampark-console-webapp/src/api/flink/app.ts | 4 +-
.../src/api/flink/flinkBuild.ts | 5 +-
.../components/Form/src/components/FormItem.vue | 8 +-
.../Modal/src/components/ModalWrapper.vue | 4 +-
.../components/Table/src/components/HeaderCell.vue | 2 +-
.../src/hooks/setting/useMenuSetting.ts | 10 +-
.../streampark-console-webapp/src/utils/props.ts | 46 ++++----
.../src/views/base/error-log/data.tsx | 12 +-
.../src/views/flink/app/data/option.ts | 121 ++++++++++-----------
.../views/resource/project/components/ListItem.vue | 5 +-
12 files changed, 160 insertions(+), 114 deletions(-)
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
index 1db459925..f4f6637a5 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
@@ -43,9 +43,11 @@ import org.eclipse.jgit.lib.Constants;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.jar.JarFile;
+import java.util.stream.Collectors;
@Slf4j
@Data
@@ -213,17 +215,62 @@ public class Project implements Serializable {
StringBuilder cmdBuffer = new StringBuilder(mvn).append(" clean package
-DskipTests ");
if (StringUtils.isNotBlank(this.buildArgs)) {
- cmdBuffer.append(this.buildArgs.trim());
+ List<String> dangerArgs = getDangerArgs(this.buildArgs);
+ if (dangerArgs.isEmpty()) {
+ cmdBuffer.append(this.buildArgs.trim());
+ } else {
+ throw new IllegalArgumentException(
+ String.format(
+ "Invalid build args, dangerous operation symbol detected: %s,
in your buildArgs: %s",
+ dangerArgs.stream().collect(Collectors.joining(",")),
this.buildArgs));
+ }
}
String setting =
InternalConfigHolder.get(CommonConfig.MAVEN_SETTINGS_PATH());
if (StringUtils.isNotBlank(setting)) {
- cmdBuffer.append(" --settings ").append(setting);
+ List<String> dangerArgs = getDangerArgs(setting);
+ if (dangerArgs.isEmpty()) {
+ File file = new File(setting);
+ if (file.exists() && file.isFile()) {
+ cmdBuffer.append(" --settings ").append(setting);
+ } else {
+ throw new IllegalArgumentException(
+ String.format("Invalid maven setting path, %s no exists or not
file", setting));
+ }
+ } else {
+ throw new IllegalArgumentException(
+ String.format(
+ "Invalid maven setting path, dangerous operation symbol
detected: %s, in your maven setting path: %s",
+ dangerArgs.stream().collect(Collectors.joining(",")),
setting));
+ }
}
-
return cmdBuffer.toString();
}
+ private List<String> getDangerArgs(String param) {
+ String[] args = param.split("\\s+");
+ List<String> dangerArgs = new ArrayList<>();
+ for (String arg : args) {
+ if (arg.length() == 1) {
+ if (arg.equals("|")) {
+ dangerArgs.add("|");
+ }
+ if (arg.equals("&")) {
+ dangerArgs.add("&");
+ }
+ } else {
+ arg = arg.substring(0, 2);
+ if (arg.equals("||")) {
+ dangerArgs.add("||");
+ }
+ if (arg.equals("&&")) {
+ dangerArgs.add("&&");
+ }
+ }
+ }
+ return dangerArgs;
+ }
+
@JsonIgnore
public String getMavenWorkHome() {
String buildHome = this.getAppSource().getAbsolutePath();
diff --git
a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
index 48f013570..f5d2df45b 100644
---
a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
+++
b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
@@ -81,10 +81,10 @@ insert into `t_menu` values (130200, 130000,
'resource.variable', '/resource/var
insert into `t_menu` values (130300, 130000, 'resource.upload',
'/resource/upload', 'resource/upload/View', null, null, '0', 1, 3, now(),
now());
insert into `t_menu` values (130101, 130100, 'project view', null, null,
'project:view', null, '1', 1, null, now(), now());
-insert into `t_menu` values (130102, 130100, 'project add', '/project/add',
'project/Add', 'project:create', '', '0', 0, null, now(), now());
+insert into `t_menu` values (130102, 130100, 'project add', '/project/add',
'resource/project/Add', 'project:create', '', '0', 0, null, now(), now());
insert into `t_menu` values (130103, 130100, 'project build', null, null,
'project:build', null, '1', 1, null, now(), now());
insert into `t_menu` values (130104, 130100, 'project delete', null, null,
'project:delete', null, '1', 1, null, now(), now());
-insert into `t_menu` values (130105, 130100, 'project edit', '/project/edit',
'project/Edit', 'project:update', null, '0', 0, null, now(), now());
+insert into `t_menu` values (130105, 130100, 'project edit', '/project/edit',
'resource/project/Edit', 'project:update', null, '0', 0, null, now(), now());
insert into `t_menu` values (130201, 130200, 'variable view', NULL, NULL,
'variable:view', NULL, '1', 1, null, now(), now());
insert into `t_menu` values (130202, 130200, 'variable depend view', null,
null, 'variable:depend_apps', null, '1', 1, NULL, now(), now());
diff --git a/streampark-console/streampark-console-webapp/src/api/flink/app.ts
b/streampark-console/streampark-console-webapp/src/api/flink/app.ts
index 48a61cbfb..13110db38 100644
--- a/streampark-console/streampark-console-webapp/src/api/flink/app.ts
+++ b/streampark-console/streampark-console-webapp/src/api/flink/app.ts
@@ -109,7 +109,7 @@ export function fetchCheckName(data: { id?: string;
jobName: string }): Promise<
return defHttp.post({ url: APP_API.CHECK_NAME, data });
}
-export function fetchMain(data):Promise<string> {
+export function fetchMain(data): Promise<string> {
return defHttp.post({ url: APP_API.MAIN, data });
}
/**
@@ -117,7 +117,7 @@ export function fetchMain(data):Promise<string> {
* @param params
* @returns {String} file path
*/
-export function fetchUpload(params) :Promise<string> {
+export function fetchUpload(params): Promise<string> {
return defHttp.post<string>({
url: APP_API.UPLOAD,
params,
diff --git
a/streampark-console/streampark-console-webapp/src/api/flink/flinkBuild.ts
b/streampark-console/streampark-console-webapp/src/api/flink/flinkBuild.ts
index 8fbda0dc9..de201ec67 100644
--- a/streampark-console/streampark-console-webapp/src/api/flink/flinkBuild.ts
+++ b/streampark-console/streampark-console-webapp/src/api/flink/flinkBuild.ts
@@ -22,7 +22,10 @@ enum BUILD_API {
DETAIL = '/flink/pipe/detail',
}
-export function fetchBuild(data: { appId: string; forceBuild: boolean; }):
Promise<AxiosResponse<any>> {
+export function fetchBuild(data: {
+ appId: string;
+ forceBuild: boolean;
+}): Promise<AxiosResponse<any>> {
return defHttp.post({ url: BUILD_API.BUILD, data }, {
isReturnNativeResponse: true });
}
/**
diff --git
a/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue
b/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue
index 137ae94d6..9bbb5023f 100644
---
a/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue
+++
b/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue
@@ -333,8 +333,8 @@
return slot
? getSlot(slots, slot, unref(getValues))
: render
- ? render(unref(getValues))
- : renderComponent();
+ ? render(unref(getValues))
+ : renderComponent();
};
const showSuffix = !!suffix;
@@ -382,8 +382,8 @@
return colSlot
? getSlot(slots, colSlot, values)
: renderColContent
- ? renderColContent(values)
- : renderItem();
+ ? renderColContent(values)
+ : renderItem();
};
return (
diff --git
a/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue
b/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue
index 1b1b9a613..52c8b5eb8 100644
---
a/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue
+++
b/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue
@@ -153,8 +153,8 @@
realHeightRef.value = props.height
? props.height
: realHeight > maxHeight
- ? maxHeight
- : realHeight;
+ ? maxHeight
+ : realHeight;
}
emit('height-change', unref(realHeightRef));
} catch (error) {
diff --git
a/streampark-console/streampark-console-webapp/src/components/Table/src/components/HeaderCell.vue
b/streampark-console/streampark-console-webapp/src/components/Table/src/components/HeaderCell.vue
index 35c080269..36ab854c5 100644
---
a/streampark-console/streampark-console-webapp/src/components/Table/src/components/HeaderCell.vue
+++
b/streampark-console/streampark-console-webapp/src/components/Table/src/components/HeaderCell.vue
@@ -22,7 +22,7 @@
props: {
column: {
type: Object as PropType<BasicColumn>,
- default: () => ({} as BasicColumn),
+ default: () => ({}) as BasicColumn,
},
},
setup(props) {
diff --git
a/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts
b/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts
index 3566bfd27..f501c6e80 100644
---
a/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts
+++
b/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts
@@ -105,8 +105,8 @@ export function useMenuSetting() {
return siderHidden
? 0
: collapsedShowTitle
- ? SIDE_BAR_SHOW_TIT_MINI_WIDTH
- : SIDE_BAR_MINI_WIDTH;
+ ? SIDE_BAR_SHOW_TIT_MINI_WIDTH
+ : SIDE_BAR_MINI_WIDTH;
});
const getCalcContentWidth = computed(() => {
@@ -114,9 +114,9 @@ export function useMenuSetting() {
unref(getIsTopMenu) || !unref(getShowMenu) || (unref(getSplit) &&
unref(getMenuHidden))
? 0
: unref(getIsMixSidebar)
- ? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH :
SIDE_BAR_SHOW_TIT_MINI_WIDTH) +
- (unref(getMixSideFixed) && unref(mixSideHasChildren) ?
unref(getRealWidth) : 0)
- : unref(getRealWidth);
+ ? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH :
SIDE_BAR_SHOW_TIT_MINI_WIDTH) +
+ (unref(getMixSideFixed) && unref(mixSideHasChildren) ?
unref(getRealWidth) : 0)
+ : unref(getRealWidth);
return `calc(100% - ${unref(width)}px)`;
});
diff --git a/streampark-console/streampark-console-webapp/src/utils/props.ts
b/streampark-console/streampark-console-webapp/src/utils/props.ts
index 368f490f2..4a5491b27 100644
--- a/streampark-console/streampark-console-webapp/src/utils/props.ts
+++ b/streampark-console/streampark-console-webapp/src/utils/props.ts
@@ -28,8 +28,8 @@ export type BuildPropOption<T, D extends BuildPropType<T, V,
C>, R, V, C> = {
default?: R extends true
? never
: D extends Record<string, unknown> | Array<any>
- ? () => D
- : (() => D) | D;
+ ? () => D
+ : (() => D) | D;
validator?: ((val: any) => val is C) | ((val: any) => boolean);
};
@@ -37,8 +37,8 @@ type _BuildPropType<T, V, C> =
| (T extends PropWrapper<unknown>
? T[typeof wrapperKey]
: [V] extends [never]
- ? ResolvePropTypeWithReadonly<T>
- : never)
+ ? ResolvePropTypeWithReadonly<T>
+ : never)
| V
| C;
export type BuildPropType<T, V, C> = _BuildPropType<
@@ -53,8 +53,8 @@ type _BuildPropDefault<T, D> = [T] extends [
]
? D
: D extends () => T
- ? ReturnType<D>
- : D;
+ ? ReturnType<D>
+ : D;
export type BuildPropDefault<T, D, R> = R extends true
? { readonly default?: undefined }
@@ -146,12 +146,12 @@ export const buildProps = <
[K in keyof O]: O[K] extends BuildPropReturn<any, any, any, any, any>
? O[K]
: [O[K]] extends NativePropType
- ? O[K]
- : O[K] extends BuildPropOption<infer T, infer D, infer R, infer V, infer
C>
- ? D extends BuildPropType<T, V, C>
- ? BuildPropOption<T, D, R, V, C>
- : never
- : never;
+ ? O[K]
+ : O[K] extends BuildPropOption<infer T, infer D, infer R, infer V,
infer C>
+ ? D extends BuildPropType<T, V, C>
+ ? BuildPropOption<T, D, R, V, C>
+ : never
+ : never;
},
>(
props: O,
@@ -162,17 +162,17 @@ export const buildProps = <
[K in keyof O]: O[K] extends { [propKey]: boolean }
? O[K]
: [O[K]] extends NativePropType
- ? O[K]
- : O[K] extends BuildPropOption<
- infer T,
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- infer _D,
- infer R,
- infer V,
- infer C
- >
- ? BuildPropReturn<T, O[K]['default'], R, V, C>
- : never;
+ ? O[K]
+ : O[K] extends BuildPropOption<
+ infer T,
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ infer _D,
+ infer R,
+ infer V,
+ infer C
+ >
+ ? BuildPropReturn<T, O[K]['default'], R, V, C>
+ : never;
};
export const definePropType = <T>(val: any) => ({ [wrapperKey]: val }) as
PropWrapper<T>;
diff --git
a/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx
b/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx
index 3ffc2f453..73120a425 100644
---
a/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx
+++
b/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx
@@ -16,12 +16,12 @@ export function getColumns(): BasicColumn[] {
text === ErrorTypeEnum.VUE
? 'green'
: text === ErrorTypeEnum.RESOURCE
- ? 'cyan'
- : text === ErrorTypeEnum.PROMISE
- ? 'blue'
- : ErrorTypeEnum.AJAX
- ? 'red'
- : 'purple';
+ ? 'cyan'
+ : text === ErrorTypeEnum.PROMISE
+ ? 'blue'
+ : ErrorTypeEnum.AJAX
+ ? 'red'
+ : 'purple';
return <Tag color={color}>{() => text}</Tag>;
},
},
diff --git
a/streampark-console/streampark-console-webapp/src/views/flink/app/data/option.ts
b/streampark-console/streampark-console-webapp/src/views/flink/app/data/option.ts
index 84658abf2..54cb399cf 100644
---
a/streampark-console/streampark-console-webapp/src/views/flink/app/data/option.ts
+++
b/streampark-console/streampark-console-webapp/src/views/flink/app/data/option.ts
@@ -488,68 +488,65 @@ const options = [
},
},
{
- key: 'taskmanager.memory.network.max',
- name: 'taskmanager.memory.network.max',
- placeholder: 'Max Network Memory size for TaskExecutors',
- description:
- 'This biggest Network Memory is used for allocation of network
buffers',
- unit: 'mb',
- group: 'taskmanager-memory',
- type: 'number',
- min: 64,
- max: 1024,
- step: 1,
- defaultValue: 1024,
- validator: (_rule, value, callback) => {
- if (!value) {
- callback(new Error('memory.network.max is required or you can
delete this option'));
- } else {
- callback();
- }
- },
- },
- {
- key: 'taskmanager.memory.network.min',
- name: 'taskmanager.memory.network.min',
- placeholder: 'Min Network Memory size for TaskExecutors',
- description:
- 'This minimum Network Memory is used for allocation of network
buffers',
- unit: 'mb',
- group: 'taskmanager-memory',
- type: 'number',
- min: 64,
- max: 1024,
- step: 1,
- defaultValue: 64,
- validator: (_rule, value, callback) => {
- if (!value) {
- callback(new Error('memory.network.min is required or you can
delete this option'));
- } else {
- callback();
- }
- },
- },
- {
- key: 'taskmanager.memory.network.fraction',
- name: 'taskmanager.memory.network.fraction',
- placeholder: 'Fraction of Network Memory size for
TaskExecutors',
- description:
- 'The fraction of Network Memory size is used for allocation
of network buffers',
- unit: 'mb',
- group: 'taskmanager-memory',
- type: 'number',
- min: 0.1,
- max: 1,
- step: 0.1,
- defaultValue: 0.1,
- validator: (_rule, value, callback) => {
- if (!value) {
- callback(new Error('memory.network.fraction is required or
you can delete this option'));
- } else {
- callback();
- }
- },
- },
+ key: 'taskmanager.memory.network.max',
+ name: 'taskmanager.memory.network.max',
+ placeholder: 'Max Network Memory size for TaskExecutors',
+ description: 'This biggest Network Memory is used for allocation of
network buffers',
+ unit: 'mb',
+ group: 'taskmanager-memory',
+ type: 'number',
+ min: 64,
+ max: 1024,
+ step: 1,
+ defaultValue: 1024,
+ validator: (_rule, value, callback) => {
+ if (!value) {
+ callback(new Error('memory.network.max is required or you can delete
this option'));
+ } else {
+ callback();
+ }
+ },
+ },
+ {
+ key: 'taskmanager.memory.network.min',
+ name: 'taskmanager.memory.network.min',
+ placeholder: 'Min Network Memory size for TaskExecutors',
+ description: 'This minimum Network Memory is used for allocation of
network buffers',
+ unit: 'mb',
+ group: 'taskmanager-memory',
+ type: 'number',
+ min: 64,
+ max: 1024,
+ step: 1,
+ defaultValue: 64,
+ validator: (_rule, value, callback) => {
+ if (!value) {
+ callback(new Error('memory.network.min is required or you can delete
this option'));
+ } else {
+ callback();
+ }
+ },
+ },
+ {
+ key: 'taskmanager.memory.network.fraction',
+ name: 'taskmanager.memory.network.fraction',
+ placeholder: 'Fraction of Network Memory size for TaskExecutors',
+ description: 'The fraction of Network Memory size is used for allocation
of network buffers',
+ unit: 'mb',
+ group: 'taskmanager-memory',
+ type: 'number',
+ min: 0.1,
+ max: 1,
+ step: 0.1,
+ defaultValue: 0.1,
+ validator: (_rule, value, callback) => {
+ if (!value) {
+ callback(new Error('memory.network.fraction is required or you can
delete this option'));
+ } else {
+ callback();
+ }
+ },
+ },
];
const optionsKeyMapping = new Map<string, Recordable>();
diff --git
a/streampark-console/streampark-console-webapp/src/views/resource/project/components/ListItem.vue
b/streampark-console/streampark-console-webapp/src/views/resource/project/components/ListItem.vue
index 5f5d9ad9c..2ca92caf3 100644
---
a/streampark-console/streampark-console-webapp/src/views/resource/project/components/ListItem.vue
+++
b/streampark-console/streampark-console-webapp/src/views/resource/project/components/ListItem.vue
@@ -125,17 +125,16 @@
import { computed } from 'vue';
import { buildProject, deleteProject } from '/@/api/resource/project';
import { useMessage } from '/@/hooks/web/useMessage';
- import { useGo } from '/@/hooks/web/usePage';
import { ProjectRecord } from '/@/api/resource/project/model/projectModel';
import { BuildStateEnum } from '/@/enums/flinkEnum';
import { useI18n } from '/@/hooks/web/useI18n';
import { ProjectTypeEnum } from '/@/enums/projectEnum';
+ import { router } from '/@/router';
const { t } = useI18n();
const emit = defineEmits(['viewLog', 'success']);
const { Swal, createMessage } = useMessage();
- const go = useGo();
const props = defineProps({
item: { type: Object as PropType<ProjectRecord>, required: true },
});
@@ -172,7 +171,7 @@
}
const handleEdit = function () {
- go(`/project/edit?id=${props.item.id}`);
+ router.push({ path: '/project/edit', query: { id: props.item.id } });
};
async function handleDelete() {