@@ -149,21 +149,28 @@ async function _is_object_version_fit(req, predicate, value) {
149149 return res ;
150150}
151151
152- async function has_bucket_policy_permission ( policy , account , method , arn_path , req , disallow_public_access = false ,
153- should_pass_principal = true ) {
152+ async function has_bucket_policy_permission ( policy , account , method , arn_path , req ,
153+ { disallow_public_access = false , should_pass_principal = true } = { } ) {
154154 const [ allow_statements , deny_statements ] = _ . partition ( policy . Statement , statement => statement . Effect === 'Allow' ) ;
155155
156156 // the case where the permission is an array started in op get_object_attributes
157157 const method_arr = Array . isArray ( method ) ? method : [ method ] ;
158158
159159 // look for explicit denies
160160 const res_arr_deny = await is_statement_fit_of_method_array (
161- deny_statements , account , method_arr , arn_path , req , undefined , should_pass_principal ) ; // No need to disallow in "DENY"
161+ deny_statements , account , method_arr , arn_path , req , {
162+ disallow_public_access : false , // No need to disallow in "DENY"
163+ should_pass_principal
164+ }
165+ ) ;
162166 if ( res_arr_deny . every ( item => item ) ) return 'DENY' ;
163167
164168 // look for explicit allows
165169 const res_arr_allow = await is_statement_fit_of_method_array (
166- allow_statements , account , method_arr , arn_path , req , disallow_public_access , should_pass_principal ) ;
170+ allow_statements , account , method_arr , arn_path , req , {
171+ disallow_public_access,
172+ should_pass_principal
173+ } ) ;
167174 if ( res_arr_allow . every ( item => item ) ) return 'ALLOW' ;
168175
169176 // implicit deny
@@ -219,13 +226,13 @@ function _is_resource_fit(arn_path, statement) {
219226}
220227
221228async function is_statement_fit_of_method_array ( statements , account , method_arr , arn_path , req ,
222- disallow_public_access = false , should_pass_principal = true ) {
229+ { disallow_public_access = false , should_pass_principal = true } = { } ) {
223230 return Promise . all ( method_arr . map ( method_permission =>
224- _is_statements_fit ( statements , account , method_permission , arn_path , req , disallow_public_access , should_pass_principal ) ) ) ;
231+ _is_statements_fit ( statements , account , method_permission , arn_path , req , { disallow_public_access, should_pass_principal } ) ) ) ;
225232}
226233
227- async function _is_statements_fit ( statements , account , method , arn_path , req , disallow_public_access = false ,
228- should_pass_principal = true ) {
234+ async function _is_statements_fit ( statements , account , method , arn_path , req ,
235+ { disallow_public_access = false , should_pass_principal = true } = { } ) {
229236 for ( const statement of statements ) {
230237 const action_fit = _is_action_fit ( method , statement ) ;
231238 const principal_fit = should_pass_principal ? _is_principal_fit ( account , statement , disallow_public_access ) : true ;
0 commit comments