mirror of
https://github.com/danielmiessler/SecLists
synced 2026-01-05 23:57:21 +01:00
commit
a1a7700a31
3 changed files with 109 additions and 0 deletions
61
.bin/get-and-patch-readme-repository-details.py
Executable file
61
.bin/get-and-patch-readme-repository-details.py
Executable file
|
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
# If you change the commit message you need to change .github/workflows/readme-updater.yml
|
||||
|
||||
import requests,re
|
||||
|
||||
print("[+] Readme stats updater")
|
||||
|
||||
REPOSITORY_API="https://api.github.com/repos/%s"
|
||||
REPOSITORY="danielmiessler/SecLists"
|
||||
DETAILS_ANCHOR="<!--- details anchor -->"
|
||||
DETAILS_ANCHOR_REGEX=r"%s.*?%s"%(DETAILS_ANCHOR,DETAILS_ANCHOR)
|
||||
COMMIT_MESSAGE="[Github Action] Automated readme update."
|
||||
DETAIL_USER_NOTICE_STRING="""%s
|
||||
|
||||
### Repository details
|
||||
|
||||
Size of a complete clone of SecLists is currently at `%s`
|
||||
|
||||
Cloning this repository should take %i-%i minutes at 5MB/s speeds.
|
||||
|
||||
%s"""
|
||||
|
||||
size=requests.get(REPOSITORY_API%(REPOSITORY)).json()['size'] # Its in kb
|
||||
|
||||
suffixes=['MB','GB','TB']
|
||||
final_size=[str(size),"","KB"]
|
||||
|
||||
for i in suffixes:
|
||||
if len(final_size[0])>3:
|
||||
|
||||
final_size[1]=final_size[0][-3:]+final_size[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]
|
||||
|
||||
eta_lower_bound=int(str(size/5000/60).split('.')[0]) # Get whole number after decimal point
|
||||
eta_upper_bound=eta_lower_bound+1
|
||||
|
||||
DETAIL_USER_NOTICE_STRING=DETAIL_USER_NOTICE_STRING%(DETAILS_ANCHOR,final_size,eta_lower_bound,eta_upper_bound,DETAILS_ANCHOR)
|
||||
|
||||
readme_contents=open("README.md").read()
|
||||
|
||||
if re.match(DETAILS_ANCHOR_REGEX,readme_contents,flags=re.DOTALL):
|
||||
print("[!] Error: No details anchor found!")
|
||||
exit(2)
|
||||
|
||||
readme_contents=re.sub(DETAILS_ANCHOR_REGEX,DETAIL_USER_NOTICE_STRING,readme_contents,flags=re.DOTALL)
|
||||
open("README.md","w").write(readme_contents)
|
||||
|
||||
print("[+] Wrote README.md!")
|
||||
36
.github/workflows/readme-updater.yml
vendored
Normal file
36
.github/workflows/readme-updater.yml
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# If you change the commit message you need to change .bin/get-and-patch-readme-repository-details.py
|
||||
|
||||
name: Readme updater - Updates readme with latest stats
|
||||
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
update-readme:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Update readme
|
||||
run: .bin/get-and-patch-readme-repository-details.py
|
||||
|
||||
- name: Commit files if changed
|
||||
run: |
|
||||
git add -N .
|
||||
|
||||
if [ -z "$(git ls-files --modified)" ]; then
|
||||
echo "[+] No files were changed"
|
||||
else
|
||||
echo "[+] Files were changed! Pushing changed..."
|
||||
git add -A
|
||||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
|
||||
git config --local user.email "example@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git commit -m "[Github Action] Automated readme update."
|
||||
git push
|
||||
fi
|
||||
|
||||
12
README.md
12
README.md
|
|
@ -8,6 +8,18 @@ This project is maintained by [Daniel Miessler](https://danielmiessler.com/), [J
|
|||
|
||||
- - -
|
||||
|
||||
<!--- details anchor -->
|
||||
|
||||
### Repository details
|
||||
|
||||
Size of a complete clone of SecLists is currently at `1.05 GB`
|
||||
|
||||
Cloning this repository should take 3-4 minutes at 5MB/s speeds.
|
||||
|
||||
<!--- details anchor -->
|
||||
|
||||
- - -
|
||||
|
||||
### Install
|
||||
|
||||
**Zip**
|
||||
|
|
|
|||
Loading…
Reference in a new issue