Skip to content
Open
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 @@ -130,9 +130,21 @@

const restructureNodeData = (data: INodeData) => {
if (!data?.id) {
const allowedFields = [

Check warning on line 133 in dolphinscheduler-ui/src/views/projects/task/components/node/detail-modal.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

`allowedFields` should be a `Set`, and use `allowedFields.has()` to check existence or non-existence.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZ6ga7xmAQ80L8fBcIDW&open=AZ6ga7xmAQ80L8fBcIDW&pullRequest=18308
'taskPriority',
'workerGroup',
'environmentCode',
'failRetryTimes',
'failRetryInterval',
'cpuQuota',
'memoryMax',
'timeoutFlag',
'timeoutNotifyStrategy',
'timeout'
]
for (const item in projectPreferences.value) {
if (projectPreferences.value[item] !== null && item in data) {
Object.assign(data, { item: projectPreferences.value[item] })
if (projectPreferences.value[item] !== null && allowedFields.includes(item)) {
Object.assign(data, { [item]: projectPreferences.value[item] })
}
Comment on lines 132 to 148

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix: use whitelist for project preference fields in task creation

  • Replace item in data check with explicit allowed fields list
  • Ensures project preferences are applied to new tasks even when initial data object is empty
  • Prevents unrelated fields (tenant, alertGroups) from being added to task node model
  • Whitelist includes: taskPriority, workerGroup, environmentCode, failRetryTimes, failRetryInterval, cpuQuota, memoryMax, timeoutFlag, timeoutNotifyStrategy, timeout

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ export default defineComponent({
timingForm.environmentCode = projectPreferences.value.environmentCode
}
}
if (projectPreferences.value?.alertGroup && variables?.alertGroups) {
if (projectPreferences.value?.alertGroups && variables?.alertGroups) {
if (
containValueInOptions(
variables.alertGroups,
projectPreferences.value.alertGroup
projectPreferences.value.alertGroups
)
) {
timingForm.warningGroupId = projectPreferences.value.alertGroup
timingForm.warningGroupId = projectPreferences.value.alertGroups
}
}
}
Expand Down
Loading