From 11c316e65352ccfc07162670bcceaa6e2c98afdf Mon Sep 17 00:00:00 2001 From: Ian Littman Date: Wed, 18 Dec 2024 14:04:39 -0600 Subject: [PATCH] Pin Python version in GitHub Actions for osquery version updater, use Python HTTP client directly to avoid needing to figure out how to pin requests lib (#24861) For #24274. Skipping changes file since this is an internal tool. # Checklist for submitter - [x] Manual QA for all new/changed functionality --- .github/scripts/update_osquery_versions.py | 12 +++++++++--- .github/workflows/update-osquery-versions.yml | 4 +--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/scripts/update_osquery_versions.py b/.github/scripts/update_osquery_versions.py index e26d60fe33..c65deceb2e 100755 --- a/.github/scripts/update_osquery_versions.py +++ b/.github/scripts/update_osquery_versions.py @@ -1,6 +1,7 @@ import os -import requests import re +import json +import http.client # Use GITHUB_WORKSPACE to get the root of your repository repo_root = os.environ.get('GITHUB_WORKSPACE', '') @@ -8,8 +9,13 @@ FILE_PATH = os.path.join(repo_root, 'frontend', 'utilities', 'constants.tsx') def fetch_osquery_versions(): - response = requests.get('https://api.github.com/repos/osquery/osquery/releases') - releases = response.json() + conn = http.client.HTTPSConnection('api.github.com') + conn.request('GET', '/repos/osquery/osquery/releases', headers={"User-Agent": "Fleet/osquery-checker"}) + resp = conn.getresponse() + content = resp.read() + conn.close() + releases = json.loads(content.decode('utf-8')) + return [release['tag_name'] for release in releases if not release['prerelease']] def update_min_osquery_version_options(new_versions): diff --git a/.github/workflows/update-osquery-versions.yml b/.github/workflows/update-osquery-versions.yml index 2955e2d2c1..1f0b89c0c5 100644 --- a/.github/workflows/update-osquery-versions.yml +++ b/.github/workflows/update-osquery-versions.yml @@ -16,9 +16,7 @@ jobs: - name: Set up Python uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 with: - python-version: "3.x" - - name: Install dependencies - run: pip install requests + python-version: "3.13.1" - name: Update Osquery versions in UI run: python .github/scripts/update_osquery_versions.py - name: PR changes