diff mbox series

[yocto-autobuilder-helper] Fix requests to git.yoctoproject.org triggering Anubis

Message ID 20251123171508.124628-1-richard.purdie@linuxfoundation.org
State New
Headers show
Series [yocto-autobuilder-helper] Fix requests to git.yoctoproject.org triggering Anubis | expand

Commit Message

Richard Purdie Nov. 23, 2025, 5:15 p.m. UTC
From: Konstantin Ryabitsev <konstantin@linuxfoundation.org>

Bot requests to git.yoctoproject.org are triggering the newest version
of Anubis. Work around it by sending a proper user-agent and setting
the Accept header.

Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 scripts/yocto-supported-distros | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/scripts/yocto-supported-distros b/scripts/yocto-supported-distros
index e70943d..11b05b7 100755
--- a/scripts/yocto-supported-distros
+++ b/scripts/yocto-supported-distros
@@ -42,19 +42,23 @@  import argparse
 import json
 import os
 import re
-import urllib.request
 import sys
 import subprocess
 import tempfile
 
 from pathlib import Path
 from typing import List, Dict, Set
-from urllib.error import HTTPError
 
+from urllib.error import HTTPError
+from urllib.request import Request, urlopen
 
 CONFIG_REMOTE_URL = "https://git.yoctoproject.org/yocto-autobuilder2/plain/config.py"
 AUTOBUILDER_WORKERS_ENDPOINT = "https://autobuilder.yoctoproject.org/valkyrie/api/v2/workers"
 
+REQ_HEADERS = {
+    "User-Agent": "yocto-autobuilder-helper (git://git.yoctoproject.org/yocto-autobuilder-helper)",
+    "Accept": "*/*",
+}
 
 INPUT_REGEXES = {
     "alma": {
@@ -321,8 +325,10 @@  def _filter_inactive_workers(possible_workers: List[str]) -> List[str]:
     _possible_workers = []
     workers_ab = []
 
+    req = Request(AUTOBUILDER_WORKERS_ENDPOINT, headers=REQ_HEADERS)
+
     try:
-        with urllib.request.urlopen(AUTOBUILDER_WORKERS_ENDPOINT) as r:
+        with urlopen(req) as r:
             workers_ab = json.load(r).get("workers")
     except (HTTPError, AttributeError) as e:
         print(f"WARNING: Error when trying to fetch the worker statuses from {AUTOBUILDER_WORKERS_ENDPOINT}:")
@@ -354,8 +360,9 @@  def main():
         exit(1)
 
     if args.config_from_web:
+        req = Request(CONFIG_REMOTE_URL, headers=REQ_HEADERS)
         try:
-            with urllib.request.urlopen(CONFIG_REMOTE_URL) as r:
+            with urlopen(req) as r:
                 with tempfile.TemporaryDirectory() as tempdir:
                     with open(Path(tempdir) / "config.py", "wb") as conf:
                         conf.write(r.read())