Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
51 changes: 51 additions & 0 deletions images/ubuntu/scripts/build/install-awf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash -e
################################################################################
## File: install-awf.sh
## Desc: Install Agent Workflow Firewall JS bundle (most recent 3 versions)
## Supply chain security: AWF - checksum validation
################################################################################

# Source the helpers for use with the script
source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/os.sh

# Following the pattern in install-docker.sh where the core AW container images are only installed on ubuntu-latest
if is_ubuntu22; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this code do you need updating ubuntu-22 Packer template?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Updated

exit 0
fi

# Number of versions to install (current + 2 previous)
NUM_VERSIONS=3

# Get the most recent stable releases (exclude pre-releases, beta and release without assets)
releases=$(curl -fsSL "https://api.github.com/repos/github/gh-aw-firewall/releases?per_page=10")
versions=$(echo "$releases" | jq -r '[.[] | select(.assets | length > 0) | select(.prerelease == false) | select(.tag_name | test(".*-[a-z]|beta") | not)] | .[:'"$NUM_VERSIONS"'] | .[].tag_name')

Comment on lines +14 to +17
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GitHub release query uses per_page=10 and only checks that a release has some assets, not that it includes awf-bundle.js/checksums.txt. This can lead to caching fewer than NUM_VERSIONS versions or failing downloads if a release is missing the expected files. Prefer using helpers/install.sh (get_github_releases_by_version + resolve_github_release_asset_url) or filter releases by the required asset name and increase the page size so you can reliably install 3 stable versions.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

já verifiquei as mudanças a serem feitas.

if [[ -z "$versions" ]]; then
echo "Error: Unable to find AWF releases."
exit 1
fi

for tag in $versions; do
version="${tag#v}"
echo "Installing AWF JS bundle version $version to toolcache..."

# Download the JS bundle
bundle_url="https://github.com/github/gh-aw-firewall/releases/download/${tag}/awf-bundle.js"
bundle_path=$(download_with_retry "$bundle_url")

# Supply chain security - AWF
checksums_url="https://github.com/github/gh-aw-firewall/releases/download/${tag}/checksums.txt"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, how do we enforce the security here? If someone was able to update release artifacts then they could equally update the checksum file too.

Copy link
Copy Markdown
Author

@aiqiaoy aiqiaoy Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point. I think we need to verify signature to be fully protected, although this check sum validation is an existing pattern in our install scripts

external_hash=$(get_checksum_from_url "$checksums_url" "awf-bundle.js" "SHA256")
use_checksum_comparison "$bundle_path" "$external_hash"

# Install to toolcache
awf_toolcache_path="$AGENT_TOOLSDIRECTORY/agentic-workflow-firewall-js/$version/x64"
mkdir -p "$awf_toolcache_path"
cp "$bundle_path" "$awf_toolcache_path/awf-bundle.js"

# Mark installation complete
touch "$AGENT_TOOLSDIRECTORY/agentic-workflow-firewall-js/$version/x64.complete"
done

invoke_tests "Tools" "AWF"
56 changes: 56 additions & 0 deletions images/ubuntu/scripts/build/install-copilot-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash -e
################################################################################
## File: install-copilot-cli.sh
## Desc: Install Copilot CLI (most recent 3 versions)
## Supply chain security: Copilot CLI - checksum validation
################################################################################

# Source the helpers for use with the script
source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/os.sh

# Following the pattern in install-docker.sh where the core AW container images are only installed on ubuntu-latest
if is_ubuntu22; then
exit 0
fi

# Number of versions to cache (current + 2 previous)
NUM_VERSIONS=3

# Get the most recent stable releases (exclude pre-releases, rc, and beta)
releases=$(curl -fsSL "https://api.github.com/repos/github/copilot-cli/releases?per_page=10")
versions=$(echo "$releases" | jq -r '[.[] | select(.assets | length > 0) | select(.prerelease == false) | select(.tag_name | test(".*-[a-z]|beta") | not)] | .[:'"$NUM_VERSIONS"'] | .[].tag_name')

Comment thread
aiqiaoy marked this conversation as resolved.
Outdated
if [[ -z "$versions" ]]; then
echo "Error: Unable to find Copilot CLI releases."
exit 1
fi

for tag in $versions; do
version="${tag#v}"
echo "Installing Copilot CLI version $version to toolcache..."

# Download Copilot CLI
archive_url="https://github.com/github/copilot-cli/releases/download/${tag}/copilot-linux-x64.tar.gz"
copilot_cli_archive=$(download_with_retry "$archive_url")

# Supply chain security - Copilot CLI
checksums_url="https://github.com/github/copilot-cli/releases/download/${tag}/SHA256SUMS.txt"
external_hash=$(get_checksum_from_url "$checksums_url" "copilot-linux-x64.tar.gz" "SHA256")
use_checksum_comparison "$copilot_cli_archive" "$external_hash"

# Install to toolcache
copilot_cli_toolcache_path="$AGENT_TOOLSDIRECTORY/copilot-cli/$version/x64"
mkdir -p "$copilot_cli_toolcache_path"
tar -xzf "$copilot_cli_archive" -C "$copilot_cli_toolcache_path"

# Mark installation complete
touch "$AGENT_TOOLSDIRECTORY/copilot-cli/$version/x64.complete"
done

# Symlink the latest version to /usr/local/bin
latest_version=$(echo "$versions" | head -n 1)
latest_version="${latest_version#v}"
ln -sf "$AGENT_TOOLSDIRECTORY/copilot-cli/$latest_version/x64/copilot" /usr/local/bin/copilot

invoke_tests "CLI.Tools" "Copilot CLI"
16 changes: 16 additions & 0 deletions images/ubuntu/scripts/tests/CLI.Tools.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,19 @@ Describe "Oras CLI" -Skip:((-not (Test-IsUbuntu22))) {
"oras version" | Should -ReturnZeroExitCode
}
}

Describe "Copilot CLI" -Skip:(Test-IsUbuntu22) {
It "Copilot CLI toolcache directory exists" {
$copilotCliPath = Join-Path $env:AGENT_TOOLSDIRECTORY "copilot-cli"
$copilotCliPath | Should -Exist
}

It "At least 2 versions are installed" {
$copilotCliPath = Join-Path $env:AGENT_TOOLSDIRECTORY "copilot-cli"
(Get-ChildItem -Path $copilotCliPath -Directory).Count | Should -BeGreaterOrEqual 2
Comment thread
aiqiaoy marked this conversation as resolved.
Outdated
}

It "Copilot CLI version" {
"copilot --version" | Should -ReturnZeroExitCode
}
}
19 changes: 19 additions & 0 deletions images/ubuntu/scripts/tests/Tools.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,22 @@ project(NinjaTest NONE)
Remove-Item -Path "/tmp/ninjaproject" -Recurse -Force
}
}

Describe "AWF" -Skip:(Test-IsUbuntu22) {
It "AWF toolcache directory exists" {
$awfPath = Join-Path $env:AGENT_TOOLSDIRECTORY "agentic-workflow-firewall-js"
$awfPath | Should -Exist
}

It "At least 3 versions are installed" {
$awfPath = Join-Path $env:AGENT_TOOLSDIRECTORY "agentic-workflow-firewall-js"
(Get-ChildItem -Path $awfPath -Directory).Count | Should -BeGreaterOrEqual 3
}

It "AWF JS bundle exists" {
$awfPath = Join-Path $env:AGENT_TOOLSDIRECTORY "agentic-workflow-firewall-js"
$latestVersion = Get-ChildItem -Path $awfPath -Directory | Sort-Object -Property { [version]$_.Name } -Descending | Select-Object -First 1
$bundlePath = Join-Path $latestVersion.FullName "x64" "awf-bundle.js"
$bundlePath | Should -Exist
}
}
2 changes: 2 additions & 0 deletions images/ubuntu/templates/build.ubuntu-22_04.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ build {
"${path.root}/../scripts/build/install-swift.sh",
"${path.root}/../scripts/build/install-cmake.sh",
"${path.root}/../scripts/build/install-codeql-bundle.sh",
"${path.root}/../scripts/build/install-copilot-cli.sh",
"${path.root}/../scripts/build/install-awf.sh",
"${path.root}/../scripts/build/install-container-tools.sh",
"${path.root}/../scripts/build/install-dotnetcore-sdk.sh",
"${path.root}/../scripts/build/install-firefox.sh",
Expand Down
2 changes: 2 additions & 0 deletions images/ubuntu/templates/build.ubuntu-24_04.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ provisioner "shell" {
"${path.root}/../scripts/build/install-swift.sh",
"${path.root}/../scripts/build/install-cmake.sh",
"${path.root}/../scripts/build/install-codeql-bundle.sh",
"${path.root}/../scripts/build/install-copilot-cli.sh",
"${path.root}/../scripts/build/install-awf.sh",
"${path.root}/../scripts/build/install-container-tools.sh",
"${path.root}/../scripts/build/install-dotnetcore-sdk.sh",
"${path.root}/../scripts/build/install-microsoft-edge.sh",
Expand Down
Loading