Skip to content
Open
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
22 changes: 22 additions & 0 deletions .github/workflows/agentops-fleet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: AgentOps Fleet Gate

on:
push:
pull_request:
Comment on lines +4 to +5
workflow_dispatch:
schedule:
- cron: '31 8 * * 1'

permissions:
contents: read
actions: read
security-events: write
pull-requests: read

jobs:
agentops:
uses: donny-devops/github-actions-templates/.github/workflows/reusable-agentops.yml@main

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 Security Vulnerability: Pinning to a mutable branch reference (@main) allows the workflow definition to change without notice, potentially introducing malicious code into your CI/CD pipeline1.

Replace with a specific commit SHA or immutable tag to ensure workflow integrity and prevent supply chain attacks.

    uses: donny-devops/github-actions-templates/.github/workflows/reusable-agentops.yml@<commit-sha-here>

Footnotes

  1. CWE-829: Inclusion of Functionality from Untrusted Control Sphere - https://cwe.mitre.org/data/definitions/829.html

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Micro-Learning Topic: Inclusion of Functionality from Untrusted Control Sphere (CWE 829)

Matched on "CWE-829"

What is this? (2min video)

The software imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere.

Try a challenge in Secure Code Warrior

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Pin reusable workflow to immutable SHA

Reference the reusable workflow with a commit SHA instead of @main. GitHub’s reusable-workflow syntax allows branches, but using a moving branch makes this gate non-deterministic and lets upstream changes (or a compromised upstream branch) silently change what executes in this repo, including code that runs with this workflow’s token permissions. Pinning to an immutable SHA avoids unexpected breakages and supply-chain risk.

Useful? React with 👍 / 👎.

with:
python-version: '3.12'
node-version: '22'
run-security-audit: true
62 changes: 35 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ on:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

permissions:
contents: read

jobs:
lint:
name: Lint (ruff)
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v7

- uses: actions/setup-python@v5
with:
Expand All @@ -31,18 +29,13 @@ jobs:
- name: Lint with ruff
run: ruff check . --output-format=github

- name: Format with ruff
run: |
ruff format .
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git diff --quiet || git commit -am "style: auto-format with ruff" && git push
- name: Format check with ruff
run: ruff format --check .

test:
name: Test (pytest + PostgreSQL)
runs-on: ubuntu-latest
needs: lint

services:
postgres:
image: postgres:16-alpine
Expand All @@ -57,13 +50,12 @@ jobs:
--health-retries 5
ports:
- 5432:5432

env:
DATABASE_URL: postgresql://testuser:testpass@localhost:5432/testdb
SECRET_KEY: test-secret

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- uses: actions/setup-python@v5
with:
python-version: "3.12"
Expand All @@ -75,57 +67,73 @@ jobs:
pip install -r requirements.txt

- name: Run migrations
run: |
flask db upgrade
run: flask db upgrade
env:
FLASK_APP: "app:create_app()"

- name: Run pytest
run: |
pytest --cov=app --cov-report=xml --cov-fail-under=85 -v
run: pytest --cov=app --cov-report=xml --cov-fail-under=85 -v

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
retention-days: 7

docker:
name: Build & Push Docker Image
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write

security-events: write
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
uses: docker/login-action@v4
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=sha,prefix=sha-
type=raw,value=latest

- name: Build and push
uses: docker/build-push-action@v5
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true

- name: Trivy image scan
uses: aquasecurity/trivy-action@master
with:
image-ref: ghcr.io/${{ github.repository }}:latest
format: sarif
output: trivy.sarif
severity: HIGH,CRITICAL
exit-code: '0'

- name: Upload Trivy results
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: trivy.sarif
35 changes: 35 additions & 0 deletions .github/workflows/security-hygiene.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Security Hygiene

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

jobs:
hygiene:
name: Secret hygiene
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

- name: Checkout repository
uses: actions/checkout@v4

- name: Block obvious private keys and tokens
shell: bash
run: |
SECRET_PATTERN='BEGIN (RSA |OPENSSH |EC |DSA )?PRIVATE KEY|ghp_[A-Za-z0-9_]{20,}|github_pat_[A-Za-z0-9_]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{20,}|sk-[A-Za-z0-9]{20,}'
if grep -RInE "$SECRET_PATTERN" . \
--exclude-dir=.git \
--exclude=.github/workflows/security-hygiene.yml; then
echo "Potential secret material found. Remove it and rotate the credential."
exit 1
fi
Loading