Skip to content

Commit 88a8421

Browse files
reset org match order to match on email mapping before assigner domain match
1 parent 9c46855 commit 88a8421

File tree

1 file changed

+59
-46
lines changed

1 file changed

+59
-46
lines changed

schema/v5.0/support/CVE_4_to_5_converter/cve4to5up.py

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -389,53 +389,66 @@ def CVE_Convert(inputfile, outputpath):
389389
# get org info
390390
username = i_meta["ASSIGNER"]
391391
if i_meta["ASSIGNER"] not in all_users:
392-
#attempt to locate org from username domain extract
393-
orgShort = username
394-
if '@' in orgShort:
395-
orgShort = orgShort.split('@',1)[1]
396-
if '.' in orgShort:
397-
# strip last .xxxx
398-
orgShort = orgShort.rsplit('.', 1)[0]
399-
# print ("looking for org: "+orgShort)
400-
orgShort = orgShort.lower()
392+
401393
found = False
402-
for org in all_orgs:
403-
if all_orgs[org]["short_name"].casefold() == orgShort.casefold():
404-
o_meta["assignerOrgId"] = all_orgs[org]["UUID"]
405-
o_meta["assignerShortName"] = all_orgs[org]["short_name"]
406-
found = True
407-
break
394+
# check user mapping first for org name
395+
if username in requester_map:
396+
orgShort = requester_map[username][3]
397+
for org in all_orgs:
398+
if all_orgs[org]["short_name"].casefold() == orgShort.casefold():
399+
o_meta["assignerOrgId"] = all_orgs[org]["UUID"]
400+
o_meta["assignerShortName"] = all_orgs[org]["short_name"]
401+
found = True
402+
break
408403

409404
if not found:
410-
if username in requester_map:
411-
orgShort = requester_map[username][3]
412-
for org in all_orgs:
413-
if all_orgs[org]["short_name"].casefold() == orgShort.casefold():
414-
o_meta["assignerOrgId"] = all_orgs[org]["UUID"]
415-
o_meta["assignerShortName"] = all_orgs[org]["short_name"]
416-
found = True
417-
break
418-
else:
419-
# look for email half
420-
if '@' in username:
421-
userShort = username.split('@',1)[1]
422-
for user in requester_map:
423-
tuser = user
424-
if '@' in tuser:
425-
tuser = user.split('@',1)[1]
426-
if userShort.casefold() == tuser.casefold():
427-
orgShort = requester_map[user][3]
428-
for org in all_orgs:
429-
if all_orgs[org]["short_name"].casefold() == orgShort.casefold():
430-
o_meta["assignerOrgId"] = all_orgs[org]["UUID"]
431-
o_meta["assignerShortName"] = all_orgs[org]["short_name"]
432-
found = True
433-
break
434-
# end for org
435-
if found: break
436-
# end for user
405+
#attempt to locate org from username domain extract
406+
orgShort = username
407+
if '@' in orgShort:
408+
orgShort = orgShort.split('@',1)[1]
409+
if '.' in orgShort:
410+
# strip last .xxxx
411+
orgShort = orgShort.rsplit('.', 1)[0]
412+
# print ("looking for org: "+orgShort)
413+
orgShort = orgShort.lower()
414+
for org in all_orgs:
415+
if all_orgs[org]["short_name"].casefold() == orgShort.casefold():
416+
o_meta["assignerOrgId"] = all_orgs[org]["UUID"]
417+
o_meta["assignerShortName"] = all_orgs[org]["short_name"]
418+
found = True
419+
break
420+
421+
if not found:
422+
if username in requester_map:
423+
orgShort = requester_map[username][3]
424+
for org in all_orgs:
425+
if all_orgs[org]["short_name"].casefold() == orgShort.casefold():
426+
o_meta["assignerOrgId"] = all_orgs[org]["UUID"]
427+
o_meta["assignerShortName"] = all_orgs[org]["short_name"]
428+
found = True
429+
break
437430
else:
438-
print("found username that is not an email: "+ str(username) )
431+
# look for email half
432+
if '@' in username:
433+
userShort = username.split('@',1)[1]
434+
for user in requester_map:
435+
tuser = user
436+
if '@' in tuser:
437+
tuser = user.split('@',1)[1]
438+
if userShort.casefold() == tuser.casefold():
439+
orgShort = requester_map[user][3]
440+
for org in all_orgs:
441+
if all_orgs[org]["short_name"].casefold() == orgShort.casefold():
442+
o_meta["assignerOrgId"] = all_orgs[org]["UUID"]
443+
o_meta["assignerShortName"] = all_orgs[org]["short_name"]
444+
found = True
445+
break
446+
# end for org
447+
if found: break
448+
# end for user
449+
else:
450+
print("found username that is not an email: "+ str(username) )
451+
# end if - user_map else parsed email magic
439452

440453
if not found:
441454
# default to MITRE and CNAofLR
@@ -446,8 +459,8 @@ def CVE_Convert(inputfile, outputpath):
446459
o_meta["assignerOrgId"] = all_users[username]["org_UUID"]
447460
o_meta["assignerShortName"] = all_users[username]["org_short_name"]
448461
else:
449-
o_meta["assignerOrgId"] = all_users[username]["org_UUID"]
450-
o_meta["assignerShortName"] = all_users[username]["org_short_name"]
462+
o_meta["assignerOrgId"] = all_users[username]["org_UUID"]
463+
o_meta["assignerShortName"] = all_users[username]["org_short_name"]
451464

452465
# print("in = " + i_meta["ASSIGNER"] + " out = " +o_meta["assignerShortName"])
453466

@@ -755,7 +768,7 @@ def CVE_Convert(inputfile, outputpath):
755768

756769
if len(o["product"]) > maxV5ProductLength:
757770
o["product"] = (o["product"][:(maxV5ProductLength-16)] + " ...[truncated*]")
758-
converter_errors["product_name"] = {"error": "product_name too long. Use array of products to record more than one product.", "message": "Truncated!"}
771+
converter_errors["product_name"] = {"error": "product_name too long. Use array of products to recond more than one product.", "message": "Truncated!"}
759772

760773
o_cna["affected"] = o_affected
761774
# done with affected up convert

0 commit comments

Comments
 (0)