From 358444d86ea7013979faf9fde1a3fcc85e501fd3 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 17 Dec 2025 23:18:23 -0500 Subject: [PATCH] Format code with Black --- .github/workflows/black.yml | 13 +++++++++++-- scripts/fetch_blacklists.py | 21 +++++++++++++++++---- scripts/update_readme.py | 4 +++- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 49de97e..f0b398d 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -6,7 +6,7 @@ on: paths: - '**/*.py' permissions: - contents: read + contents: write pull-requests: write checks: write jobs: @@ -18,6 +18,7 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 + persist-credentials: true - name: Set up Python uses: actions/setup-python@v4 with: @@ -28,4 +29,12 @@ jobs: run: black --check . - name: Show diff if formatting needed if: ${{ failure() }} - run: git --no-pager diff \ No newline at end of file + run: git --no-pager diff + - name: Run Black (autoformat) + if: ${{ failure() }} + run: | + pip install black + black . + git add -A + git commit -m "Autoformat: black" || echo "No changes" + git push origin HEAD:refs/heads/auto/format || echo "Push failed or blocked" \ No newline at end of file diff --git a/scripts/fetch_blacklists.py b/scripts/fetch_blacklists.py index 1a18026..76cd287 100644 --- a/scripts/fetch_blacklists.py +++ b/scripts/fetch_blacklists.py @@ -19,10 +19,19 @@ SOURCES = [ - ("stamparm_ipsum", "https://raw.githubusercontent.com/stamparm/ipsum/master/ipsum.txt"), + ( + "stamparm_ipsum", + "https://raw.githubusercontent.com/stamparm/ipsum/master/ipsum.txt", + ), ("spamhaus_drop", "https://www.spamhaus.org/drop/drop.txt"), - ("emerging_block_ips", "https://rules.emergingthreats.net/fwrules/emerging-Block-IPs.txt"), - ("ransomwaretracker_rw_ipbl", "https://ransomwaretracker.abuse.ch/downloads/RW_IPBL.txt"), + ( + "emerging_block_ips", + "https://rules.emergingthreats.net/fwrules/emerging-Block-IPs.txt", + ), + ( + "ransomwaretracker_rw_ipbl", + "https://ransomwaretracker.abuse.ch/downloads/RW_IPBL.txt", + ), ("zeus_abusech", "https://zeustracker.abuse.ch/blocklist.php?download=ipblocklist"), ] @@ -138,8 +147,12 @@ def main(): # The pipeline's `process_badips.py` will merge `data/new_ips.csv` and # other `data/*.csv` sources into `badip_list.csv` and update the DB. if new_ips: - print(f"Found {len(new_ips)} new IPs (not in badip_list.csv); leaving merge to process_badips.py") + print( + f"Found {len(new_ips)} new IPs (not in badip_list.csv); leaving merge to process_badips.py" + ) else: print("No new IPs detected; nothing to merge") + + if __name__ == "__main__": main() diff --git a/scripts/update_readme.py b/scripts/update_readme.py index fc39b00..ad245da 100644 --- a/scripts/update_readme.py +++ b/scripts/update_readme.py @@ -22,7 +22,9 @@ def format_time(iso_str): def build_block(stats): - update_time = format_time(stats.get("update_time") or stats.get("update_time_iso") or "") + update_time = format_time( + stats.get("update_time") or stats.get("update_time_iso") or "" + ) total = stats.get("total_ips", 0) countries = stats.get("countries_affected") or stats.get("countries") or 0 severity = stats.get("severity_avg") or stats.get("average_severity") or 0.0