1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
|
*** Settings ***
Library json
Library Collections
Resource ../../variable/common_variable.txt
Resource ../../variable/policy_object_default.txt
Resource manage_object_body.robot
*** Variables ***
*** Keywords ***
ObjectListOperation
[Documentation]
... 描述:入口,opAction参数可为'add','update','disable','enable'
... 参数:returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
... objectList: 必传,字典类型。字典内可选参数信息:
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
... 多个对象处理
[Arguments] ${returnData} ${objectList} ${opAction}
Log Call ObjectListOperation
${objectListJson} Set Variable [
FOR ${object} IN @{objectList}
${json} ObjectOrganize ${object} ${opAction}
${objectListJson} Set Variable ${objectListJson}${json},
END
${objectListJson}= Replace String Using Regexp ${objectListJson} ,$ ]
# 转为json结构并返回
${dict} Create Dictionary opAction=${opAction} returnData=${returnData} objectList=replace:objectList
${bodyJson} json.Dumps ${dict} ensure_ascii=False
${json} Replace String ${bodyJson} "replace:objectList" ${objectListJson}
Log Object_Request_Body-${json}
[Return] ${json}
CategoryListOperation
[Documentation]
... 描述:入口,opAction参数可为'add','update','disable','enable'
... 参数:returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
... objectList: 必传,字典类型。字典内可选参数信息:
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
... 多个对象处理
[Arguments] ${returnData} ${objectList} ${opAction}
Log Call ObjectListOperation
${objectListJson} Set Variable [
FOR ${object} IN @{objectList}
${json} CategoryOrganize ${object} ${opAction}
${objectListJson} Set Variable ${objectListJson}${json},
END
${objectListJson}= Replace String Using Regexp ${objectListJson} ,$ ]
# 转为json结构并返回
${dict} Create Dictionary opAction=${opAction} returnData=${returnData} categoryList=replace:objectList
${bodyJson} json.Dumps ${dict} ensure_ascii=False
${json} Replace String ${bodyJson} "replace:objectList" ${json}
Log Category_Request_Body-${json}
# 转为json结构并返回
# ${dict} Create Dictionary opAction=${opAction} returnData=${returnData} objectList=replace:objectList
# ${bodyJson} json.Dumps ${dict} ensure_ascii=False
# ${json} Replace String ${bodyJson} "replace:objectList" ${objectListJson}
# Log Object_Request_Body-${json}
[Return] ${json}
ObjectOperation
[Documentation]
... 描述:入口,opAction参数可为'add','update','disable','enable'
... 参数:returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
... object: 必传,字典类型。字典内可选参数信息:
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
... 单个策略处理
[Arguments] ${returnData} ${object} ${opAction}
Log Call ObjectOperation
${json} ObjectOrganize ${object} ${opAction}
# 转为json结构并返回
${dict} Create Dictionary opAction=${opAction} returnData=${returnData} objectList=replace:objectList
${bodyJson} json.Dumps ${dict} ensure_ascii=False
${json} Replace String ${bodyJson} "replace:objectList" ${json}
Log Object_Request_Body-${json}
[Return] ${json}
InstallOperation
[Documentation]
... 描述:入口,opAction参数可为'add','update','disable','enable'
... 参数:returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
... object: 必传,字典类型。字典内可选参数信息:
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
... 单个策略处理
[Arguments] ${object}
Log Call ObjectOperation
${json} ObjectOrganize ${object}
# 转为json结构并返回
${dict} Create Dictionary opAction=${opAction} returnData=${returnData} objectList=replace:objectList
${bodyJson} json.Dumps ${dict} ensure_ascii=False
${json} Replace String ${bodyJson} "replace:objectList" ${json}
Log Object_Request_Body-${json}
[Return] ${json}
FeatureOperation
[Documentation]
... 描述:入口,opAction参数可为'add','update','disable','enable'
... 参数:returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
... object: 必传,字典类型。字典内可选参数信息:
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
... 单个策略处理
[Arguments] ${returnData} ${object} ${opAction}
Log Call ObjectOperation
${json} ObjectOrganize ${object} ${opAction}
# 转为json结构并返回
${dict} Create Dictionary opAction=${opAction} returnData=${returnData} objectList=replace:objectList
${bodyJson} json.Dumps ${dict} ensure_ascii=False
${json} Replace String ${bodyJson} "replace:objectList" ${json}
Log Object_Request_Body-${json}
[Return] ${json}
CategoryOperation
[Documentation]
... 描述:入口,opAction参数可为'add','update','disable','enable'
... 参数:returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
... object: 必传,字典类型。字典内可选参数信息:
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
... 单个策略处理
[Arguments] ${returnData} ${category} ${opAction}
Log Call ObjectOperation
${json} CategoryOrganize ${category} ${opAction}
# 转为json结构并返回
${dict} Create Dictionary opAction=${opAction} returnData=${returnData} list=replace:objectList
${bodyJson} json.Dumps ${dict} ensure_ascii=False
${json} Replace String ${bodyJson} "replace:objectList" ${json}
Log Category_Request_Body-${json}
[Return] ${json}
listorone
[Arguments] ${object}
${addItemList} Evaluate str('addItemList'in${object}.keys())
log ${addItemList}
${subObjectIds} Evaluate str('subObjectIds'in${object}.keys())
log ${subObjectIds}
${objectparm} set variable ${addItemList} ${subObjectIds}
should contain x times ${objectparm} True 1
# Should Not Be Empty ${object}[addItemList] or Should Not Be Empty ${object}[subObjectIds]
ObjectOrganize
[Documentation]
... 描述:入口,opAction参数可为'add','update','disable','enable'
... object: 必传,字典类型。字典内可选参数信息:
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
... 单个策略转换为json
[Arguments] ${object} ${opAction}
Log Call ObjectOrganize
${emptyList} Create List
${returnDict} Create Dictionary
# 断言必传参数
# Should Not Be Empty ${object}[objectType]
# Set To Dictionary ${returnDict} objectType=${object}[objectType]
#新增时addItemList不能为空
Run Keyword If "${opAction}"=="add" listorone ${object}
Run Keyword If "${opAction}"=="update" Should Not Be Empty ${object}[objectId]
Run Keyword If "${opAction}"=="enable" Should Not Be Empty ${object}[objectId]
Run Keyword If "${opAction}"=="disable" Should Not Be Empty ${object}[objectId]
${return} ${objectId} Run Keyword And Ignore Error Get From Dictionary ${object} objectId
Run Keyword If "${return}"=="FAIL" or "${objectId}"=="${EMPTY}" Set To Dictionary ${returnDict} objectId=${EMPTY}
... ELSE Set To Dictionary ${returnDict} objectId=${objectId}
${return} ${objectType} Run Keyword And Ignore Error Get From Dictionary ${object} objectType
${objectTypeV} Run Keyword If "${return}"!="FAIL" and "${objectType}"!="${EMPTY}" Evaluate '${objectType}'.lower()
... ELSE Evaluate '${Default_ObjectType}'.lower()
Set To Dictionary ${returnDict} objectType=${objectTypeV}
#enable disable直接返回json
Run Keyword And Return If "${opAction}"=="enable" or "${opAction}"=="disable" ManageEnableAndDisable ${object} ${returnDict} ${opAction}
# 取可选参数,为传入设置默认值
Set To Dictionary ${returnDict} objectType=${objectTypeV}
${return} ${objectSubType} Run Keyword And Ignore Error Get From Dictionary ${object} objectSubType
Run Keyword If "${return}"!="FAIL" and "${objectSubType}"!="${EMPTY}" Set To Dictionary ${returnDict} objectSubType=${objectSubType}
... ELSE Set To Dictionary ${returnDict} objectSubType=${Default_ObjectSubType}
${return} ${isValid} Run Keyword And Ignore Error Get From Dictionary ${object} isValid
Run Keyword If "${return}"=="FAIL" or "${isValid}"=="${EMPTY}" Set To Dictionary ${returnDict} isValid=${Default_IsValid}
... ELSE Set To Dictionary ${returnDict} isValid=${isValid}
${return} ${isInitialize} Run Keyword And Ignore Error Get From Dictionary ${object} isInitialize
Run Keyword If "${return}"=="FAIL" or "${isInitialize}"=="${EMPTY}" Set To Dictionary ${returnDict} isInitialize=${Default_IsInitialize}
... ELSE Set To Dictionary ${returnDict} isInitialize=${isInitialize}
${return} ${isExclusion} Run Keyword And Ignore Error Get From Dictionary ${object} isExclusion
Run Keyword If "${return}"=="FAIL" or "${isExclusion}"=="${EMPTY}" Set To Dictionary ${returnDict} isExclusion=${Default_IsExclusion}
... ELSE Set To Dictionary ${returnDict} isExclusion=${isExclusion}
${return} ${objectName} Run Keyword And Ignore Error Get From Dictionary ${object} objectName
Run Keyword If "${return}"=="FAIL" or "${objectName}"=="${EMPTY}" Set To Dictionary ${returnDict} objectName=${Default_ObjectName}
... ELSE Set To Dictionary ${returnDict} objectName=${objectName}
${return} ${objectDesc} Run Keyword And Ignore Error Get From Dictionary ${object} objectDesc
Run Keyword If "${return}"!="FAIL" and "${objectDesc}"!="${EMPTY}" Set To Dictionary ${returnDict} objectDesc=${objectDesc}
... ELSE Set To Dictionary ${returnDict} objectDesc=${Default_ObjectDesc}
${return} ${subObjectIds} Run Keyword And Ignore Error Get From Dictionary ${object} subObjectIds
Run Keyword If "${return}"!="FAIL" and "${subObjectIds}"!="${EMPTY}" and "${subObjectIds}"!="${None}" Set To Dictionary ${returnDict} subObjectIds=${subObjectIds}
... ELSE Set Variable ${emptyList}
${return} ${iconColor} Run Keyword And Ignore Error Set Variable ${object['iconColor']}
Run Keyword If "${return}"!="FAIL" Set To Dictionary ${returnDict} iconColor=${iconColor}
#补充ip learning对象
${return} ${fromFqdns} Run Keyword And Ignore Error Get From Dictionary ${object} fromFqdns
Run Keyword If "${return}"!="FAIL" Set To Dictionary ${returnDict} fromFqdns=${fromFqdns}
#... ELSE Set To Dictionary ${returnDict} fromFqdns=${emptyList}
log ${fromFqdns}
${return} ${fromProtocol} Run Keyword And Ignore Error Get From Dictionary ${object} fromProtocol
Run Keyword If "${return}"!="FAIL" and "${fromProtocol}"!="${EMPTY}" Set To Dictionary ${returnDict} fromProtocol=${fromProtocol}
#... ELSE Set To Dictionary ${returnDict} fromProtocol=${Default_fromProtocol}
${return} ${learningDepth} Run Keyword And Ignore Error Get From Dictionary ${object} learningDepth
Run Keyword If "${return}"!="FAIL" and "${learningDepth}"!="${EMPTY}" Set To Dictionary ${returnDict} learningDepth=${learningDepth}
#... ELSE Set To Dictionary ${returnDict} learningDepth=${Default_learningDepth}
${return} ${agingTime} Run Keyword And Ignore Error Get From Dictionary ${object} agingTime
Run Keyword If "${return}"!="FAIL" and "${fromProtocol}"!="${EMPTY}" Set To Dictionary ${returnDict} agingTime=${agingTime}
#... ELSE Set To Dictionary ${returnDict} agingTime=${Default_agingTime}
${return} ${voteClientNum} Run Keyword And Ignore Error Get From Dictionary ${object} voteClientNum
Run Keyword If "${return}"!="FAIL" and "${fromProtocol}"!="${EMPTY}" Set To Dictionary ${returnDict} voteClientNum=${voteClientNum}
#... ELSE Set To Dictionary ${returnDict} voteClientNum=${Default_voteClientNum}
${return} ${learnedIpLimit} Run Keyword And Ignore Error Get From Dictionary ${object} learnedIpLimit
Run Keyword If "${return}"!="FAIL" and "${fromProtocol}"!="${EMPTY}" Set To Dictionary ${returnDict} learnedIpLimit=${learnedIpLimit}
#... ELSE Set To Dictionary ${returnDict} learnedIpLimit=${Default_learnedIpLimit}
# 处理AddItemList
${return} ${addItemList} Run Keyword And Ignore Error Get From Dictionary ${object} addItemList
Run Keyword If "${return}"!="FAIL" and "${addItemList}"!="${EMPTY}" ManageAddItemListNew ${addItemList} ${returnDict} ${objectTypeV} ${objectSubType}
# 处理UpdateItemList
${return} ${updateItemList} Run Keyword And Ignore Error Get From Dictionary ${object} updateItemList
Run Keyword If "${opAction}"=="update" and "${return}"!="FAIL" and "${updateItemList}"!="${EMPTY}" ManageUpdateItemList ${updateItemList} ${returnDict} ${objectTypeV} ${objectSubType}
# 处理deleteItemIds
${return} ${deleteItemIds} Run Keyword And Ignore Error Get From Dictionary ${object} deleteItemIds
Run Keyword If "${opAction}"=="update" and "${return}"!="FAIL" and "${deleteItemIds}"!="${EMPTY}" ManageDeleteItemIds ${deleteItemIds} ${returnDict}
# 转为json结构并返回
${json} json.Dumps ${returnDict} ensure_ascii=False
Log Object-${json}
[Return] ${json}
Categorylistorone
[Arguments] ${category}
${addItemList} Evaluate str('fqdnList'in${category}.keys())
log ${addItemList}
${objectparm} set variable ${addItemList}
should contain x times ${objectparm} True 1
# Should Not Be Empty ${object}[addItemList] or Should Not Be Empty ${object}[subObjectIds]
CategoryOrganize
[Documentation]
... 描述:入口,opAction参数可为'add','update','disable','enable'
... object: 必传,字典类型。字典内可选参数信息:
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
... 单个策略转换为json
[Arguments] ${category} ${opAction}
Log Call CategoryOrganize
${emptyList} Create List
${returnDict} Create Dictionary
# 断言必传参数
# Should Not Be Empty ${object}[objectType]
# Set To Dictionary ${returnDict} objectType=${object}[objectType]
#新增时addItemList不能为空
Run Keyword If "${opAction}"=="add" Categorylistorone ${category}
Run Keyword If "${opAction}"=="update" Should Not Be Empty ${category}[categoryId]
Run Keyword If "${opAction}"=="update" Should Not Be Empty ${category}[objectId]
${return} ${objectId} Run Keyword And Ignore Error Get From Dictionary ${category} objectId
Run Keyword If "${return}"=="FAIL" or "${objectId}"=="${EMPTY}" Set To Dictionary ${returnDict} objectId=${EMPTY}
... ELSE Set To Dictionary ${returnDict} objectId=${objectId}
${return} ${categoryId} Run Keyword And Ignore Error Get From Dictionary ${category} categoryId
Run Keyword If "${return}"=="FAIL" or "${categoryId}"=="${EMPTY}" Set To Dictionary ${returnDict} categoryId=${EMPTY}
... ELSE Set To Dictionary ${returnDict} categoryId=${categoryId}
${return} ${categoryType} Run Keyword And Ignore Error Get From Dictionary ${category} categoryType
${categoryTypeV} Run Keyword If "${return}"!="FAIL" and "${categoryType}"!="${EMPTY}" Evaluate '${categoryType}'.lower()
... ELSE Evaluate '${Default_CategoryType}'.lower()
Set To Dictionary ${returnDict} categoryType=${categoryTypeV}
# 取可选参数,为传入设置默认值
Set To Dictionary ${returnDict} categoryType=${categoryTypeV}
# ${return} ${isDelete} Run Keyword And Ignore Error Get From Dictionary ${category} isDelete
# Run Keyword If "${return}"=="FAIL" or "${isDelete}"=="${EMPTY}" Set To Dictionary ${returnDict} isDelete=${Default_IsDelete}
# ... ELSE Set To Dictionary ${returnDict} isDelete=${isDelete}
${return} ${categoryDimension} Run Keyword And Ignore Error Get From Dictionary ${category} categoryDimension
Run Keyword If "${return}"=="FAIL" or "${categoryDimension}"=="${EMPTY}" Set To Dictionary ${returnDict} categoryDimension=${Default_Dimension}
... ELSE Set To Dictionary ${returnDict} categoryDimension=${categoryDimension}
${return} ${categoryOrigin} Run Keyword And Ignore Error Get From Dictionary ${category} categoryOrigin
Run Keyword If "${return}"=="FAIL" or "${categoryOrigin}"=="${EMPTY}" Set To Dictionary ${returnDict} categoryOrigin=${Default_Origin}
... ELSE Set To Dictionary ${returnDict} categoryOrigin=${categoryOrigin}
${return} ${isInitialize} Run Keyword And Ignore Error Get From Dictionary ${category} isInitialize
Run Keyword If "${return}"=="FAIL" or "${isInitialize}"=="${EMPTY}" Set To Dictionary ${returnDict} isInitialize=${Default_IsInitialize}
... ELSE Set To Dictionary ${returnDict} isInitialize=${isInitialize}
${return} ${categoryName} Run Keyword And Ignore Error Get From Dictionary ${category} categoryName
Run Keyword If "${return}"=="FAIL" or "${categoryName}"=="${EMPTY}" Set To Dictionary ${returnDict} categoryName=${Default_ObjectName}
... ELSE Set To Dictionary ${returnDict} categoryName=${categoryName}
${return} ${categoryDesc} Run Keyword And Ignore Error Get From Dictionary ${category} categoryDesc
Run Keyword If "${return}"!="FAIL" and "${categoryDesc}"!="${EMPTY}" Set To Dictionary ${returnDict} categoryDesc=${categoryDesc}
... ELSE Set To Dictionary ${returnDict} categoryDesc=${Default_ObjectDesc}
${return} ${objectSubType} Run Keyword And Ignore Error Get From Dictionary ${category} objectSubType
Run Keyword If "${return}"!="FAIL" and "${objectSubType}"!="${EMPTY}" Set To Dictionary ${returnDict} objectSubType=${objectSubType}
... ELSE Set To Dictionary ${returnDict} objectSubType=${Default_ObjectSubType}
# 处理AddItemList
${return} ${addItemList} Run Keyword And Ignore Error Get From Dictionary ${category} fqdnList
Run Keyword If "${opAction}"=="add" Should Not Be Empty ${addItemList}
# Run Keyword If "${return}"!="FAIL" and "${addItemList}"!="${EMPTY}" ManageAddItemListNew ${addItemList} ${returnDict} ${categoryTypeV} ${objectSubType}
ManageAddItemListNew ${addItemList} ${returnDict} ${categoryTypeV} ${objectSubType}
# 删除无用判断key值objectSubType
Remove From Dictionary ${returnDict} objectSubType
# 转为json结构并返回
${json} json.Dumps ${returnDict} ensure_ascii=False
Log Object-${json}
[Return] ${json}
ManageEnableAndDisable
[Documentation]
... 启用与禁用时调用
[Arguments] ${object} ${returnDict} ${opAction}
Run Keyword If "${opAction}"=="enable" Set To Dictionary ${returnDict} isValid=1
Run Keyword If "${opAction}"=="disable" Set To Dictionary ${returnDict} isValid=0
${json} json.Dumps ${returnDict} ensure_ascii=False
Log Object-${json}
[Return] ${json}
ManageAddItemListNew
# 处理addItemList数组
[Arguments] ${addItemList} ${returnDict} ${type} ${subType}
Log Call ManageAddItemListNew
${itemList} Create List
FOR ${item} IN @{addItemList}
${itemNew} Run Keyword If '${type}'=='ip' and '${subType}'=="geo_location" ManageGeoItem ${item} ${subType} add
... ELSE IF '${type}'=='ip' ManageIpItem ${item} ${subType} add
... ELSE IF '${type}'=='url' or ('${type}'=='fqdn' and '${subType}'!='category') or '${type}'=='keywords' or '${type}'=='subscriberid' or '${type}'=='fqdn_category' or '${type}'=='account' or '${type}'=='app_id' or '${type}'=='mobile_identity' or '${type}'=='apn'
... ManageStrItem ${item} ${type} add
... ELSE IF '${type}'=='file_type' ManageFileItem ${item} ${type} add
... ELSE IF '${type}'=='fqdn' and '${subType}'=='category' ManageCategory ${item} ${type} add
... ELSE IF '${type}'=='http_signature' ManageExtensionStrItem ${item} ${type} add
... ELSE IF '${type}'=='file_size' or '${type}'=='file_integrity_rate' ManageNumberItem ${item} ${type} add
... ELSE Fail
Append To List ${itemList} ${itemNew}
END
Run Keyword If '${subType}'=='category' Set To Dictionary ${returnDict} fqdnList=${itemList}
... ELSE Set To Dictionary ${returnDict} addItemList=${itemList}
ManageUpdateItemList
[Documentation]
... 处理updateItemList
[Arguments] ${updateItemList} ${returnDict} ${type} ${subType}
${itemList} Create List
FOR ${item} IN @{updateItemList}
${itemId} Get From Dictionary ${item} itemId
${itemNew} Run Keyword If '${type}'=='ip' and '${subType}'=="geo_location" ManageGeoItem ${item} ${subType} update
... ELSE IF '${type}'=='ip' ManageIpItem ${item} ${subType} update
... ELSE IF '${type}'=='url' or '${type}'=='fqdn' or '${type}'=='keywords' or '${type}'=='subscriberid' or '${type}'=='fqdn_category' or '${type}'=='account' or '${type}'=='app_id'
... ManageStrItem ${item} ${type} update
... ELSE IF '${type}'=='file_type' ManageFileItem ${item} ${type} update
... ELSE IF '${type}'=='http_signature' ManageExtensionStrItem ${item} ${type} update
... ELSE IF '${type}'=='file_size' or '${type}'=='file_integrity_rate' ManageNumberItem ${item} ${type} update
... ELSE Fail
Set To Dictionary ${itemNew} itemId=${itemId}
#由于接口更新时是否内置字段会导致40014001,策略对象单元不可改是否为内置(isInitialize)参数状态,这里去掉是否内置字段
Remove From Dictionary ${itemNew} isInitialize
Append To List ${itemList} ${itemNew}
END
Set To Dictionary ${returnDict} updateItemList=${itemList}
ManageIpItem
[Documentation]
... ip item处理
[Arguments] ${item} ${subType} ${action}
Log Call ManageIpItem
${return} ${isSession} Run Keyword And Ignore Error Get From Dictionary ${item} isSession
${isSession} Run Keyword If "${return}"!="FAIL" Set Variable ${isSession} ELSE Set Variable ${EMPTY}
Run Keyword If "${action}"=="add" Should Not Be Empty ${isSession}
${return} ${ip} Run Keyword And Ignore Error Get From Dictionary ${item} ip
${ip} Run Keyword If "${return}"!="FAIL" Set Variable ${ip} ELSE Set Variable ${EMPTY}
Run Keyword If "${action}"=="add" Should Not Be Empty ${ip}
${return} ${port} Run Keyword And Ignore Error Get From Dictionary ${item} port
Run Keyword If "${action}"=="add" Should Not Be Empty ${port}
#Run Keyword If "${action}"=="add" Dictionary Should Contain Key ${item} direction
#${return} ${direction} Run Keyword And Ignore Error Get From Dictionary ${item} direction
#${direction} Run Keyword If "${return}"!="FAIL" Set Variable ${direction} ELSE Set Variable ${EMPTY}
#Run Keyword If "${action}"=="add" Dictionary Should Contain Key ${item} protocol
${return} ${protocol} Run Keyword And Ignore Error Get From Dictionary ${item} protocol
${protocol} Run Keyword If "${return}"!="FAIL" Set Variable ${protocol} ELSE Set Variable ${EMPTY}
${return} ${isInitialize} Run Keyword And Ignore Error Set Variable ${item['isInitialize']}
${isInitialize} Run Keyword If "${return}"!="FAIL" Set Variable ${isInitialize}
... ELSE Set Variable ${EMPTY}
${return} ${itemName} Run Keyword And Ignore Error Set Variable ${item['itemName']}
${itemName} Run Keyword If "${return}"!="FAIL" Set Variable ${itemName}
... ELSE Set Variable ${EMPTY}
${return} ${itemDesc} Run Keyword And Ignore Error Set Variable ${item['itemDesc']}
${itemDesc} Run Keyword If "${return}"!="FAIL" Set Variable ${itemDesc}
... ELSE Set Variable ${EMPTY}
${itemNew} Create Dictionary
Run Keyword If "${isSession}"!="${EMPTY}" Set To Dictionary ${itemNew} isSession=${isSession}
Run Keyword If "${ip}"!="${EMPTY}" Set To Dictionary ${itemNew} ip=${ip}
Run Keyword If "${port}"!="${EMPTY}" Set To Dictionary ${itemNew} port=${port}
#Run Keyword If "${direction}"!="${EMPTY}" Set To Dictionary ${itemNew} direction=${direction}
Run Keyword If "${protocol}"!="${EMPTY}" Set To Dictionary ${itemNew} protocol=${protocol}
Run Keyword If "${isInitialize}"!="${EMPTY}" Set To Dictionary ${itemNew} isInitialize=${isInitialize}
Run Keyword If "${itemName}"!="${EMPTY}" Set To Dictionary ${itemNew} itemName=${itemName}
Run Keyword If "${itemDesc}"!="${EMPTY}" Set To Dictionary ${itemNew} itemDesc=${itemDesc}
[Return] ${itemNew}
ManageGeoItem
[Documentation]
... ip item处理
[Arguments] ${item} ${subType} ${action}
Log ManageGeoItem
${return} ${keywordArray} Run Keyword And Ignore Error Get From Dictionary ${item} keywordArray
${keywordArray} Run Keyword If "${return}"!="FAIL" Set Variable ${keywordArray} ELSE Set Variable ${EMPTY}
${itemNew} Create Dictionary
${kArray} Create List
Run Keyword If "${keywordArray}"!="${EMPTY}" Append To List ${kArray} ${keywordArray}
Run Keyword If "${keywordArray}"!="${EMPTY}" Set To Dictionary ${itemNew} keywordArray=${kArray}
[Return] ${itemNew}
ManageStrItem
[Documentation]
... 字符串item处理
[Arguments] ${item} ${type} ${action}
Log Call ManageStrItem
${return} ${keywordArray} Run Keyword And Ignore Error Set Variable ${item['keywordArray']}
${keywordArray} Run Keyword If "${return}"!="FAIL" Set Variable ${keywordArray} ELSE Set Variable ${EMPTY}
Run Keyword If "${action}"=="add" Should Not Be Empty ${keywordArray}
${array} Evaluate re.split('[,]', '${keywordArray}') re
Run Keyword If "${action}"=="add" Dictionary Should Contain Key ${item} isHexbin
${return} ${isHexbin} Run Keyword And Ignore Error Get From Dictionary ${item} isHexbin
${isHexbin} Run Keyword If "${return}"!="FAIL" Set Variable ${isHexbin}
... ELSE Set Variable ${EMPTY}
${return} ${isInitialize} Run Keyword And Ignore Error Set Variable ${item['isInitialize']}
${isInitialize} Run Keyword If "${return}"!="FAIL" Set Variable ${isInitialize}
... ELSE Set Variable ${EMPTY}
${return} ${itemName} Run Keyword And Ignore Error Set Variable ${item['itemName']}
${itemName} Run Keyword If "${return}"!="FAIL" Set Variable ${itemName}
... ELSE Set Variable ${EMPTY}
${return} ${itemDesc} Run Keyword And Ignore Error Set Variable ${item['itemDesc']}
${itemDesc} Run Keyword If "${return}"!="FAIL" Set Variable ${itemDesc}
... ELSE Set Variable ${EMPTY}
${itemNew} Create Dictionary
Run Keyword If "${keywordArray}"!="${EMPTY}" Set To Dictionary ${itemNew} keywordArray=${array}
Run Keyword If "${isHexbin}"!="${EMPTY}" Set To Dictionary ${itemNew} isHexbin=${isHexbin}
Run Keyword If "${isInitialize}"!="${EMPTY}" Set To Dictionary ${itemNew} isInitialize=${isInitialize}
Run Keyword If "${itemName}"!="${EMPTY}" Set To Dictionary ${itemNew} itemName=${itemName}
Run Keyword If "${itemDesc}"!="${EMPTY}" Set To Dictionary ${itemNew} itemDesc=${itemDesc}
[Return] ${itemNew}
ManageCategory
[Documentation]
... 字符串item处理
[Arguments] ${item} ${type} ${action}
Log Call ManageStrItem
${return} ${fqdn} Run Keyword And Ignore Error Set Variable ${item['fqdn']}
${fqdn} Run Keyword If "${return}"!="FAIL" Set Variable ${fqdn} ELSE Set Variable ${EMPTY}
Run Keyword If "${action}"=="add" Should Not Be Empty ${fqdn}
${itemNew} Create Dictionary
Run Keyword If "${fqdn}"!="${EMPTY}" Set To Dictionary ${itemNew} fqdn=${fqdn}
[Return] ${itemNew}
ManageFileItem
[Documentation]
... 接口未说明,待接口说明字段类型之后再完善
[Arguments] ${item} ${type} ${action}
Log Call ManageFileItem
[Return] ${item}
ManageExtensionStrItem
[Documentation]
... http_signature参数说明
[Arguments] ${item} ${type} ${action}
Log Call ManageExtensionStrItem
${return} ${district} Run Keyword And Ignore Error Get From Dictionary ${item} district
${district} Run Keyword If "${return}"!="FAIL" Set Variable ${district} ELSE Set Variable ${EMPTY}
Run Keyword If "${action}"=="add" Should Not Be Empty ${district}
${itemNew} ManageStrItem ${item} ${type} ${action}
Run Keyword If "${district}"!="${EMPTY}" Set To Dictionary ${itemNew} district=${district}
[Return] ${itemNew}
ManageNumberItem
[Documentation]
... 接口未说明,待接口说明字段类型之后再完善
[Arguments] ${item} ${type} ${action}
Log Call ManageNumberItem
[Return] ${item}
ManageDeleteItemIds
[Documentation]
... 处理deleteItemIds
... ${1},${2},${3} -> [1,2,3]
[Arguments] ${deleteItemIds} ${returnDict}
${list} Evaluate re.split('[,]', '${deleteItemIds}') re
${list1} Create List
FOR ${var} IN @{list}
${var} Run Keyword If '${var}'.isdigit() Evaluate int('${var}')
... ELSE Set Variable ${var}
Append To List ${list1} ${var}
END
Set To Dictionary ${returnDict} deleteItemIds=${list1}
GetObjectIds
[Documentation]
... 获取结果中的对象ID
[Arguments] ${value}
Log Call Get-ObjectIds
${objectIds} Create List
${objectIdsTemp} Set Variable ${EMPTY}
${return} ${data} Run Keyword And Ignore Error Get From Dictionary ${value} data
Return From Keyword If "${return}"=="FAIL" ${objectIdsTemp}
FOR ${object} IN @{value['data']['objectList']}
Append To List ${objectIds} ${object['objectId']}
END
${json} json.Dumps ${objectIds} ensure_ascii=False
${json} Remove String ${json} [
${json} Remove String ${json} ]
[Return] ${json}
getObjectListIds
[Documentation]
... 获取结果中的对象ID
[Arguments] ${value}
Log Call Get-ObjectIds
${objectIds} Create List
${objectIdsTemp} Set Variable ${EMPTY}
${return} ${data} Run Keyword And Ignore Error Get From Dictionary ${value} data
Return From Keyword If "${return}"=="FAIL" ${objectIdsTemp}
FOR ${object} IN @{value['data']['objectList']}
Append To List ${objectIds} ${object['objectId']}
END
[Return] ${objectIds}
GetCategoryIds
[Documentation]
... 获取结果中的对象ID
[Arguments] ${value}
Log Call Get-ObjectIds
${CategoryIds} Create List
${CategoryTemp} Set Variable ${EMPTY}
${return} ${data} Run Keyword And Ignore Error Get From Dictionary ${value} data
Return From Keyword If "${return}"=="FAIL" ${CategoryTemp}
FOR ${category} IN @{value['data']['list']}
Append To List ${CategoryIds} ${category['categoryId']}
END
${json} json.Dumps ${CategoryIds} ensure_ascii=False
${json} Remove String ${json} [
${json} Remove String ${json} ]
[Return] ${json}
GetCategoryObjIds
[Documentation]
... 获取Category结果中的对象ID
[Arguments] ${value}
Log Call Get-CategoryObjectIds
${CategoryObjIds} Create List
${CategoryTemp} Set Variable ${EMPTY}
${return} ${data} Run Keyword And Ignore Error Get From Dictionary ${value} data
Return From Keyword If "${return}"=="FAIL" ${CategoryTemp}
FOR ${category} IN @{value['data']['list']}
Append To List ${CategoryObjIds} ${category['objectId']}
END
${json} json.Dumps ${CategoryObjIds} ensure_ascii=False
${json} Remove String ${json} [
${json} Remove String ${json} ]
[Return] ${json}
|