fixed the blacklisting of instances

This commit is contained in:
nihilist 2025-01-13 12:52:21 +01:00
parent f22515de6f
commit d662fb67d3
12 changed files with 35 additions and 61 deletions

View file

@ -612,12 +612,14 @@ Maintenance:
# if user wants to proceed, mark the "trusted" column as V
print("[+] Trusting webring participant", wdf.at[index,"URL"])
wdf.at[index,"Trusted"]='✔️'
wdf.to_csv(webringcsvfile, index=False)
else:
print("[-] not trusting webring participant, skipping.")
if choice == "2":
print("[+] UnTrusting webring participant", wdf.at[index,"URL"])
wdf.at[index,"Trusted"]=''
wdf.to_csv(webringcsvfile, index=False)
# untrust the webring participant
# if 2: mark the "trusted" column as empty
if choice == "3":
@ -678,11 +680,31 @@ Maintenance:
print(uvdf)
rows2delete= [] # it is an empty list at first
# TODO find all rows that match with the instance name in wdf aswell
wdf.drop(index, inplace= True)
wdf.to_csv(webringcsvfile, index=False)
print(wdf)
# TODO remove the entire directory in www/participants/INSTANCENAME
# find all rows that match with the instance name in wdf aswell to remove them
for i,j in wdf.iterrows():
row=wdf.loc[i,:].values.tolist()
for k,l in bldf.iterrows():
#print("[+] Blacklisted word=",k, bldf.at[k, 'blacklisted-words'])
blword=bldf.at[k, 'blacklisted-words']
if any(blword in str(x) for x in row) == True:
#print("found blacklisted word! marking row for deletion")
if i not in rows2delete:
print("Marking row", i,"for deletion, as it matches with a blacklisted word")
rows2delete.append(i) #mark the row for deletion if not already done
for i in rows2delete:
row=wdf.loc[i,:].values.tolist()
print('[+] REMOVING ROW :',i,row)
wdf.drop(i, inplace= True)
wdf.to_csv(webringcsvfile, index=False)
print(wdf)
rows2delete= [] # it is an empty list at first
# remove the entire directory in www/participants/INSTANCENAME aswell to get rid of it
instance2blacklistpath=rootpath+'www/participants/'+instance2blacklist
print("[+] removing the participant's directory at ",instance2blacklistpath)
shutil.rmtree(instance2blacklistpath)