备忘:关于NU告警系列代码探测规则
代码:
1 if semver.compare(dependency_version, installed_dep_version) == -1: 2 # print(dependency_version, installed_dep_version) 3 4 # 低版本为直接依赖 5 if dependency_name+"@"+dependency_version == direct_dep: 6 str_print("*****************************************************************") 7 str_print("error! NU1605 直接依赖版本版本低于间接依赖"+dependency_name) 8 str_print("直接版本:"+dependency_version) 9 str_print("间接依赖范围:"+ installed_dep_version_range) 10 11 error_type_count_dict['NU1605'] = error_type_count_dict['NU1605']+1 12 # 添加到冲突队列 13 if direct_dep+"_"+installed_dep_version not in error_directly_dependency_list: 14 error_directly_dependency_list.append(direct_dep+"_"+installed_dep_version) 15 16 # 低版本为间接依赖 17 elif dependency_name+"@"+installed_dep_version == installed_dep_direct_dep: 18 # print("*****************************************************************") 19 # print("error! NU1608 直接依赖版本高于间接依赖,但无交集", dependency_name) 20 # print("直接版本:", installed_dep_version) 21 # print("间接依赖范围:", dependency_version_range) 22 23 warning_count = warning_count + 1 24 25 # # 添加到冲突队列 26 # if direct_dep not in error_directly_dependency_list: 27 # error_directly_dependency_list.append(direct_dep) 28 29 # 高低版本呢均为间接依赖 30 else: 31 str_print("*****************************************************************") 32 str_print("error! NU1107 间接依赖之间无交集"+ dependency_name) 33 str_print("已安装版本:"+ installed_dep_version) 34 str_print("待检测依赖范围:"+ dependency_version_range) 35 str_print("冲突间接依赖范围:"+installed_dep_version_range) 36 37 error_type_count_dict['NU1107'] = error_type_count_dict['NU1107'] + 1 38 # 添加到冲突队列 39 if direct_dep not in error_directly_dependency_list: 40 error_directly_dependency_list.append(direct_dep) 41 else: 42 # 5.0.0 3.1.8 43 # print(dependency_version, installed_dep_version) 44 45 # 低版本为直接依赖 46 if dependency_name+"@"+installed_dep_version == installed_dep_direct_dep: 47 str_print("*****************************************************************") 48 str_print("error! NU1605 直接依赖版本版本低于间接依赖"+dependency_name) 49 str_print("直接版本:"+ installed_dep_version) 50 str_print("间接依赖范围:"+ dependency_version_range) 51 52 error_type_count_dict['NU1605'] = error_type_count_dict['NU1605'] + 1 53 # 添加到冲突队列 54 if installed_dep_direct_dep + "_" + dependency_version not in error_directly_dependency_list: 55 error_directly_dependency_list.append(installed_dep_direct_dep + "_" + dependency_version) 56 57 # 低版本为间接依赖 58 elif dependency_name + "@" + dependency_version == direct_dep: 59 # print("*****************************************************************") 60 # print("error! NU1608 直接依赖版本高于间接依赖,但无交集",dependency_name) 61 # print("直接版本:",dependency_version) 62 # print("间接依赖范围:", installed_dep_version_range) 63 64 warning_count = warning_count + 1 65 66 # # 添加到冲突队列 67 # if installed_dep_direct_dep not in error_directly_dependency_list: 68 # error_directly_dependency_list.append(installed_dep_direct_dep) 69 70 # 高低版本呢均为间接依赖 71 else: 72 str_print("*****************************************************************") 73 str_print("error! NU1107 间接依赖之间无交集"+ dependency_name) 74 str_print("已安装版本:"+installed_dep_version) 75 str_print("待检测依赖范围:"+ dependency_version_range) 76 str_print("冲突间接依赖范围:"+ installed_dep_version_range) 77 78 error_type_count_dict['NU1107'] = error_type_count_dict['NU1107'] + 1 79 # 添加到冲突队列 80 if installed_dep_direct_dep not in error_directly_dependency_list: 81 error_directly_dependency_list.append(installed_dep_direct_dep)