2023-11-25 00:06:46 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
# 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
|
2023-11-25 00:12:09 +08:00
|
|
|
import sys
|
2023-11-25 00:06:46 +08:00
|
|
|
|
|
|
|
print("[+] New line check")
|
|
|
|
|
2023-11-25 00:32:04 +08:00
|
|
|
if not sys.argv[1]:
|
|
|
|
exit(0)
|
|
|
|
|
2023-11-25 00:12:09 +08:00
|
|
|
files=sys.argv[1].split(" ")
|
2023-11-25 00:06:46 +08:00
|
|
|
|
2023-11-25 00:12:09 +08:00
|
|
|
for i in files:
|
|
|
|
if not os.path.isfile(i):
|
|
|
|
print("[!] %s does not exist!"%(i))
|
|
|
|
exit(2)
|
2023-11-25 00:06:46 +08:00
|
|
|
|
|
|
|
for i in files:
|
|
|
|
f=open(i,"r")
|
|
|
|
contents=f.read()
|
|
|
|
|
|
|
|
if contents[-1] == '\n':
|
2023-11-25 00:25:59 +08:00
|
|
|
print("[!] %s ends with a new line!"%(i))
|
2023-11-25 00:06:46 +08:00
|
|
|
exit(2)
|
2023-11-25 00:25:59 +08:00
|
|
|
print("[+] %s passed new line check!"%(i))
|
|
|
|
|
2023-11-25 01:34:28 +08:00
|
|
|
counter=1
|
|
|
|
|
2023-11-25 00:41:40 +08:00
|
|
|
for line in contents.split('\n'):
|
|
|
|
if len(line)==0:
|
2023-11-25 01:34:28 +08:00
|
|
|
print("[!] %s has an empty entry at line %i!"%(i,counter))
|
2023-11-25 00:25:59 +08:00
|
|
|
exit(2)
|
2023-11-25 01:34:28 +08:00
|
|
|
counter+=1
|
2023-11-25 00:25:59 +08:00
|
|
|
print("[+] %s passed empty line check!"%(i))
|
2023-11-25 00:06:46 +08:00
|
|
|
|
|
|
|
print("[+] All files passed checks")
|
2023-11-25 00:41:40 +08:00
|
|
|
# exit(0)
|