Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix for README updater #942

Merged
merged 5 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions .bin/get-and-patch-readme-repository-details.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# If you change the commit message you need to change .github/workflows/readme-updater.yml

import requests,re
from decimal import Decimal

print("[+] Readme stats updater")

Expand All @@ -20,6 +21,10 @@
Cloning this repository should take %i-%i minutes at 5MB/s speeds.

%s"""
ERROR_STRING="::error file=%s,line=%s,col=%s,endColumn=%s::%s"

def print_err(file,msg,line=1,col=1,endcol=1):
print(ERROR_STRING%(file,line,col,endcol,msg))

size=requests.get(REPOSITORY_API%(REPOSITORY)).json()['size'] # Its in kb

Expand All @@ -33,16 +38,7 @@
final_size[0]=final_size[0][:-3]
final_size[2]=i

trailing_nums=list(final_size[1])

decimal_len=3-len(final_size[0])
if int(trailing_nums[decimal_len])>=5:
trailing_nums[decimal_len-1]=str(int(trailing_nums[decimal_len-1])+1)

trailing_nums=''.join(trailing_nums)
trailing_nums=trailing_nums[:decimal_len]

final_size=final_size[0]+'.'+trailing_nums+' '+final_size[2]
final_size="%s %s"%(str(round(Decimal('.'.join(final_size[:2])),1)),final_size[2])

eta_lower_bound=int(str(size/5000/60).split('.')[0]) # Get whole number after decimal point
eta_upper_bound=eta_lower_bound+1
Expand All @@ -51,11 +47,11 @@

readme_contents=open("README.md").read()

if re.match(DETAILS_ANCHOR_REGEX,readme_contents,flags=re.DOTALL):
print("[!] Error: No details anchor found!")
if not re.search(DETAILS_ANCHOR_REGEX,readme_contents,flags=re.DOTALL):
print_err("README.md", "[!] Error: No details anchor found!")
exit(2)

readme_contents=re.sub(DETAILS_ANCHOR_REGEX,DETAIL_USER_NOTICE_STRING,readme_contents,flags=re.DOTALL)
readme_contents=re.sub(DETAILS_ANCHOR_REGEX,DETAIL_USER_NOTICE_STRING,readme_contents,count=1,flags=re.DOTALL)
open("README.md","w").write(readme_contents)

print("[+] Wrote README.md!")
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This project is maintained by [Daniel Miessler](https://danielmiessler.com/), [J

### Repository details

Size of a complete clone of SecLists is currently at `969. MB`
Size of a complete clone of SecLists is currently at `969.8 MB`

Cloning this repository should take 3-4 minutes at 5MB/s speeds.

Expand Down