Skip to content
optionfactoryPublic

About

Aggregate and audit governance, compliance, and dependency security across your organization's repositories.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Elaine - governor of Melee Island.

A CLI tool for aggregating and inspecting governance manifests and dependency vulnerabilities across an organization's GitHub repositories.

What serve holds, who can do what with it and the known limits: SECURITY.md.

"That's the second biggest attack surface I've ever seen!"

— Elaine, sizing up your dependency tree.

Prerequisites

  • Read access to the repositories of the target organization: a GitHub App installed on it (see "Signing in as a GitHub App"), or a personal access token, provided via the GITHUB_TOKEN or GH_TOKEN environment variables or by having an active gh auth token session.
  • An elaine.conf.json configuration file in the working directory.
  • The ecosystem tools the scanners invoke: mvn, npm, go, and cargo with cargo-outdated (only needed for repositories using that ecosystem).
  • For the container images: docker with buildx, and grype, which keeps its own vulnerability database (a few GB, updated at every scan; one whose checksum fails, after a download cut short, is deleted and downloaded again). Without them every image shows as failed, and the rest of the scan goes on.

Installation

curl -sSL https://github.com/optionfactory/elaine/releases/latest/download/elaine-linux-amd64-musl \
  | sudo tee /usr/local/bin/elaine > /dev/null \
  && sudo chmod +x /usr/local/bin/elaine

Configuration

Create an elaine.conf.json file in the directory where you run the tool:

{
  "organization": "your-organization",
  "data_dir": "data",
  "address": "127.0.0.1",
  "port": 8000,
  "login": {
    "client_id": "{{ID}}.apps.googleusercontent.com",
    "client_secret": "{{SECRET}}",
    "public_url": "https://elaine.your-organization.com",
    "domain": "your-organization.com"
  }
}

All fields except organization are optional: data_dir defaults to data, the server binds to 127.0.0.1:8000, github_token can be set here or resolved from the environment, and omitting login serves the dashboard without authentication. Within login every field is required, domain included: without it any Google account would sign in. The file holds the tokens and the login secret: elaine refuses to start when every user of the machine can read it (its group may). What it writes in data_dir (the scan data, the images, what the last push brought, the logs) is readable only by its own user: files 0600, directories 0700; data_dir itself is left as the deployment sets it. Unknown fields are refused.

manifests_repository names the repository of the organization that holds the manifests of the repositories that cannot carry their own (see "Central manifests repository" under "Repository Manifests"). It defaults to elaine-<organization>-manifests, used only when the organization has a repository of that name; there is no setting that turns the central manifests off.

The pages load nothing from elsewhere: ftl and httpc (from fml, version 9.0.0) are in src/frontend/vendor/, built into the binary and pinned by their hash in each page; updating fml means copying its two dist files there and updating the hashes. The three fonts, Space Grotesk, Plus Jakarta Sans and JetBrains Mono, are in src/frontend/vendor/fonts/: the latin woff2 files served by Google Fonts, under the SIL Open Font License (OFL.txt next to them), built into the binary like the rest. Every page carries a Content-Security-Policy that runs only the site's own scripts and, by their hash, the inline scripts of that page, and takes fonts only from the site; every response says nosniff and sends no referrer, and the API is never cached.

With login, the whole dashboard (pages, assets and API) requires a Google login of domain: the authorization code flow with PKCE, then a session cookie valid for 12 hours (__Host- prefixed), signed with a key generated at every start (a restart signs everyone out). Sign-ins and refused logins are logged with the email. Only /favicon.svg and the pushes to /api/snapshot stay public. The OAuth client needs one authorized redirect URI, <public_url>/oidc/callback; /logout signs out.

Signing in as a GitHub App

A scan that runs as a service should not depend on a person's token. With github_app, sync signs in as a GitHub App of the organization:

{
  "organization": "your-organization",
  "github_app": {
    "app_id": 123456,
    "private_key_file": "github-app.pem"
  }
}

The app is created in the settings of the organization (Developer settings, GitHub Apps): no webhook, repository permissions "Contents: read-only" and "Metadata: read-only", then "Generate a private key" and "Install App" on the organization, with all its repositories or the ones to scan. app_id is the "App ID" of its settings page, private_key_file the downloaded .pem, relative to the working directory like elaine.conf.json, and refused the same way when every user of the machine can read it.

At each sync elaine signs a statement of being the app with that key, finds the installation of the app on organization and asks GitHub for a token of it, which lives one hour and is never written anywhere. sync is the only command that calls GitHub, so scan needs neither the key nor a token. github_app and github_token together are refused.

Scanning on a different machine

serve only needs the scan results, so the dashboard can run on a server while sync and scan run on another machine (the one holding the GitHub token and the ecosystem tools) that pushes the results to it.

On the server, set the token that pushes must present:

{
  "organization": "your-organization",
  "push_token": "{{A LONG RANDOM STRING}}"
}

On the scanning machine, point remote at the server:

{
  "organization": "your-organization",
  "remote": {
    "url": "https://elaine.your-organization.com",
    "token": "{{THE SAME STRING}}"
  }
}

With remote configured, scan pushes its results at the end, even when some repositories failed; elaine push sends the last results again without rescanning. Each push replaces everything the server shows; the server keeps one thing of the push before it, what the new push brought that it did not have, in last-push.json next to stats.json (the attention page lists it), written at every push whether or not mail is configured, and removed by the first push after a loss of data, which has nothing to compare with. The token travels in an HTTP header, so put the server behind a reverse proxy that terminates TLS. Without push_token, the server refuses every push. The token is checked before the body is read; a push may be at most 16 MB gzipped and 256 MB unzipped (a real one of a few hundred repositories is about 1 MB and 10 MB), and each repository's html_url must be under https://github.com/<organization>/, since the pages and the mails link to it. Refused pushes are logged, without the token.

Scanner image

ghcr.io/optionfactory/elaine-scanner holds elaine with every tool sync and scan call (Maven and the JDK, npm, Go, Cargo with cargo-outdated, grype, docker buildx), on the debian13-jdk25-builder of docker-machines. Its tags are <elaine version>-<image number> (1 for a new version of elaine, one more when the image of the same version is published again because its tools changed), <elaine version> and latest. Without a command it runs elaine sync && elaine scan:

docker run --rm \
  -e GITHUB_TOKEN \
  -v ./elaine.conf.json:/scan/elaine.conf.json:ro \
  -v elaine-data:/scan/data \
  -v elaine-home:/home/builder \
  ghcr.io/optionfactory/elaine-scanner

With a GitHub App in place of the token, the key is mounted next to the configuration (-v ./github-app.pem:/scan/github-app.pem:ro) and -e GITHUB_TOKEN goes away.

It runs as user 950 in /scan: the configuration file, and the key of the app, must be readable by that user and not by everyone. /scan/data keeps the archives and the scan data between runs, /home/builder the caches of the tools and the grype database (a few GB). docker buildx imagetools inspect reads the registries directly: no Docker socket is needed.

make check-updates compares the versions of the tools, pinned in the Makefile, with the latest ones; make build-scanner test-scanner builds the image and runs each tool in it; make publish-scanner builds it from scratch, tests it and pushes it with its SBOM and provenance.

Mail on new vulnerabilities

With alerts, the server mails the vulnerabilities each push brings that the previous one did not have (at most 200 listed in one mail, the subject counting them all and how many touch a tier 1 repository, the rest on the dashboard):

{
  "alerts": {
    "smtp_host": "smtp-relay.example.com",
    "smtp_port": 587,
    "from": "[email protected]",
    "to": "[email protected]"
  }
}

The relay must take mail without credentials (by the address of the server, for example). STARTTLS is required, except on a loopback address; smtp_port defaults to 587, and the domain of from is the name elaine gives in EHLO.

A vulnerability is new once per repository, artifact and advisory: the same advisory at another version of the artifact is not. The first push, or the first after the data was lost, sends nothing. A repository counts only when both pushes scanned it for vulnerabilities, so a scan that failed once does not make all its vulnerabilities new at the next; a repository that shows up for the first time counts whole. Archived repositories are left out, and so are the ones whose manifest declares the lifecycle prototype or end-of-life: they stay on the dashboard, only the mails skip them. A repository without a manifest, or without a lifecycle in it, is mailed. One that leaves prototype is mailed from then on only for what is new: what it already had is not announced. The push answers without waiting for the mail; a mail that fails is only logged.

The mail lists the new vulnerabilities by repository: the highest tier first, then the widest ingress of its environments (the internet first), then the most new vulnerabilities; without a manifest, a repository counts as tier 4 with unknown exposure, as on the risk matrix. Each repository comes with its tier and exposure, marked when it is in tier 1 or 2 and reachable from outside as on the risk matrix, its stewards as its manifest writes them, and a link to its page on the dashboard (to GitHub when the server has no login, hence no public_url). A vulnerability of an image appears under every repository that runs it. Above them, how many of the new vulnerabilities touch a tier 1 or 2 repository reachable from outside, how many repositories they touch and, when there are some, how many images; below, how many shipped vulnerabilities the live repositories have in all. The mail is HTML with a plain-text alternative that says the same, and loads nothing from elsewhere.

The container images follow the same rules, with the image compared without its tag (moving a repository to a newer tag does not announce again what the newer tag still has), and only their fixable high and critical vulnerabilities are mailed. An image is mailed when at least one repository the mails cover runs it, and the mail names only those repositories. The first push that scanned images sends nothing for them. A tag the previous push could not scan (Docker Hub rate limits the inspections) sends nothing either, rather than being compared with the other tags of its image.

Container images

After the repositories, scan looks at every image the live repositories run (from their pinch configurations and Ansible playbooks), once per image: it reads the SBOM the registry publishes for it with docker buildx imagetools inspect (the image is not pulled; for a multi-platform image, the linux/amd64 one) and runs grype --only-fixed on it. Only the vulnerabilities that already have a fix are kept: the ones a newer image removes. An image whose registry publishes no SBOM is shown as such and not scanned. This runs at every scan, also when no repository changed, since new advisories hit images that did not change. The registries rate limit the inspections (Docker Hub above all), so the SBOM is kept in <data_dir>/stats/sboms/ with the digest it belongs to, and inspected again only when the image's digest has changed: elaine asks for it first with a HEAD request on the manifest, which Docker Hub does not count, with an anonymous token. Grype still runs on every image at every scan. An image pinned by digest is never inspected twice; one whose registry refuses the HEAD (a private one) is inspected every time, as before; one rate limited anyway is scanned from its last SBOM. The results go to images.json next to stats.json, and travel in the push.

Without a login the registries are asked anonymously: enough for the public images, within the limit a registry gives to an address (on Docker Hub about a hundred inspections in six hours, shared by everyone behind that address: a first scan of many images goes over it, and the following ones complete it). registries gives a login by registry, as the image names write it, docker.io for Docker Hub:

{
  "registries": {
    "docker.io": { "username": "your-organization-bot", "token": "{{A READ-ONLY ACCESS TOKEN}}" },
    "ghcr.io": { "username": "your-organization-bot", "token": "{{A TOKEN THAT READS PACKAGES}}" }
  }
}

With a login the limit is the account's, and the private images of the registry are scanned like the public ones. elaine uses it for its own digest requests and hands it to docker buildx in a configuration directory of its own, made for the scan and removed after it: when registries is set, the docker login of the user running elaine is not read. A wrong login shows as failed images, with the answer of the registry.

The dashboard shows them apart from the vulnerabilities of the dependencies: on each repository, the images it runs with what their scan found; on the security page, a section with every image and its vulnerabilities, and in the ranking of the repositories a column with the fixable high and critical vulnerabilities of their images, which does not change the order.

Usage

elaine sync        # fetch repository metadata and cache .tar.gz archives from GitHub
elaine scan        # unpack and audit the cached repositories
elaine serve       # serve the dashboard and stats data over HTTP
elaine push        # send the scan results to the configured remote server
elaine bootstrap   # sync + scan + serve in one go
elaine init        # create a stub elaine.yaml manifest in the current folder
elaine clean-stats        # remove per-repository scan data, the aggregated stats file and what the last push brought
elaine clean-repositories # remove cached repository metadata and archives

The three main phases in detail:

  1. Sync: Fetch repository metadata from the GitHub API and cache source archives (.tar.gz) locally.

  2. Scan: Unpack the cached tarballs to temporary directories across concurrent workers. It scans for specific files, dependencies, and configurations (e.g., Ansible, Docker, legopfa, pinch) in a single pass, then runs per-ecosystem checks: known vulnerabilities via the OSV API and outdated dependencies via the ecosystem's own tooling.

    "Well, well, well, Log4Shell. You do turn up in the strangest of places."

    — Elaine, reviewing your outdated dependencies.

    Each vulnerability is either shipped or only in what builds and tests the repository. Build and test only are: Maven dependencies of test scope (from anarchitect 1.19; provided counts as shipped), npm packages the lockfile marks dev, crates reached only through Cargo dev or build dependencies or through a proc macro (from cargo metadata for x86_64-unknown-linux-gnu), Go modules only the tests compile. Only the modules some package compiles are checked for Go (go list -deps), not every module of the graph; npm packages for another platform than Linux x64 and crates for another target are left out. They are listed apart on the pages, and count neither in the risk matrix, the ranking and the filters, nor in the alert mails. When cargo metadata fails, every crate of Cargo.lock counts as shipped.

    When a check fails (tool missing, unparseable lockfile, OSV unreachable), the failure is recorded per repo and scanner, and the command's full output is kept in data/stats/logs/<repo>/<scanner>.log. The dashboard's Security page lists all failures and lets you inspect the logs.

    A repository that did not change since its last scan (its central manifest included), and whose checks all passed, is not unpacked again. Its dependencies are still checked against OSV at every scan, in one batch for all such repositories, from the list each scanner recorded at the last full scan (data/stats/dependencies/<repo>.json, kept on the scanning machine and never pushed): new advisories hit dependencies that did not change. For Maven the list comes from anarchitect-dependencies.json, written by anarchitect since 1.17; with an earlier anarchitect, the Maven vulnerabilities of an unchanged repository stay as the last full scan found them. If OSV cannot be reached, the repositories keep the vulnerabilities they had. A repository last scanned by a release whose scanners found things differently is scanned again in full, changed or not.

    A fork is scanned only when it has a manifest, its own or a central one: with it, the organization declares the fork its own, and it is scanned like any other repository. A live fork without a manifest is an unclassified fork: every scanner but the one that looks for a manifest skips it (dependencies, Docker files, pinch.yaml, Ansible playbooks, legopfa configurations), so elaine knows nothing of its vulnerabilities nor of the images it runs. The central manifests repository is the place for the manifest of a fork: an elaine.yaml committed in a fork diverges from upstream and ends up in the pull requests sent upstream. A parked fork from which nothing is shipped is better archived. The first scan of a fork that gets a manifest reports upstream's vulnerabilities as the organization's, which is right when the organization ships it; the alert mails say nothing of that first scan, since the previous push did not scan the fork, and announce what is new from the next one.

  3. Serve: Launch the embedded Axum web server to view the aggregated statistics in a browser dashboard. Pass --dev to serve frontend assets from ./src/frontend/ instead of the embedded binary.

    The repositories page, index.html, lists the repositories in a table, stacked items on a phone: classification, stewards, vulnerabilities shipped, outdated dependencies and last push, with a mark only for the exceptions (central manifest, unclassified fork, end of life while not archived, archived, disabled); a repository without a manifest says so in plain text. The bar next to the vulnerabilities shipped is on a fixed scale, the same on every row and on the ranking of the security page: a quarter from 1, half from 10, three quarters from 50, full from 200. Its filters are in a panel the Filters button opens and closes, a full-screen sheet on a phone; the panel opens on a desktop and stays closed on a phone at every load, nothing remembers it. The filters chosen are in the query string, so a link such as index.html?manifest=unclassified-fork opens the repositories page filtered.

    The attention page, attention.html, first in the navigation, lists what needs a decision, each row only when its number is above zero and each leading to the page where it is decided: the new vulnerabilities the last push brought, the live repositories with a failed check, the end-of-life repositories not archived, the unclassified forks, the central manifests out of place (a repository with its own elaine.yaml too, a file of the manifests repository naming no repository) and the compliance assessments still pending. Beside them, what the last push brought, as the mail counts it; with no push compared with an earlier one yet, it says there is nothing to compare with.

    Besides the attention, repositories, governance, security and inventory pages, each repository has its page, repository.html#<name>: what GitHub says of it, what its manifest declares, its compliance per framework, the vulnerabilities of its dependencies and of the images it runs, its outdated dependencies, its scanner failures with their logs, and the paths of the Docker files, Ansible configurations and legopfa configurations found in it. The governance page lists, among the rest, the repositories whose manifest declares end-of-life and that are not archived on GitHub: archiving them is what takes them out of the scans. Its coverage marks in orange a framework assessed on fewer than 80% of the repositories declaring compliance, and counts apart the live repositories without a compliance block, whether their manifest is missing or has no compliance section; its list of inactive repositories marks a repository idle for more than six months, an active one idle for more than a year first, and never one whose lifecycle is end-of-life or unmaintained. The unclassified forks are counted apart from the repositories without manifest: the repositories page has a number and a filter for them, the governance coverage a column, and the risk matrix and ranking of the security page leave them out. Each steward has theirs, steward.html#<steward>: their live repositories and the compliance frameworks still pending on them. A steward written as an email first.last@domain is the same person as First Last, and case does not count. The repository, steward and attention pages read the API, behind the login like the rest:

    • GET /api/attention: rows (in the order of the page, only those above zero, each with its kind: new-vulnerabilities with count, repositories and critical, those in tier 1 or 2; scanner-failures, end-of-life-not-archived and unclassified-forks with count; central-manifests with count, repositories and orphans; pending-assessments with count, and framework and pending for the framework with the most) and since_last_push (received_at, count and vulnerabilities, by advisory and package with their repositories and, for an image, the image and the version that fixes it; null when there is nothing to compare with).

    • GET /api/projects/{name}: the repository as /api/projects lists it, plus pending_frameworks (the compliance frameworks still to assess) and image_vulnerabilities (the fixable vulnerabilities of each scanned image it runs, by image); 404 when there is no such repository.

    • GET /api/stewards/{name}: steward (the name as the page shows it), written_as (the spellings found in the manifests), repositories (the live ones naming the steward: name, type, tier, lifecycle, counts of vulnerabilities shipped, of build and test only ones and of outdated dependencies, null when not checked, last push), pending (each framework still pending, with its repositories) and without_compliance (the repositories whose manifest has no compliance block); 404 when no repository names the steward.

Repository Manifests

Governance & Compliance (elaine.yaml)

Each repository can declare an elaine.yaml governance manifest at its root. Elaine audits it and surfaces the metadata (service tier, lifecycle, project type, regulatory applicability) in the dashboard, where the repositories page can filter projects on it. Repositories without a valid manifest show up as without manifest, except the live forks, which show up as unclassified forks (see the Scan phase under Usage):

"Less talking, more eviscerating, 'sweetie.'"

— Elaine, on repositories with no elaine.yaml.

# yaml-language-server: $schema=https://raw.githubusercontent.com/optionfactory/elaine/refs/heads/master/schema/elaine-v1.schema.json
schema_version: 1
name: "my-service"
type: service                # library | service | tool | infrastructure | documentation | playground
lifecycle: active            # active | maintenance | unmaintained | deprecated | end-of-life | prototype
tier: tier2                  # tier1 (24/7 SLA) -> tier4 (experimental)
stewards:
  - "[email protected]"
sensitivity:
  - pii
compliance:
  dora: non-critical         # EU Digital Operational Resilience Act
  cra: default               # EU Cyber Resilience Act
  nis2: important-entity     # EU NIS2 Directive
  ai_act: out-of-scope       # EU AI Act
  gdpr: controller           # GDPR processing role
  data_residency: eu         # EU | eea | us | global | not-applicable | pending-assessment
  ads: internal              # Italian Garante AdS responsibility
environments:
  - name: "production"
    type: production
    platform: cloud
    ingress: restricted-vpn
    dns: managed
    certificates: managed-acme-dns01
    domains:
      - api.example.com

Only schema_version and name are required; every other field is optional. Compliance fields left as pending-assessment (or ads pending-nomination) count as pending in the Compliance filter of the repositories page:

"Guybrush, this is important. Are you listening to me? This is IMPORTANT!"

— Elaine, on compliance fields still set to pending-assessment.

Adding the comment above as the first line of the file enables autocompletion and validation in IDEs with YAML language server support. Run elaine init to generate a stub.

Central manifests repository

Some repositories cannot carry an elaine.yaml, or should not: a fork of an upstream project, a repository of a customer, any repository where a file of elaine is unwanted. Their manifests can live in one repository of the organization: elaine-<organization>-manifests (elaine-your-organization-manifests for the configuration above), or the one manifests_repository names in elaine.conf.json:

{
  "organization": "your-organization",
  "manifests_repository": "elaine-manifests"
}

Without manifests_repository, a scan of an organization without a repository of the default name has no central manifests and says nothing about it; with it, a repository missing from the synced ones is said on the console, and the scan goes on without central manifests. There is no setting that turns them off: null is the same as leaving the field out, so whoever creates a repository of the default name starts the central manifests.

In that repository, the file elaine-<name>.yaml at the root is the manifest of the repository <name>, in the same schema as elaine.yaml: elaine-billing.yaml for billing, elaine-elaine-manifests.yaml for elaine-manifests. <name> is what remains of the file name without the first elaine- and the final .yaml, and must be the name of the repository exactly, case included. The prefix keeps the central files apart from the repository's own elaine.yaml and from any other YAML file at the root, with no directory to remember. Only files directly at the root count, and only with the .yaml extension (not .yml); the root elaine.yaml stays the manifest of the manifests repository itself, and any other file is ignored. Only the manifests repository is read for these files: an elaine-<name>.yaml in any other repository means nothing. scan reads them from the archive sync downloads, once per scan; when that archive is missing, it says so and scans as if there were no central manifests.

An elaine.yaml in the repository wins whole: the central file is ignored, no field is merged, and the repository shows a failed elaine/central-manifest check until one of the two is removed. A central file that does not parse leaves the repository without manifest, with a failed elaine/manifest check that names the file. A central file that names no repository of the organization (a misspelled name, a repository renamed or deleted since) is listed by a failed elaine/orphan-manifests check of the manifests repository, checked again whenever the manifests repository changes and at every scan while such a file is there. The repository page says when a manifest comes from the central repository.

A change of a central file makes its repository be scanned again in full at the next scan, even when the repository itself did not change.

Process Supervision (pinch.yaml)

Elaine also detects pinch.yaml manifests (the process supervisor's workflow manifest) and deduces the Docker container images declared by type: "docker" processes, reporting them as container dependencies.

Ansible playbooks

In a repository with an ansible.cfg, Elaine reads the playbooks and task files under its directory (the YAML files that are a list: a pinch.yaml, a docker-compose.yml or a GitHub workflow is a mapping, and is left out) and takes the string value of every image key (community.docker.docker_container, or a module of a collection that nests it) as a container image. The {{ a.b }} references are resolved against the vars of the play the image is in, over the variables of each inventory (the group_vars and host_vars in the same directory): one image per distinct result, so two inventories with different tags give two images. Only plain dotted lookups are resolved; an image with a filter or a loop variable ({{ item.image }}) is left out, and the repository shows a failed ansible/containers check that lists it. Symbolic links are not followed.

About

Aggregate and audit governance, compliance, and dependency security across your organization's repositories.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages