From 597f5758a128dbd72bd5cc7f9f7a228a11fc2729 Mon Sep 17 00:00:00 2001 From: Mo Langning <133737702+molangning@users.noreply.github.com> Date: Thu, 30 Nov 2023 00:03:49 +0800 Subject: [PATCH 1/5] patched away faulty checks and replacements --- .bin/get-and-patch-readme-repository-details.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.bin/get-and-patch-readme-repository-details.py b/.bin/get-and-patch-readme-repository-details.py index cadab904fdc..518764910c9 100755 --- a/.bin/get-and-patch-readme-repository-details.py +++ b/.bin/get-and-patch-readme-repository-details.py @@ -51,11 +51,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!") From 2143fe4b59b6fa6c834602bf52339d9ad5aa100f Mon Sep 17 00:00:00 2001 From: Mo Langning <133737702+molangning@users.noreply.github.com> Date: Thu, 30 Nov 2023 00:15:30 +0800 Subject: [PATCH 2/5] improved logging --- .bin/get-and-patch-readme-repository-details.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.bin/get-and-patch-readme-repository-details.py b/.bin/get-and-patch-readme-repository-details.py index 518764910c9..f5d525e62a8 100755 --- a/.bin/get-and-patch-readme-repository-details.py +++ b/.bin/get-and-patch-readme-repository-details.py @@ -20,6 +20,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 From bae9fec8f5f874f20bf03f6b933a6ff64e7da0df Mon Sep 17 00:00:00 2001 From: Mo Langning <133737702+molangning@users.noreply.github.com> Date: Thu, 30 Nov 2023 00:16:19 +0800 Subject: [PATCH 3/5] fix weird edge case where size returns something like 969. MB --- .bin/get-and-patch-readme-repository-details.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.bin/get-and-patch-readme-repository-details.py b/.bin/get-and-patch-readme-repository-details.py index f5d525e62a8..7e89bf9fbdc 100755 --- a/.bin/get-and-patch-readme-repository-details.py +++ b/.bin/get-and-patch-readme-repository-details.py @@ -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") @@ -37,16 +38,7 @@ def print_err(file,msg,line=1,col=1,endcol=1): 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=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 From f5814f0c5e2e7e3e3858724cfbc6e8a4eeaf16bc Mon Sep 17 00:00:00 2001 From: Mo Langning <133737702+molangning@users.noreply.github.com> Date: Thu, 30 Nov 2023 00:18:50 +0800 Subject: [PATCH 4/5] used formatting strings instead --- .bin/get-and-patch-readme-repository-details.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bin/get-and-patch-readme-repository-details.py b/.bin/get-and-patch-readme-repository-details.py index 7e89bf9fbdc..cd5f6b8a663 100755 --- a/.bin/get-and-patch-readme-repository-details.py +++ b/.bin/get-and-patch-readme-repository-details.py @@ -38,7 +38,7 @@ def print_err(file,msg,line=1,col=1,endcol=1): final_size[0]=final_size[0][:-3] final_size[2]=i -final_size=str(round(Decimal('.'.join(final_size[:2])),1))+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 From aa7e29b84cb2f7b47d83f67ce58d3bc6765b7e34 Mon Sep 17 00:00:00 2001 From: Mo Langning <133737702+molangning@users.noreply.github.com> Date: Thu, 30 Nov 2023 00:19:03 +0800 Subject: [PATCH 5/5] Updated README.md with correct values --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09419e163f5..917cc5bf2b6 100644 --- a/README.md +++ b/README.md @@ -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.