@@ -126,7 +126,7 @@ def get_rating_from_sitespeed(url, local_translation, global_translation):
126
126
result = convert_item_to_domain_data (data )
127
127
128
128
texts = ''
129
- texts = sum_overall_software_used (local_translation , global_translation , result )
129
+ texts = sum_overall_software_used (local_translation , result )
130
130
131
131
rating += rate_software_security_result (local_translation , global_translation , result )
132
132
@@ -441,7 +441,7 @@ def rate_software_cve(issue_type, result, local_translation, global_translation)
441
441
rating += cve_ratings
442
442
return rating
443
443
444
- def sum_overall_software_used (local_translation , global_translation , result ):
444
+ def sum_overall_software_used (local_translation , result ):
445
445
texts = []
446
446
447
447
categories = ['cms' , 'webserver' , 'os' ,
@@ -574,10 +574,8 @@ def enrich_data(data, orginal_domain, result_folder_name, rules):
574
574
for item in data :
575
575
enrich_versions (softwares , item )
576
576
577
- enrich_data_from_javascript (tmp_list , item , rules )
578
- enrich_data_from_videos (tmp_list , item , result_folder_name )
577
+ enrich_data_from_javascript (item , rules )
579
578
enrich_data_from_images (tmp_list , item , result_folder_name )
580
- enrich_data_from_documents (tmp_list , item , result_folder_name )
581
579
582
580
if len (testing ) > 0 :
583
581
raw_data ['test' ][orginal_domain ] = {
@@ -663,36 +661,6 @@ def add_known_software_source(name, source_type, match, url):
663
661
with open (file_path , 'w' , encoding = 'utf-8' , newline = '' ) as file :
664
662
file .write (data )
665
663
666
- def add_wordpressplugin_software_source (name , version , url ):
667
- base_directory = Path (os .path .dirname (
668
- os .path .realpath (__file__ )) + os .path .sep ).parent
669
-
670
- file_path = (
671
- f'{ base_directory } { os .path .sep } data{ os .path .sep } '
672
- 'software-wordpressplugin-sources.json' )
673
- if not os .path .isfile (file_path ):
674
- file_path = f'{ base_directory } { os .path .sep } software-wordpressplugin-sources.json'
675
- if not os .path .isfile (file_path ):
676
- print ("Info: No software-wordpressplugin-sources.json file found!" )
677
-
678
- collection = {}
679
- try :
680
- with open (file_path , encoding = 'utf-8' ) as json_file :
681
- collection = json .load (json_file )
682
- except :
683
- print ('INFO: There was no ' , file_path , 'file.' )
684
-
685
- if 'softwares' not in collection :
686
- collection ['softwares' ] = {}
687
-
688
- if name not in collection ['softwares' ]:
689
- collection ['softwares' ][name ] = {}
690
-
691
- data = json .dumps (collection , indent = 4 )
692
- with open (file_path , 'w' , encoding = 'utf-8' , newline = '' ) as file :
693
- file .write (data )
694
-
695
-
696
664
def add_unknown_software_source (name , version , url ):
697
665
base_directory = Path (os .path .dirname (
698
666
os .path .realpath (__file__ )) + os .path .sep ).parent
@@ -715,7 +683,7 @@ def add_unknown_software_source(name, version, url):
715
683
'versions' : {},
716
684
}
717
685
718
- if version == None or version == '' :
686
+ if version in ( None , '' ) :
719
687
version = 'unknown'
720
688
721
689
if version not in collection [name ]['versions' ]:
@@ -789,13 +757,13 @@ def enrich_versions(collection, item):
789
757
current_year = datetime .now ().year
790
758
for year in range (10 , 2 , - 1 ):
791
759
if last_pushed_year < (current_year - year ):
792
- match ['issues' ].append ('UNMAINTAINED_SOURCE_{0 }_YEARS' . format ( year ) )
760
+ match ['issues' ].append (f 'UNMAINTAINED_SOURCE_{ year } _YEARS' )
793
761
break
794
762
795
763
if 'tech' in software_info :
796
764
match ['tech' ] = software_info ['tech' ]
797
765
798
- if match ['version' ] == None :
766
+ if match ['version' ] is None :
799
767
continue
800
768
801
769
version = None
@@ -827,7 +795,7 @@ def enrich_versions(collection, item):
827
795
if tmp_version == version :
828
796
match ['issues' ].extend (software_info ['versions' ][current_version ])
829
797
break
830
- elif tmp_version > version :
798
+ if tmp_version > version :
831
799
# NOTE: handle versions that doesn't match but we know is less or
832
800
# greater then versions we know.
833
801
# For example if: software_info['versions'] = [4.0, 3.0, 2.0, 1.0].
@@ -858,7 +826,7 @@ def enrich_versions(collection, item):
858
826
else :
859
827
match ['issues' ].append ('BEHIND001' )
860
828
861
- def enrich_data_from_javascript (tmp_list , item , rules ):
829
+ def enrich_data_from_javascript (item , rules ):
862
830
if USE_STEALTH :
863
831
return
864
832
for match in item ['matches' ]:
@@ -872,21 +840,7 @@ def enrich_data_from_javascript(tmp_list, item, rules):
872
840
if match ['version' ] is None :
873
841
return
874
842
875
- def enrich_data_from_videos (tmp_list , item , result_folder_name , nof_tries = 0 ):
876
- if USE_STEALTH :
877
- return
878
- for match in item ['matches' ]:
879
- if match ['category' ] != 'video' :
880
- return
881
-
882
- if match ['name' ] != 'mp4' :
883
- return
884
-
885
- def enrich_data_from_documents (tmp_list , item , result_folder_name , nof_tries = 0 ):
886
- if USE_STEALTH :
887
- return
888
-
889
- def enrich_data_from_images (tmp_list , item , result_folder_name , nof_tries = 0 ):
843
+ def enrich_data_from_images (tmp_list , item , result_folder_name ):
890
844
if USE_STEALTH :
891
845
return
892
846
for match in item ['matches' ]:
@@ -905,7 +859,7 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
905
859
906
860
tech_name = ''
907
861
tech_version = ''
908
- for matchNum , match in enumerate (matches , start = 1 ):
862
+ for _ , match in enumerate (matches , start = 1 ):
909
863
tech_name = match .group ('name' )
910
864
tech_version = match .group ('version' )
911
865
@@ -918,7 +872,7 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
918
872
'enrich' ,
919
873
match ['precision' ],
920
874
'security' ,
921
- ' whisper.{0}.app' . format ( match ['category' ]) , None ))
875
+ f" whisper.{ match ['category' ]} .app" , None ))
922
876
923
877
if tech_version is not None :
924
878
tech_version = tech_version .lower ()
@@ -929,10 +883,9 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
929
883
'enrich' ,
930
884
0.8 ,
931
885
'security' ,
932
- ' whisper.{0}.app' . format ( match ['category' ]) , None ))
886
+ f" whisper.{ match ['category' ]} .app" , None ))
933
887
else :
934
- cache_key = '{0}.cache.{1}' .format (
935
- hashlib .sha512 (item ['url' ].encode ()).hexdigest (), match ['name' ])
888
+ cache_key = f"{ hashlib .sha512 (item ['url' ].encode ()).hexdigest ()} .cache.{ match ['name' ]} "
936
889
cache_path = os .path .join (result_folder_name , cache_key )
937
890
938
891
image_data = None
@@ -961,8 +914,8 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
961
914
for tag_id in exifdata :
962
915
# get the tag name, instead of human unreadable tag id
963
916
tag = TAGS .get (tag_id , None )
964
- if tag == None :
965
- tag = 'unknown_{0}' . format ( tag_id )
917
+ if tag is None :
918
+ tag = f 'unknown_{ tag_id } '
966
919
967
920
tag_name = tag .lower ()
968
921
tag_data = exifdata .get (tag_id )
@@ -979,11 +932,11 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
979
932
r"(?P<version>[0-9.]+){0,1}[ (]{0,2}(?P<osname>[a-zA-Z]+){0,1})[)]{0,1}" )
980
933
matches = re .finditer (
981
934
regex , tag_data , re .MULTILINE )
982
- for matchNum , match in enumerate (matches , start = 1 ):
935
+ for _ , match in enumerate (matches , start = 1 ):
983
936
tech_name = match .group ('name' )
984
937
tech_version = match .group ('version' )
985
938
os_name = match .group ('osname' )
986
- if tech_name != None and tech_version == None :
939
+ if tech_name is not None and tech_version is None :
987
940
tech_name = tech_name .lower ().strip ().replace (' ' , '-' )
988
941
tmp_list .append (get_default_info (
989
942
item ['url' ], 'enrich' , 0.5 , 'img.software' , tech_name , None ))
@@ -992,9 +945,9 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
992
945
'enrich' ,
993
946
match ['precision' ],
994
947
'security' ,
995
- ' whisper.{0}.app' . format ( match ['category' ]) , None ))
948
+ f" whisper.{ match ['category' ]} .app" , None ))
996
949
997
- if tech_version != None :
950
+ if tech_version is not None :
998
951
tech_version = tech_version .lower ()
999
952
tmp_list .append (get_default_info (
1000
953
item ['url' ],
@@ -1008,7 +961,7 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
1008
961
'enrich' ,
1009
962
0.8 ,
1010
963
'security' ,
1011
- ' whisper.{0}.app' . format ( match ['category' ]) , None ))
964
+ f" whisper.{ match ['category' ]} .app" , None ))
1012
965
1013
966
if os_name is not None :
1014
967
os_name = os_name .lower ()
@@ -1019,14 +972,14 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
1019
972
'enrich' ,
1020
973
0.8 ,
1021
974
'security' ,
1022
- ' whisper.{0}.os' . format ( match ['category' ]) , None ))
975
+ f" whisper.{ match ['category' ]} .os" , None ))
1023
976
elif 'artist' == tag_name or 'xpauthor' == tag_name :
1024
977
tmp_list .append (get_default_info (
1025
978
item ['url' ],
1026
979
'enrich' ,
1027
980
0.8 ,
1028
981
'security' ,
1029
- ' info.{0}.person' . format ( match ['category' ]) , None ))
982
+ f" info.{ match ['category' ]} .person" , None ))
1030
983
elif 'make' == tag_name :
1031
984
device_name = tag_data .lower ().strip ()
1032
985
if 'nikon corporation' in device_name :
@@ -1038,31 +991,31 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
1038
991
r"(?P<version>[0-9.]+){0,1}[ (]{0,2}(?P<osname>[a-zA-Z]+){0,1})[)]{0,1}" )
1039
992
matches = re .finditer (
1040
993
regex , tag_data , re .MULTILINE )
1041
- for matchNum , match in enumerate (matches , start = 1 ):
994
+ for _ , match in enumerate (matches , start = 1 ):
1042
995
tech_name = match .group ('name' )
1043
996
tech_version = match .group ('version' )
1044
997
os_name = match .group ('osname' )
1045
- if tech_name != None and tech_version == None :
998
+ if tech_name is not None and tech_version is None :
1046
999
tech_name = tech_name .lower ().strip ().replace (' ' , '-' )
1047
1000
device_name = tech_name
1048
1001
tmp_list .append (get_default_info (
1049
1002
item ['url' ],
1050
1003
'enrich' ,
1051
1004
match ['precision' ],
1052
1005
'security' ,
1053
- ' whisper.{0}.device' . format ( match ['category' ]) , None ))
1006
+ f" whisper.{ match ['category' ]} .device" , None ))
1054
1007
1055
- if tech_version != None :
1008
+ if tech_version is not None :
1056
1009
tech_version = tech_version .lower ()
1057
1010
device_version = tech_version
1058
1011
tmp_list .append (get_default_info (
1059
1012
item ['url' ],
1060
1013
'enrich' ,
1061
1014
0.8 ,
1062
1015
'security' ,
1063
- ' whisper.{0}.device' . format ( match ['category' ]) , None ))
1016
+ f" whisper.{ match ['category' ]} .device" , None ))
1064
1017
1065
- if os_name != None :
1018
+ if os_name is not None :
1066
1019
os_name = os_name .lower ().strip ()
1067
1020
tmp_list .append (get_default_info (
1068
1021
item ['url' ], 'content' , 0.6 , 'img.os' , os_name , None ))
@@ -1071,22 +1024,22 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
1071
1024
'enrich' ,
1072
1025
0.8 ,
1073
1026
'security' ,
1074
- ' whisper.{0}.os' . format ( match ['category' ]) , None ))
1027
+ f" whisper.{ match ['category' ]} .os" , None ))
1075
1028
elif 'model' == tag_name :
1076
1029
tmp_list .append (get_default_info (
1077
1030
item ['url' ],
1078
1031
'enrich' ,
1079
1032
0.8 ,
1080
1033
'security' ,
1081
- ' info.{0}.model' . format ( match ['category' ]) , None ))
1034
+ f" info.{ match ['category' ]} .model" , None ))
1082
1035
device_version = tag_data .lower ().strip ()
1083
1036
elif 'gpsinfo' == tag_name :
1084
1037
tmp_list .append (get_default_info (
1085
1038
item ['url' ],
1086
1039
'enrich' ,
1087
1040
0.8 ,
1088
1041
'security' ,
1089
- ' info.{0}.location' . format ( match ['category' ]) , None ))
1042
+ f" info.{ match ['category' ]} .location" , None ))
1090
1043
1091
1044
if device_name is not None or device_version is not None :
1092
1045
if device_name is not None :
@@ -1099,7 +1052,7 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
1099
1052
'enrich' ,
1100
1053
match ['precision' ],
1101
1054
'security' ,
1102
- ' whisper.{0}.device' . format ( match ['category' ]) , None ))
1055
+ f" whisper.{ match ['category' ]} .device" , None ))
1103
1056
1104
1057
if device_name is not None and device_version is not None :
1105
1058
device_version = device_version .lower ()
@@ -1112,7 +1065,7 @@ def enrich_data_from_images(tmp_list, item, result_folder_name, nof_tries=0):
1112
1065
'enrich' ,
1113
1066
0.8 ,
1114
1067
'security' ,
1115
- ' whisper.{0}.device' . format ( match ['category' ]) , None ))
1068
+ f" whisper.{ match ['category' ]} .device" , None ))
1116
1069
1117
1070
1118
1071
def identify_software (filename , origin_domain , rules ):
@@ -1265,7 +1218,7 @@ def lookup_response_content(item, response_mimetype, response_content, rules):
1265
1218
1266
1219
regex = r"{0}" .format (rule ['match' ])
1267
1220
matches = re .finditer (regex , response_content , re .IGNORECASE )
1268
- for matchNum , match in enumerate (matches , start = 1 ):
1221
+ for _ , match in enumerate (matches , start = 1 ):
1269
1222
match_name = None
1270
1223
match_version = None
1271
1224
match_github_owner = None
@@ -1379,7 +1332,7 @@ def lookup_request_url(item, rules, origin_domain):
1379
1332
1380
1333
regex = r"{0}" .format (rule ['match' ])
1381
1334
matches = re .finditer (regex , req_url , re .MULTILINE )
1382
- for matchNum , match in enumerate (matches , start = 1 ):
1335
+ for _ , match in enumerate (matches , start = 1 ):
1383
1336
match_name = None
1384
1337
match_version = None
1385
1338
@@ -1466,7 +1419,7 @@ def lookup_cookie(item, cookie_name, cookie_value, rules, origin_domain):
1466
1419
1467
1420
regex = r"{0}" .format (rule ['match' ])
1468
1421
matches = re .finditer (regex , value , re .MULTILINE )
1469
- for matchNum , match in enumerate (matches , start = 1 ):
1422
+ for _ , match in enumerate (matches , start = 1 ):
1470
1423
match_name = None
1471
1424
match_version = None
1472
1425
@@ -1552,7 +1505,7 @@ def lookup_response_header(item, header_name, header_value, rules, origin_domain
1552
1505
1553
1506
regex = r"{0}" .format (rule ['match' ])
1554
1507
matches = re .finditer (regex , header_value , re .MULTILINE )
1555
- for matchNum , match in enumerate (matches , start = 1 ):
1508
+ for _ , match in enumerate (matches , start = 1 ):
1556
1509
match_name = None
1557
1510
match_version = None
1558
1511
0 commit comments