microsoft/hve-core

Public

mirrored fromhttps://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ci/884-codeql-python-analysis

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.devcontainer/scripts/on-create.sh

100lines · modecode

1#!/usr/bin/env bash
2# Copyright (c) Microsoft Corporation.
3# SPDX-License-Identifier: MIT
4#
5# on-create.sh
6# Install system dependencies for HVE Core development container
7
8set -euo pipefail
9
10main() {
11 echo "Installing system dependencies..."
12
13 sudo apt update
14 sudo apt install -y shellcheck
15
16 # Dependencies are pinned for stability. Dependabot and security workflows manage updates.
17 echo "Installing actionlint..."
18 ACTIONLINT_VERSION="1.7.10"
19 ARCH=$(uname -m)
20 if [[ "${ARCH}" == "x86_64" ]]; then
21 ACTIONLINT_ARCH="amd64"
22 ACTIONLINT_SHA256="f4c76b71db5755a713e6055cbb0857ed07e103e028bda117817660ebadb4386f"
23 elif [[ "${ARCH}" == "aarch64" ]]; then
24 ACTIONLINT_ARCH="arm64"
25 ACTIONLINT_SHA256="cd3dfe5f66887ec6b987752d8d9614e59fd22f39415c5ad9f28374623f41773a"
26 else
27 echo "ERROR: Unsupported architecture: ${ARCH}" >&2
28 exit 1
29 fi
30 curl -sSfL "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_${ACTIONLINT_ARCH}.tar.gz" -o /tmp/actionlint.tar.gz
31
32 echo "Checking actionlint tarball integrity..."
33 if ! echo "${ACTIONLINT_SHA256} /tmp/actionlint.tar.gz" | sha256sum -c --quiet -; then
34 echo "ERROR: SHA256 checksum verification failed for actionlint tarball" >&2
35 rm /tmp/actionlint.tar.gz
36 exit 1
37 fi
38 sudo tar -xzf /tmp/actionlint.tar.gz -C /usr/local/bin actionlint
39 rm /tmp/actionlint.tar.gz
40
41 echo "Installing PowerShell modules..."
42 pwsh -NoProfile -Command "Install-Module -Name PowerShell-Yaml -Force -Scope CurrentUser -Repository PSGallery"
43 pwsh -NoProfile -Command "Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser -Repository PSGallery"
44 pwsh -NoProfile -Command "Install-Module -Name Pester -RequiredVersion 5.7.1 -Force -Scope CurrentUser -Repository PSGallery"
45
46 echo "Installing gitleaks..."
47 # Download gitleaks tarball and verify checksum before extracting
48 GITLEAKS_VERSION="8.18.2"
49 if [[ "${ARCH}" == "x86_64" ]]; then
50 GITLEAKS_ARCH="x64"
51 GITLEAKS_SHA256="6298c9235dfc9278c14b28afd9b7fa4e6f4a289cb1974bd27949fc1e9122bdee"
52 elif [[ "${ARCH}" == "aarch64" ]]; then
53 GITLEAKS_ARCH="arm64"
54 GITLEAKS_SHA256="4df25683f95b9e1dbb8cc71dac74d10067b8aba221e7f991e01cafa05bcbd030"
55 else
56 echo "ERROR: Unsupported architecture for gitleaks: ${ARCH}" >&2
57 exit 1
58 fi
59 curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_${GITLEAKS_ARCH}.tar.gz" -o /tmp/gitleaks.tar.gz
60
61 echo "Checking gitleaks tarball integrity..."
62 if ! echo "${GITLEAKS_SHA256} /tmp/gitleaks.tar.gz" | sha256sum -c --quiet -; then
63 echo "ERROR: SHA256 checksum verification failed for gitleaks tarball" >&2
64 rm /tmp/gitleaks.tar.gz
65 exit 1
66 fi
67 sudo tar -xzf /tmp/gitleaks.tar.gz -C /usr/local/bin gitleaks
68 rm /tmp/gitleaks.tar.gz
69
70 echo "Installing uv package manager..."
71 # Dependencies are pinned for stability. Dependabot and security workflows manage updates.
72 UV_VERSION="0.10.8"
73 if [[ "${ARCH}" == "x86_64" ]]; then
74 UV_ARCH="x86_64-unknown-linux-gnu"
75 UV_SHA256="f0c566b55683395a62fefb9261a060fa09824914b5682c3b9629fa154762ae2f"
76 elif [[ "${ARCH}" == "aarch64" ]]; then
77 UV_ARCH="aarch64-unknown-linux-gnu"
78 UV_SHA256="661860e954f87dcd823251191866af3486484d1a9df60eed56f4586ed7559e3d"
79 else
80 echo "ERROR: Unsupported architecture for uv: ${ARCH}" >&2
81 exit 1
82 fi
83 curl -sSfL "https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-${UV_ARCH}.tar.gz" -o /tmp/uv.tar.gz
84
85 echo "Checking uv tarball integrity..."
86 if ! echo "${UV_SHA256} /tmp/uv.tar.gz" | sha256sum -c --quiet -; then
87 echo "ERROR: SHA256 checksum verification failed for uv tarball" >&2
88 rm -f /tmp/uv.tar.gz
89 exit 1
90 fi
91 sudo tar -xzf /tmp/uv.tar.gz -C /usr/local/bin --strip-components=1 "uv-${UV_ARCH}/uv" "uv-${UV_ARCH}/uvx"
92 rm /tmp/uv.tar.gz
93
94 echo "Syncing Python environments for skills..."
95 find .github/skills -name pyproject.toml -type f -execdir uv sync \;
96
97 echo "System dependencies installed successfully"
98}
99
100main "$@"
101