Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/security/image_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
r"@sha256:(?P<digest>[0-9a-f]{64})(?P<stage> +AS +[A-Za-z0-9_.-]+)?$", re.M)
SHA256 = re.compile(r"[0-9a-f]{64}")
TIMEOUT = 60
RETRIES = 3

Api = Callable[..., Any]
Fetch = Callable[..., tuple[bytes, dict[str, str]]]
Expand Down Expand Up @@ -114,12 +115,14 @@ def gh_api(endpoint: str, method: str = "GET", payload: Any = None) -> Any:


def http_get(url: str, headers: dict[str, str], head: bool = False) -> tuple[bytes, dict[str, str]]:
"""GET (or HEAD) `url` with curl, HTTPS only; the body and the response headers."""
"""GET (or HEAD) `url` with curl, HTTPS only; the body and the response headers.
A transient failure, such as a 504 from the registry, is retried."""
args = ["curl", "--fail", "--silent", "--show-error", "--proto", "=https",
"--retry", str(RETRIES), "--retry-all-errors",
"--max-time", str(TIMEOUT), "--head" if head else "--dump-header", *([] if head else ["-"]), url]
for name, value in headers.items():
args[1:1] = ["--header", f"{name}: {value}"]
result = subprocess.run(args, capture_output=True, timeout=TIMEOUT + 10)
result = subprocess.run(args, capture_output=True, timeout=(TIMEOUT + 10) * (RETRIES + 1))
if result.returncode != 0:
raise ApiError(f"GET {url}: {result.stderr.decode('utf-8', 'replace').strip()}")
head_part, _, payload = result.stdout.partition(b"\r\n\r\n")
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/malware-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ jobs:
run: |
set -euo pipefail
pins=.github/security/yara.json
curl -fsSL -o yr.tar.gz "$(jq -r .yara_x.url "$pins")"
curl --retry 3 --retry-all-errors -fsSL -o yr.tar.gz "$(jq -r .yara_x.url "$pins")"
echo "$(jq -r .yara_x.sha256 "$pins") yr.tar.gz" | sha256sum --check
tar -xzf yr.tar.gz yr
curl -fsSL -o forge.zip "$(jq -r .yara_forge.url "$pins")"
curl --retry 3 --retry-all-errors -fsSL -o forge.zip "$(jq -r .yara_forge.url "$pins")"
echo "$(jq -r .yara_forge.sha256 "$pins") forge.zip" | sha256sum --check
unzip -q forge.zip -d forge
YARA_FORGE_RELEASE=$(jq -r .yara_forge.release "$pins")
Expand Down