added new line checker for all push

This commit is contained in:
Mo Langning
2023-11-25 00:12:09 +08:00
parent 61b4435381
commit f794f2ff83
+8 -8
View File
@@ -3,16 +3,16 @@
# test string: ./.bin/new-line-checker.py "Fuzzing/file-extensions-all-cases.txt Fuzzing/file-extensions-lower-case.txt Fuzzing/file-extensions-upper-case.txt Fuzzing/file-extensions.txt" # test string: ./.bin/new-line-checker.py "Fuzzing/file-extensions-all-cases.txt Fuzzing/file-extensions-lower-case.txt Fuzzing/file-extensions-upper-case.txt Fuzzing/file-extensions.txt"
import os import os
import sys
print("[+] New line check") print("[+] New line check")
files = [] files=sys.argv[1].split(" ")
dirs = ['sources/','blacklists/','whitelists/']
for i in dirs: for i in files:
for root,_,file_list in os.walk(i): if not os.path.isfile(i):
for file in file_list: print("[!] %s does not exist!"%(i))
files.append(os.path.join(root,file)) exit(2)
for i in files: for i in files:
f=open(i,"r") f=open(i,"r")
@@ -24,7 +24,7 @@ for i in files:
if contents[-1] == '\n': if contents[-1] == '\n':
print("[!] %s ends with a new line"%(i)) print("[!] %s ends with a new line"%(i))
exit(2) exit(2)
# print("[+] %s passed new line check"%(i)) print("[+] %s passed new line check"%(i))
print("[+] All files passed checks") print("[+] All files passed checks")
exit(0) # exit(0)