Commit 8d3b922
committed
fix(access-control): gate the seeded model too, and collapse the seed rule
Block creation seeds `model` the same way it seeds `operation`: `agent`,
`router` and `evaluator` all declare `defaultValue: 'claude-sonnet-5'`, and
`prepareBlockState` wrote it unconditionally. The model combobox only fills a
field that is empty, so a group denying that model (or the Anthropic provider)
got an Agent block pre-filled with a model it cannot run — the same bug as the
operation one, on the other axis the permission group governs.
Rather than a second bespoke gate, `prepareBlockState` now takes one veto,
`isSeededValueAllowed(subBlockId, value)`, and seeds nothing when a declared
default is denied. Nothing substitutes a replacement there any more: the
editor's own permission-aware pickers already resolve the right one and only
fill an empty field, and substituting in the store would drift from
`getDefaultBlockName`, which names a block after its *declared* default. That
also deletes `firstAllowedOperation` and its copy of subblock-option
enumeration.
Review follow-ups:
- `usePermissionConfig` gains `isModelUsable` (denylist AND provider allowlist);
the combobox's two hand-rolled copies of that pair now call it
- `isToolAllowed`/`isModelAllowed` index their denylists — the gate calls them
once per option of every block offered, so a linear scan made a check's cost
scale with denylist length (measured 3.2ms -> 0.30ms per search-index build
at 500 denied tools)
- `useOperationAccess` had three members with three different loading
semantics, one documented as unsafe alone; it now exposes one withholding
`resolveOperationGate`
- the agent tool picker derived its option list twice with the empty-id filter
on only one path; both callers now share one `{ options, denied }` result
- `OPERATION_SUBBLOCK_ID` was a verbatim copy of the private constant in
`canvas-sentence.ts`, doc comment included; that file now imports it1 parent 310b4be commit 8d3b922
10 files changed
Lines changed: 233 additions & 171 deletions
File tree
- apps/sim
- app/workspace/[workspaceId]/w/[workflowId]
- components/panel/components/editor/components/sub-block/components
- combobox
- dropdown
- tool-input
- hooks
- lib
- permission-groups
- workflows/blocks
- stores/workflows
Lines changed: 5 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 110 | + | |
116 | 111 | | |
117 | 112 | | |
118 | 113 | | |
119 | 114 | | |
120 | 115 | | |
121 | 116 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 117 | + | |
131 | 118 | | |
132 | 119 | | |
133 | 120 | | |
134 | | - | |
| 121 | + | |
135 | 122 | | |
136 | 123 | | |
137 | 124 | | |
| |||
210 | 197 | | |
211 | 198 | | |
212 | 199 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 200 | + | |
222 | 201 | | |
223 | 202 | | |
224 | 203 | | |
| |||
251 | 230 | | |
252 | 231 | | |
253 | 232 | | |
254 | | - | |
255 | | - | |
| 233 | + | |
256 | 234 | | |
257 | 235 | | |
258 | 236 | | |
| |||
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | | - | |
22 | | - | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
197 | 198 | | |
198 | 199 | | |
199 | 200 | | |
200 | | - | |
| 201 | + | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
| |||
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
229 | | - | |
230 | | - | |
231 | 230 | | |
232 | 231 | | |
233 | 232 | | |
| |||
236 | 235 | | |
237 | 236 | | |
238 | 237 | | |
| 238 | + | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
| 244 | + | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| |||
Lines changed: 36 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
666 | 669 | | |
667 | 670 | | |
668 | 671 | | |
669 | | - | |
670 | | - | |
671 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
672 | 679 | | |
673 | | - | |
| 680 | + | |
674 | 681 | | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
681 | 690 | | |
682 | 691 | | |
683 | 692 | | |
| |||
688 | 697 | | |
689 | 698 | | |
690 | 699 | | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
695 | 706 | | |
696 | 707 | | |
697 | 708 | | |
| |||
806 | 817 | | |
807 | 818 | | |
808 | 819 | | |
809 | | - | |
810 | | - | |
811 | | - | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
812 | 824 | | |
813 | 825 | | |
814 | 826 | | |
| |||
844 | 856 | | |
845 | 857 | | |
846 | 858 | | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
| 859 | + | |
855 | 860 | | |
856 | 861 | | |
857 | 862 | | |
| |||
1830 | 1835 | | |
1831 | 1836 | | |
1832 | 1837 | | |
1833 | | - | |
| 1838 | + | |
1834 | 1839 | | |
1835 | 1840 | | |
1836 | 1841 | | |
| |||
2090 | 2095 | | |
2091 | 2096 | | |
2092 | 2097 | | |
2093 | | - | |
2094 | | - | |
2095 | | - | |
2096 | | - | |
2097 | | - | |
2098 | | - | |
2099 | | - | |
2100 | | - | |
2101 | | - | |
2102 | | - | |
2103 | | - | |
2104 | | - | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
2105 | 2101 | | |
| 2102 | + | |
2106 | 2103 | | |
2107 | 2104 | | |
2108 | 2105 | | |
| |||
Lines changed: 17 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| |||
870 | 871 | | |
871 | 872 | | |
872 | 873 | | |
873 | | - | |
| 874 | + | |
| 875 | + | |
874 | 876 | | |
875 | 877 | | |
876 | 878 | | |
| |||
894 | 896 | | |
895 | 897 | | |
896 | 898 | | |
897 | | - | |
898 | | - | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
899 | 902 | | |
900 | | - | |
901 | | - | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
902 | 910 | | |
903 | 911 | | |
904 | 912 | | |
| |||
910 | 918 | | |
911 | 919 | | |
912 | 920 | | |
913 | | - | |
| 921 | + | |
914 | 922 | | |
915 | 923 | | |
916 | 924 | | |
| |||
958 | 966 | | |
959 | 967 | | |
960 | 968 | | |
961 | | - | |
962 | | - | |
| 969 | + | |
| 970 | + | |
963 | 971 | | |
964 | 972 | | |
965 | 973 | | |
| |||
0 commit comments