Saved filters 2#1301
Merged
lyubov-voloshko merged 32 commits intomainfrom Aug 13, 2025
Merged
Conversation
- add saved filters panel; - add save filters set dialog and request.
- show filters menu; - display filters in edit popup; - remove filters.
- remove filter selection through index; - clear filters on selecting already active filter
- add update saved filters; - update saved filters layout.
…filters when regular are applied
| if (dynamicColumn && this.savedFilterMap[this.selectedFilterSetId]) { | ||
| const filters = params['filters'] ? JsonURL.parse(params['filters']) : {}; | ||
|
|
||
| this.savedFilterMap[this.selectedFilterSetId].dynamicColumn = { |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the prototype pollution vulnerability, we should prevent user-controlled keys from being used to modify object properties in a way that could affect the prototype chain. The best way to do this is to use a Map object instead of a plain object for savedFilterMap, as Map is resilient to prototype pollution. This requires:
- Changing the type and initialization of
savedFilterMapfrom{ [key: string]: any } = {}toMap<string, any> = new Map(). - Updating all code that reads or writes to
savedFilterMapto useMapmethods (set,get,has, etc.) instead of object property access. - Specifically, in
loadSavedFilters, update the assignment to usesetinstead of object spread, and update all subsequent accesses to usegetinstead of bracket notation.
All changes are to be made in frontend/src/app/components/dashboard/db-table-view/saved-filters-panel/saved-filters-panel.component.ts.
Suggested changeset
1
frontend/src/app/components/dashboard/db-table-view/saved-filters-panel/saved-filters-panel.component.ts
| @@ -60,7 +60,7 @@ | ||
| private dynamicColumnValueDebounceTimer: any = null; | ||
|
|
||
| public savedFilterData: any[] = []; | ||
| public savedFilterMap: { [key: string]: any } = {}; | ||
| public savedFilterMap: Map<string, any> = new Map(); | ||
|
|
||
| public selectedFilterSetId: string | null = null; | ||
| public selectedFilter: any = null; | ||
| @@ -196,23 +196,27 @@ | ||
| this.savedFilterData = data.sort((a, b) => | ||
| new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime() | ||
| ); | ||
| this.savedFilterMap = Object.assign({}, ...data.map((filter) => { | ||
| this.savedFilterMap = new Map(); | ||
| data.forEach((filter) => { | ||
| const transformedFilter = this.processFiltersData(filter); | ||
| return { [filter.id]: transformedFilter }; | ||
| })); | ||
| this.savedFilterMap.set(filter.id, transformedFilter); | ||
| }); | ||
|
|
||
| const params = this.route.snapshot.queryParams; | ||
| const dynamicColumn = params['dynamic_column'] ? JsonURL.parse(params['dynamic_column']) : null; | ||
|
|
||
| if (this.selectedFilterSetId && this.savedFilterData.length > 0) { | ||
| if (dynamicColumn && this.savedFilterMap[this.selectedFilterSetId]) { | ||
| if (dynamicColumn && this.savedFilterMap.has(this.selectedFilterSetId)) { | ||
| const filters = params['filters'] ? JsonURL.parse(params['filters']) : {}; | ||
|
|
||
| this.savedFilterMap[this.selectedFilterSetId].dynamicColumn = { | ||
| column: dynamicColumn.column_name, | ||
| operator: dynamicColumn.comparator, | ||
| value: filters[dynamicColumn.column_name]?.[dynamicColumn.comparator] || null | ||
| }; | ||
| const selectedFilter = this.savedFilterMap.get(this.selectedFilterSetId); | ||
| if (selectedFilter) { | ||
| selectedFilter.dynamicColumn = { | ||
| column: dynamicColumn.column_name, | ||
| operator: dynamicColumn.comparator, | ||
| value: filters[dynamicColumn.column_name]?.[dynamicColumn.comparator] || null | ||
| }; | ||
| } | ||
| } | ||
| } | ||
| } |
Copilot is powered by AI and may make mistakes. Always verify output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.