@@ -1092,99 +1092,57 @@ impl<'cx> Dataflow<'cx> for PermissionDataflow {
1092
1092
let mut permissions_within_call: Vec < String > = vec ! [ ] ;
1093
1093
let intrinsic_func_type = intrinsic_argument. name . unwrap ( ) ;
1094
1094
1095
+ let ( resolver, regex_map) = match intrinsic_func_type {
1096
+ IntrinsicName :: RequestJiraSoftware => (
1097
+ interp. jira_software_permission_resolver ,
1098
+ interp. jira_software_regex_map ,
1099
+ ) ,
1100
+ IntrinsicName :: RequestJiraServiceManagement => (
1101
+ interp. jira_service_management_permission_resolver ,
1102
+ interp. jira_service_management_regex_map ,
1103
+ ) ,
1104
+ IntrinsicName :: RequestConfluence => (
1105
+ interp. confluence_permission_resolver ,
1106
+ interp. confluence_regex_map ,
1107
+ ) ,
1108
+ IntrinsicName :: RequestJira => {
1109
+ ( interp. jira_permission_resolver , interp. jira_regex_map )
1110
+ }
1111
+ IntrinsicName :: RequestBitbucket => (
1112
+ interp. bitbucket_permission_resolver ,
1113
+ interp. bitbucket_regex_map ,
1114
+ ) ,
1115
+ _ => unreachable ! ( "Invalid intrinsic function type" ) ,
1116
+ } ;
1117
+
1095
1118
if intrinsic_argument. first_arg . is_none ( ) {
1096
1119
interp. permissions . drain ( ..) ;
1097
1120
} else {
1098
1121
intrinsic_argument
1099
1122
. first_arg
1100
1123
. iter ( )
1101
1124
. for_each ( |first_arg_vec| {
1102
- if let Some ( second_arg_vec) = intrinsic_argument. second_arg . clone ( ) {
1103
- first_arg_vec. iter ( ) . for_each ( |first_arg| {
1104
- let first_arg = first_arg. replace ( & [ '\"' ] [ ..] , "" ) ;
1105
- second_arg_vec. iter ( ) . for_each ( |second_arg| {
1106
- if intrinsic_func_type
1107
- == IntrinsicName :: RequestJiraServiceManagement
1108
- {
1109
- let permissions = check_url_for_permissions (
1110
- interp. jira_service_management_permission_resolver ,
1111
- interp. jira_service_management_regex_map ,
1112
- translate_request_type ( Some ( second_arg) ) ,
1113
- & first_arg,
1114
- ) ;
1115
- permissions_within_call. extend_from_slice ( & permissions)
1116
- } else if intrinsic_func_type
1117
- == IntrinsicName :: RequestConfluence
1118
- {
1119
- let permissions = check_url_for_permissions (
1120
- interp. confluence_permission_resolver ,
1121
- interp. confluence_regex_map ,
1122
- translate_request_type ( Some ( second_arg) ) ,
1123
- & first_arg,
1124
- ) ;
1125
- permissions_within_call. extend_from_slice ( & permissions)
1126
- } else if intrinsic_func_type == IntrinsicName :: RequestJira {
1127
- let permissions = check_url_for_permissions (
1128
- interp. jira_permission_resolver ,
1129
- interp. jira_regex_map ,
1130
- translate_request_type ( Some ( second_arg) ) ,
1131
- & first_arg,
1132
- ) ;
1133
- permissions_within_call. extend_from_slice ( & permissions)
1134
- } else if intrinsic_func_type == IntrinsicName :: RequestBitbucket
1135
- {
1136
- let permissions = check_url_for_permissions (
1137
- interp. bitbucket_permission_resolver ,
1138
- interp. bitbucket_regex_map ,
1139
- translate_request_type ( Some ( second_arg) ) ,
1140
- & first_arg,
1141
- ) ;
1142
- permissions_within_call. extend_from_slice ( & permissions)
1143
- }
1125
+ first_arg_vec. iter ( ) . for_each ( |first_arg| {
1126
+ let first_arg = first_arg. replace ( & [ '\"' ] [ ..] , "" ) ;
1127
+ let request_types = intrinsic_argument
1128
+ . second_arg
1129
+ . as_ref ( )
1130
+ . map ( |args| {
1131
+ args. iter ( )
1132
+ . map ( |arg| translate_request_type ( Some ( arg) ) )
1133
+ . collect :: < Vec < _ > > ( )
1134
+ . into_iter ( )
1144
1135
} )
1145
- } )
1146
- } else {
1147
- first_arg_vec. iter ( ) . for_each ( |first_arg| {
1148
- let first_arg = first_arg. replace ( & [ '\"' ] [ ..] , "" ) ;
1149
- if intrinsic_func_type
1150
- == IntrinsicName :: RequestJiraServiceManagement
1151
- {
1152
- let permissions = check_url_for_permissions (
1153
- interp. jira_service_management_permission_resolver ,
1154
- interp. jira_service_management_regex_map ,
1155
- RequestType :: Get ,
1156
- & first_arg,
1157
- ) ;
1158
- permissions_within_call. extend_from_slice ( & permissions)
1159
- } else if intrinsic_func_type == IntrinsicName :: RequestConfluence {
1160
- let permissions = check_url_for_permissions (
1161
- interp. confluence_permission_resolver ,
1162
- interp. confluence_regex_map ,
1163
- RequestType :: Get ,
1164
- & first_arg,
1165
- ) ;
1166
- permissions_within_call. extend_from_slice ( & permissions)
1167
- } else if intrinsic_func_type == IntrinsicName :: RequestJira {
1168
- let permissions = check_url_for_permissions (
1169
- interp. jira_permission_resolver ,
1170
- interp. jira_regex_map ,
1171
- RequestType :: Get ,
1172
- & first_arg,
1173
- ) ;
1174
- permissions_within_call. extend_from_slice ( & permissions)
1175
- } else if intrinsic_func_type == IntrinsicName :: RequestBitbucket {
1176
- let permissions = check_url_for_permissions (
1177
- interp. bitbucket_permission_resolver ,
1178
- interp. bitbucket_regex_map ,
1179
- RequestType :: Get ,
1180
- & first_arg,
1181
- ) ;
1182
- permissions_within_call. extend_from_slice ( & permissions)
1183
- }
1184
- } )
1185
- }
1186
- } ) ;
1136
+ . unwrap_or_else ( || vec ! [ RequestType :: Get ] . into_iter ( ) ) ;
1187
1137
1138
+ for req_type in request_types {
1139
+ let permissions = check_url_for_permissions (
1140
+ resolver, regex_map, req_type, & first_arg,
1141
+ ) ;
1142
+ permissions_within_call. extend_from_slice ( & permissions) ;
1143
+ }
1144
+ } ) ;
1145
+ } ) ;
1188
1146
interp
1189
1147
. permissions
1190
1148
. retain ( |permissions| !permissions_within_call. contains ( permissions) ) ;
0 commit comments