Reimport files

This commit is contained in:
Mo Langning
2024-02-17 03:04:59 +08:00
parent 28c116e49d
commit 5fbcb2fba3
8 changed files with 523 additions and 67 deletions
+45
View File
@@ -0,0 +1,45 @@
All the files here will be run by `validators.sh` as part of the check pipeline
## Specifications
Scripts will be passed a space separated list of files to check
e.g `./script.sh "Discovery/Web-Content/trickest-robots-disallowed-wordlists/top-100.txt"`
If you want your output to be parsed by the caller script, follow the below specs,else the output will be displayed raw in actions summaries
## Wrapped calls
### Wrapped calls checks
- - -
Scripts should check if its being run by the caller script. The environment variable `IS_RUNNING_UNDER_CALLER_SCRIPT` will be set to one
### Wrapped calls Specifications
- - -
Checker scripts will now have to print out the name of the check followed by a new line
Example `New line checker`
This value will be used as the checker title
After that, the descriptions will need to be printed out
Example `To fix the error, you have to remove the empty lines or new lines at the end of the file`
This is for contributors to understand why the checks failed
- - -
Outputs from now on will have to be in separate lines for each warnings or errors
This is the format for errors
Example `E,filename,line_number`
In the above example, `E` stands for errors. Accepted values are `E` and `W` for errors and warnings respectively
filename is the name of the file that the error comes from.
line_number is the line the script detected the error in.
+66
View File
@@ -0,0 +1,66 @@
#!/usr/bin/python3
import os,sys
if not sys.argv[1]:
exit(0)
IS_WRAPPED=False
if "IS_RUNNING_UNDER_CALLER_SCRIPT" in os.environ:
IS_WRAPPED=os.environ['IS_RUNNING_UNDER_CALLER_SCRIPT']=="1"
def print_normal(msg):
if IS_WRAPPED:
return
print(msg)
def print_err(file,line_number):
if IS_WRAPPED:
print("E,%s,%s"%(file,line_number))
def print_warn(file,line_number):
if IS_WRAPPED:
print("W,%s,%s"%(file,line_number))
print_normal("[+] Entries starting with slash checker")
if IS_WRAPPED:
print("Entries starting with slash check")
print("The warning are more for informative purposes and does not actually serve as a check. You can ignore this.")
files=sys.argv[1].split(" ")
for i in files:
if not os.path.isfile(i):
print_err(i,0)
print_normal("[!] %s does not exist!"%(i))
exit(2)
pass_status=True
for i in files:
contents=open(i,"rb").read()
counter=1
for line in contents.splitlines():
if line.startswith(b'/'):
print_normal("[!] Warning: %s starts with a slash on line %i!"%(i,counter))
print_warn(i,counter)
pass_status=False
counter+=1
print_normal("[+] %s passed no starting slash check!"%(i))
if pass_status:
print_normal("[+] All files passed checks")
exit(0)
print_normal("[!] Warning: One or more files failed to pass the checks")
if IS_WRAPPED:
exit(0)
else:
exit(2)
+88
View File
@@ -0,0 +1,88 @@
#!/usr/bin/env python3
import os,sys
if not sys.argv[1]:
exit(0)
IS_WRAPPED=False
if "IS_RUNNING_UNDER_CALLER_SCRIPT" in os.environ:
IS_WRAPPED=os.environ['IS_RUNNING_UNDER_CALLER_SCRIPT']=="1"
def print_normal(msg):
if IS_WRAPPED:
return
print(msg)
def print_err(file,line_number):
if IS_WRAPPED:
print("E,%s,%s"%(file,line_number))
def print_warn(file,line_number):
if IS_WRAPPED:
print("W,%s,%s"%(file,line_number))
print_normal("[+] New line and empty line check")
if IS_WRAPPED:
print("New line and empty line check")
print("To fix the error, you would have to remove the empty lines or new lines at the end of the file.")
files=sys.argv[1].split(" ")
for i in files:
if not os.path.isfile(i):
print_err(i,0)
print_normal("[!] %s does not exist!"%(i))
exit(2)
overall_pass_status=True
for i in files:
contents=open(i,"rb").read()
line_number=len(contents.split(b'\n'))+1
if contents[-1:] == b'\n':
print_normal("[!] Warning: %s ends with a new line!"%(i))
print_warn(i,line_number)
overall_pass_status=False
else:
print_normal("[+] %s passed new line check!"%(i))
counter=1
line_pass_status=True
for line in contents.splitlines():
if not line:
print_normal("[!] Warning: %s has an empty entry on line %i!"%(i,counter))
print_warn(i,counter)
pass_status=False
line_pass_status=False
continue
elif not line.strip():
print_normal("[!] Warning: %s has an whitespace only entry on line %i!"%(i,counter))
print_warn(i,counter)
pass_status=False
line_pass_status=False
continue
counter+=1
if line_pass_status:
print_normal("[+] %s passed empty line check!"%(i))
if overall_pass_status:
print_normal("[+] All files passed checks")
exit(0)
print_normal("[!] Warning: One or more files failed to pass the checks")
if IS_WRAPPED:
exit(0)
else:
exit(2)