Skip to main content

Your Own Test Library

An organization can keep its security tests in its own Git repository. There are two setups:

  1. Replace f0_library. Point TESTS_REPO_URL at your repository. The console reads only your tests.
  2. Add your repository beside f0_library. Keep f0_library and set CUSTOM_TESTS_REPO_URL to your repository. The console reads both and merges them into one library.

Repository layout​

Both setups use f0_library's layout. The tests live under a top-level tests_source/ folder: category folders (cyber-hygiene, intel-driven, mitre-top10, phase-aligned) inside it, and one folder per test in a category, named with its UUID:

security-tests/ # your repository
├── tests_source/ # the console reads tests from here only
│ └── intel-driven/
│ └── 3f6c1a2e-8b4d-4c5e-9a7f-1d2e3f4a5b6c/
│ ├── 3f6c1a2e-8b4d-4c5e-9a7f-1d2e3f4a5b6c.go
│ └── README.md
├── preludeorg-libraries/ # optional: shared Go code the tests import
└── utils/ # optional: shared build helpers

The console checks out only tests_source/, preludeorg-libraries/ and utils/. Anything else in the repository is not read. See Custom Tests for what goes in a test folder and the metadata the indexer reads (a local folder has the categories at its top; a repository has them inside tests_source/).

Tests outside tests_source/

A repository with its category folders at the top, and no tests_source/ folder, still syncs, but it lists 0 tests. Settings, then Tests, then Test library shows source_root_refused on that source: the console found no usable tests_source/ folder (missing, or a link). Move the category folders into tests_source/, push, and click Sync.

Settings are environment variables on the backend. Restart the backend after changing them.

Setup 1: your repository replaces f0_library​

TESTS_REPO_URL=https://git.example.com/example-org/security-tests.git
TESTS_REPO_BRANCH=main
TESTS_REPO_TOKEN=<token>

The backend clones it on start and Sync pulls it. Nothing from f0_library is read.

Setup 2: your repository beside f0_library​

# main library: unchanged (f0_library by default)
CUSTOM_TESTS_REPO_URL=https://git.example.com/example-org/security-tests.git
CUSTOM_TESTS_REPO_BRANCH=main
CUSTOM_TESTS_REPO_TOKEN=<token>

CUSTOM_TESTS_REPO_BRANCH defaults to main. Your repository is cloned into its own folder, separate from the main library's clone, so the two never share files.

You can also combine the two settings: a private main library (TESTS_REPO_URL plus TESTS_REPO_TOKEN) and an own repository beside it.

Environment variables​

VariablePurpose
TESTS_REPO_URLMain library repository. Default: the public f0_library. Empty turns Git off (see TESTS_SOURCE_PATH)
TESTS_REPO_BRANCHBranch of the main library (default main)
TESTS_REPO_TOKENAccess token for the main library
TESTS_REPO_USERNAMEUser name sent with the token (default x-access-token)
TESTS_LOCAL_PATHFolder the main library is cloned into
CUSTOM_TESTS_REPO_URLYour own repository, read beside the main library
CUSTOM_TESTS_REPO_BRANCHBranch of your repository (default main)
CUSTOM_TESTS_REPO_TOKENAccess token for your repository
CUSTOM_TESTS_REPO_USERNAMEUser name sent with the token (default x-access-token)
CUSTOM_TESTS_REPO_LOCAL_PATHFolder your repository is cloned into (default: data/custom-library under the backend; in Docker, the /app/data volume)

Tokens​

Public repositories need no token. For a private one, create a read-only access token on your Git host and set it in *_REPO_TOKEN. The backend sends it to Git as HTTP Basic credentials, <username>:<token>. It tries the repository without the token first and uses the token only when anonymous access fails, so an expired token never breaks a public repository.

Hosts want different user names. Set *_REPO_USERNAME when the default does not fit:

Git host*_REPO_USERNAME
GitHubx-access-token (the default)
GitLaboauth2
Azure DevOpsany non-empty name
Bitbucketx-token-auth
Giteathe account name

Tokens are sent only over https://:

  • A token on an http:// own repository: the own repository is not synced, and the backend logs a warning.
  • A token on an http:// main repository: the token is not used. Git stays on and syncs anonymously, with a warning.

GITHUB_TOKEN​

GITHUB_TOKEN is used for the main library only when TESTS_REPO_TOKEN is unset and TESTS_REPO_URL is an https:// address on github.com. It is never used for your own repository.

Upgrading with a non-GitHub main repository

If your main repository is not on github.com and you relied on GITHUB_TOKEN to reach it, the token is no longer sent. The backend logs a start-up warning. Set TESTS_REPO_TOKEN (and TESTS_REPO_USERNAME if your host needs another name).

Which test wins​

The library reads its sources in this order, and the first source that has a test UUID wins:

  1. The local folder (CUSTOM_TESTS_PATH, see Custom Tests)
  2. Your own repository (CUSTOM_TESTS_REPO_URL)
  3. The main library

A test in your repository with the same UUID as an f0_library test therefore replaces it. Remove it from your repository and sync to get the f0_library version back.

If CUSTOM_TESTS_REPO_URL and TESTS_REPO_URL name the same repository and branch, your repository is ignored, with a warning.

What Sync does​

Sync on the Tests page (POST /api/browser/tests/sync) pulls the main library, then your own repository, and re-reads every source. One repository failing does not stop the other: the answer says "Sync completed with errors", the failed repository keeps the tests it had, and the sync chip on the Tests page shows that source in error (hover it for every source). Sync fails as a whole only when every repository fails. Sync status (GET /api/browser/tests/sync/status) lists each source in sources: its repository (without credentials), branch, commit, last sync time, status and test count.

A failed source carries one fixed reason, never Git's own message: The test repository rejected the credentials, Could not reach the test repository, The test repository or branch was not found or The sync failed. A repository whose sync failed keeps its last published-version check: it never reads as freshly checked.

Git error messages are cleaned of tokens before they are logged or shown.

On github.com repositories reached over https with a token, the console also reads modification dates from the GitHub API. Other hosts show no such dates.

Switching libraries​

When you move an install to another library (for example from f0_library to your own repository), schedules and campaigns that use tests the new library does not have are not removed or paused. The console marks them so you can decide.

  1. Set the repository keys (TESTS_REPO_URL, CUSTOM_TESTS_REPO_URL and, for a private repository, the token) in your configuration.
  2. Run the deploy script again, or restart the backend.
  3. Click Sync on the Tests page.
  4. Schedules and campaigns that use a test no source has any more now show Not in the library: see Tasks, then Schedules, and Tasks, then Campaigns. The backend also logs [library] Not in the library: … at start-up and after each sync.
  5. Open Settings, then Tests, then Test library to see the sources, the problems found in your tests and Not in the library. Each schedule and campaign there links to its page; build folders left from tests no source has are listed by UUID, without a link.
  6. Pause or remove those schedules and campaigns, or add the tests back to your repository and sync again.
  7. Rebuild the tests from the new library, because earlier builds came from the old one.

Nothing is paused or deleted automatically. A schedule marked Not in the library stays as it is until you act on it.