5
5
} = require ( "../data/hardcoded-permissions" ) ;
6
6
const { get_user } = require ( "../helpers" ) ;
7
7
const { Actor, UserActorType, AppUnderUserActorType } = require ( "../services/auth/Actor" ) ;
8
+ const { reading_has_terminal } = require ( "./permission-scan-lib" ) ;
8
9
9
10
/*
10
11
OPTIMAL FOLD LEVEL: 3
@@ -46,7 +47,7 @@ const PERMISSION_SCANNERS = [
46
47
{
47
48
name : 'user-user' ,
48
49
async scan ( a ) {
49
- const { reading, actor, permission_options } = a . values ( ) ;
50
+ const { reading, actor, permission_options, state } = a . values ( ) ;
50
51
if ( ! ( actor . type instanceof UserActorType ) ) {
51
52
return ;
52
53
}
@@ -85,11 +86,26 @@ const PERMISSION_SCANNERS = [
85
86
} ) ,
86
87
} ) ;
87
88
89
+ let should_continue = false ;
90
+ for ( const seen_actor of state . anti_cycle_actors ) {
91
+ if ( seen_actor . type . user . id === issuer_actor . type . user . id ) {
92
+ should_continue = true ;
93
+ break ;
94
+ }
95
+ }
96
+
97
+ if ( should_continue ) continue ;
98
+
88
99
// const issuer_perm = await this.check(issuer_actor, row.permission);
89
- const issuer_reading = await a . icall ( 'scan' , issuer_actor , row . permission ) ;
100
+ const issuer_reading = await a . icall (
101
+ 'scan' , issuer_actor , row . permission , undefined , state ) ;
102
+
103
+ const has_terminal = reading_has_terminal ( { reading : issuer_reading } ) ;
104
+
90
105
reading . push ( {
91
106
$ : 'path' ,
92
107
via : 'user' ,
108
+ has_terminal,
93
109
permission : row . permission ,
94
110
data : row . extra ,
95
111
holder_username : actor . type . user . username ,
@@ -134,9 +150,13 @@ const PERMISSION_SCANNERS = [
134
150
if ( ! issuer_group . hasOwnProperty ( permission ) ) continue ;
135
151
const issuer_reading =
136
152
await a . icall ( 'scan' , issuer_actor , permission )
153
+
154
+ const has_terminal = reading_has_terminal ( { reading : issuer_reading } ) ;
155
+
137
156
reading . push ( {
138
157
$ : 'path' ,
139
158
via : 'hc-user-group' ,
159
+ has_terminal,
140
160
permission,
141
161
data : issuer_group [ permission ] ,
142
162
holder_username : actor . type . user . username ,
@@ -188,9 +208,12 @@ const PERMISSION_SCANNERS = [
188
208
189
209
const issuer_reading = await a . icall ( 'scan' , issuer_actor , row . permission ) ;
190
210
211
+ const has_terminal = reading_has_terminal ( { reading : issuer_reading } ) ;
212
+
191
213
reading . push ( {
192
214
$ : 'path' ,
193
215
via : 'user-group' ,
216
+ has_terminal,
194
217
// issuer: issuer_actor,
195
218
permission : row . permission ,
196
219
data : row . extra ,
@@ -240,6 +263,8 @@ const PERMISSION_SCANNERS = [
240
263
241
264
const issuer_actor = actor . get_related_actor ( UserActorType ) ;
242
265
const issuer_reading = await a . icall ( 'scan' , issuer_actor , permission_options ) ;
266
+
267
+ const has_terminal = reading_has_terminal ( { reading : issuer_reading } ) ;
243
268
244
269
for ( const permission of permission_options ) {
245
270
{
@@ -249,6 +274,7 @@ const PERMISSION_SCANNERS = [
249
274
reading . push ( {
250
275
$ : 'path' ,
251
276
permission,
277
+ has_terminal,
252
278
source : 'user-app-implied' ,
253
279
by : 'user-app-hc-1' ,
254
280
data : implied ,
@@ -267,6 +293,7 @@ const PERMISSION_SCANNERS = [
267
293
reading . push ( {
268
294
$ : 'path' ,
269
295
permission,
296
+ has_terminal,
270
297
source : 'user-app-implied' ,
271
298
by : 'user-app-hc-2' ,
272
299
data : implicit_permissions [ permission ] ,
@@ -301,10 +328,12 @@ const PERMISSION_SCANNERS = [
301
328
} ) ( ) ;
302
329
const issuer_actor = actor . get_related_actor ( UserActorType ) ;
303
330
const issuer_reading = await a . icall ( 'scan' , issuer_actor , row . permission ) ;
331
+ const has_terminal = reading_has_terminal ( { reading : issuer_reading } ) ;
304
332
reading . push ( {
305
333
$ : 'path' ,
306
334
via : 'user-app' ,
307
335
permission : row . permission ,
336
+ has_terminal,
308
337
data : row . extra ,
309
338
issuer_username : actor . type . user . username ,
310
339
reading : issuer_reading ,
0 commit comments