Skip to Content
xajbar

Schedule infrastructure reviews with GitHub Actions

Submit approved configuration, Trivy reports, or AWS Config inventory to Xajbar on a recurring schedule.

Create an Infrastructure configuration ingest token in the review workspace. Give the token a non-sensitive asset label that distinguishes the coverage scope, then save it as the GitHub Actions secret XAJBAR_INFRA_REVIEW_TOKEN in the repository.

Choose a UTF-8 Terraform .tf, Kubernetes .yaml, a previously generated Trivy .json report, or redacted AWS Config .json snapshot that the repository owner has approved for recurring review. Remove inline credentials, Kubernetes Secret resources, and customer data before enabling this workflow. Use a dedicated, sanitized file if the original cannot be shared in full.

For Trivy, point REVIEW_PATH at an approved SchemaVersion 2 vulnerability report in the repository. If your approved scanner pipeline keeps its output outside the repository, use the same Infrastructure configuration token and request body to submit the generated report from that pipeline. Avoid printing the report or token in logs. Import covers OS and language package vulnerabilities for container images, filesystems, and repositories. Use a separate asset label per scan scope so snapshots remain comparable. Trivy scope, redaction, and fallback behavior

For AWS Config, use the redacted snapshot format with a previously collected export.

Add .github/workflows/xajbar-infrastructure.yml to the protected default branch. Replace infra/service.yaml with the approved repository-relative path. The example runs daily at 02:17 UTC. Use Run workflow in GitHub Actions to verify the first submission from the default branch.

name: Xajbar infrastructure evidence review

on:
  schedule:
    - cron: "17 2 * * *"
  workflow_dispatch:

permissions:
  contents: read

jobs:
  submit:
    if: github.event_name == 'schedule' || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
    runs-on: ubuntu-latest
    timeout-minutes: 5
    env:
      GH_TOKEN: ${{ github.token }}
      XAJBAR_INFRA_REVIEW_TOKEN: ${{ secrets.XAJBAR_INFRA_REVIEW_TOKEN }}
      REVIEW_PATH: infra/service.yaml
    steps:
      - name: Read and submit the approved file
        shell: bash
        run: |
          set -euo pipefail
          python3 - <<'PY'
          import base64
          import json
          import os
          import subprocess
          import urllib.error
          import urllib.parse
          import urllib.request
          import uuid

          path = os.environ["REVIEW_PATH"]
          repo = os.environ["GITHUB_REPOSITORY"]
          commit = os.environ["GITHUB_SHA"]
          endpoint = f"repos/{repo}/contents/{urllib.parse.quote(path)}"
          source = subprocess.run(
              ["gh", "api", "--method", "GET", endpoint, "--raw-field", f"ref={commit}"],
              check=True,
              capture_output=True,
              text=True,
          )
          file = json.loads(source.stdout)
          if not isinstance(file, dict) or file.get("type") != "file" or file.get("encoding") != "base64":
              raise SystemExit("Choose one plain evidence file for review.")

          try:
              encoded = "".join(file["content"].split())
              evidence = base64.b64decode(encoded, validate=True).decode("utf-8")
          except (AttributeError, ValueError, KeyError):
              raise SystemExit("The approved file could not be read as UTF-8.") from None
          if not evidence.strip() or len(evidence.encode("utf-16-le")) // 2 > 80_000:
              raise SystemExit("The approved file must be nonempty and at most 80,000 UTF-16 code units.")

          run_id = os.environ["GITHUB_RUN_ID"]
          scope = f"xajbar:infrastructure:{repo}:{run_id}:{path}"
          snapshot_id = str(uuid.uuid5(uuid.NAMESPACE_URL, scope))
          request = urllib.request.Request(
              "https://xajbar.com/api/review-ingest",
              data=json.dumps({"id": snapshot_id, "evidence": evidence}, ensure_ascii=False).encode(),
              headers={
                  "Authorization": "Bearer " + os.environ["XAJBAR_INFRA_REVIEW_TOKEN"],
                  "Content-Type": "application/json",
              },
              method="POST",
          )

          class NoRedirect(urllib.request.HTTPRedirectHandler):
              def redirect_request(self, *args, **kwargs):
                  return None

          try:
              with urllib.request.build_opener(NoRedirect()).open(request, timeout=30) as response:
                  report = json.load(response)
          except urllib.error.HTTPError as error:
              raise SystemExit(f"Xajbar rejected the snapshot (HTTP {error.code}).") from None
          try:
              report_id = uuid.UUID(report["id"])
          except (AttributeError, KeyError, TypeError, ValueError):
              raise SystemExit("Xajbar returned an invalid report ID.") from None
          with open(os.environ["GITHUB_STEP_SUMMARY"], "a", encoding="utf-8") as summary:
              summary.write(
                  "### Xajbar infrastructure review\n\n"
                  f"[Open saved report](https://xajbar.com/dashboard/reviews/{report_id})\n"
              )
          print(f"Xajbar saved review {report_id} with {report['findings']} findings.")
          PY

The workflow reads one file at the commit selected by GitHub. It needs repository read access and does not check out or execute repository code. Keep the path fixed in the workflow so a manual run cannot substitute a different file. GitHub can delay scheduled runs during periods of high load. GitHub Actions schedule · GitHub repository contents API

Select Open saved report in the workflow summary. Sign in to the Xajbar account that issued the ingest token to open the report. Every scheduled run creates a snapshot, even when the file is unchanged. Re-running that same GitHub Actions run returns the existing report. AWS Config reports show grouped resource counts. Review newly reported findings and verify previously reported items before closing them. Replace the ingest token before its 90-day expiration to keep intake running.