mirror of
https://github.com/trailofbits/algo.git
synced 2026-09-08 02:37:48 +02:00
* chore: Conservative dependency updates for security - Update Ansible from 9.1.0 to 9.2.0 (one minor version bump only) - Update Jinja2 to ~3.1.6 to fix CVE-2025-27516 (critical security fix) - Pin netaddr to 1.3.0 (current stable version) This is a minimal, conservative update focused on: 1. Critical security fix for Jinja2 2. Minor ansible update for bug fixes 3. Pinning netaddr to prevent surprises No changes to Ansible collections - keeping them unpinned for now. * fix: Address linter issues (ruff, yamllint, shellcheck) - Fixed ruff configuration by moving linter settings to [tool.ruff.lint] section - Fixed ruff code issues: - Moved imports to top of files (E402) - Removed unused variables or commented them out - Updated string formatting from % to .format() - Replaced dict() calls with literals - Fixed assert False usage in tests - Fixed yamllint issues: - Added missing newlines at end of files - Removed trailing spaces - Added document start markers (---) to YAML files - Fixed 'on:' truthy warnings in GitHub workflows - Fixed shellcheck issues: - Properly quoted variables in shell scripts - Fixed A && B || C pattern with proper if/then/else - Improved FreeBSD rc script quoting All linters now pass without errors related to our code changes. * fix: Additional yamllint fixes for GitHub workflows - Added document start markers (---) to test-effectiveness.yml - Fixed 'on:' truthy warning by quoting as 'on:' - Removed trailing spaces from main.yml - Added missing newline at end of test-effectiveness.yml
189 lines
5.6 KiB
YAML
189 lines
5.6 KiB
YAML
name: Main
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
syntax-check:
|
|
name: Ansible syntax check
|
|
runs-on: ubuntu-22.04
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
- name: Check Ansible playbook syntax
|
|
run: ansible-playbook main.yml --syntax-check
|
|
|
|
basic-tests:
|
|
name: Basic sanity tests
|
|
runs-on: ubuntu-22.04
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
pip install jinja2 # For template rendering tests
|
|
sudo apt-get update && sudo apt-get install -y shellcheck
|
|
|
|
- name: Run basic sanity tests
|
|
run: |
|
|
python tests/unit/test_basic_sanity.py
|
|
python tests/unit/test_config_validation.py
|
|
python tests/unit/test_user_management.py
|
|
python tests/unit/test_openssl_compatibility.py
|
|
python tests/unit/test_cloud_provider_configs.py
|
|
python tests/unit/test_template_rendering.py
|
|
python tests/unit/test_generated_configs.py
|
|
|
|
docker-build:
|
|
name: Docker build test
|
|
runs-on: ubuntu-22.04
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
- name: Build Docker image
|
|
run: docker build -t local/algo:test .
|
|
|
|
- name: Test Docker image starts
|
|
run: |
|
|
# Just verify the image can start and show help
|
|
docker run --rm local/algo:test /algo/algo --help
|
|
|
|
- name: Run Docker deployment tests
|
|
run: python tests/unit/test_docker_localhost_deployment.py
|
|
|
|
config-generation:
|
|
name: Configuration generation test
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 10
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
- name: Test configuration generation (local mode)
|
|
run: |
|
|
# Run our simplified config test
|
|
chmod +x tests/test-local-config.sh
|
|
./tests/test-local-config.sh
|
|
|
|
ansible-dry-run:
|
|
name: Ansible dry-run validation
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 10
|
|
permissions:
|
|
contents: read
|
|
strategy:
|
|
matrix:
|
|
provider: [local, ec2, digitalocean, gce]
|
|
steps:
|
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
- name: Create test configuration for ${{ matrix.provider }}
|
|
run: |
|
|
# Create provider-specific test config
|
|
cat > test-${{ matrix.provider }}.cfg << 'EOF'
|
|
users:
|
|
- testuser
|
|
cloud_providers:
|
|
${{ matrix.provider }}:
|
|
server: test-server
|
|
size: t3.micro
|
|
image: ubuntu-22.04
|
|
region: us-east-1
|
|
wireguard_enabled: true
|
|
ipsec_enabled: false
|
|
dns_adblocking: false
|
|
ssh_tunneling: false
|
|
store_pki: true
|
|
algo_provider: ${{ matrix.provider }}
|
|
algo_server_name: test-algo-vpn
|
|
server: test-server
|
|
endpoint: 10.0.0.1
|
|
ansible_ssh_user: ubuntu
|
|
ansible_ssh_port: 22
|
|
algo_ssh_port: 4160
|
|
algo_ondemand_cellular: false
|
|
algo_ondemand_wifi: false
|
|
EOF
|
|
|
|
- name: Run Ansible check mode for ${{ matrix.provider }}
|
|
run: |
|
|
# Run ansible in check mode to validate playbooks work
|
|
ansible-playbook main.yml \
|
|
-i "localhost," \
|
|
-c local \
|
|
-e @test-${{ matrix.provider }}.cfg \
|
|
-e "provider=${{ matrix.provider }}" \
|
|
--check \
|
|
--diff \
|
|
-vv \
|
|
--skip-tags "facts,tests,local,update-alternatives,cloud_api" || true
|
|
|
|
# The || true is because check mode will fail on some tasks
|
|
# but we're looking for syntax/undefined variable errors
|