| Software used to build this page | |
| Item | Value |
|---|---|
| R | R version 4.5.2 (2025-10-31) |
| Platform | aarch64-apple-darwin20 |
| Quarto | 1.8.26 |
| Packages | In sync with renv.lock |
| recipes | 1.3.1 |
| evd | 2.3.7.1 |
| isotree | 0.6.1.5 |
| igraph | 2.2.1 |
| yardstick | 1.3.2 |
Reproducibility
Cyber Anomaly Detection & Dependency Risk: how to rerun the analysis and where the results can mislead
Every number on this site comes from a simulation defined in one parameter file, params.yaml, and run with explicit random seeds. Nothing is downloaded, and no external data are used. A single script, run_all.R, regenerates every result, and the pages only read and display those results. Package versions are pinned with renv. Rerunning the same commit with the restored packages should give identical numbers. The fingerprints below let you check that. This page explains how to rebuild the site, records the environment it was built in, and states where the results can mislead.
Quick start
The code is in the GitHub repository patrick-lefler/high-dimensional-cyber-anomaly-detection. To rebuild everything from a clean copy, run these commands from a terminal:
git clone https://github.com/patrick-lefler/high-dimensional-cyber-anomaly-detection
cd high-dimensional-cyber-anomaly-detection
Rscript -e 'renv::restore()' # once: install the package versions pinned in renv.lock
Rscript run_all.R # regenerate results/ (under a minute on a laptop)
Rscript -e 'testthat::test_dir("tests/testthat")' # optional: run the unit tests
rm -rf _freeze && quarto render # render the siteThe rendered site is written to docs/. The results/ folder is not committed, so run_all.R must run before the first render. A page rendered without it stops with the message “Results missing: run Rscript run_all.R first.” Deleting _freeze/ makes Quarto re-execute every page against the new results (see Caching).
Environment
How to read the table. Each row is one piece of software this page was built with and its version. The “Packages” row says whether the installed R packages match the versions pinned in renv.lock. The last five rows are the packages the results depend on most: recipes (preprocessing), evd (generalized Pareto fits for the thresholds), isotree (Isolation Forest baseline), igraph (service graph) and yardstick (evaluation metrics).
What the table tells you. If your versions match these and the packages are in sync, rebuilding the project should give the same numbers. If they differ, small differences in the results may come from the software rather than the analysis.
Pipeline
| File | What it does | Main outputs |
|---|---|---|
params.yaml |
Every simulation, model, threshold, policy and drift parameter, plus all seeds | Read by every script and page |
R/sim.R |
Simulates host-by-window telemetry from latent factors (daily cycle, AR(1) persistence, host role) and injects attacks at three intensities | simulate_study() |
R/ae.R |
Autoencoder forward pass, analytic gradients, Adam with early stopping, finite-difference gradient check | train_ae(), ae_reconstruct(), gradient_check() |
R/evt.R |
Generalized Pareto thresholds (with the \(\xi = 0\) limit), POT fitting, block bootstrap | gpd_tau(), fit_pot(), bootstrap_taus() |
R/baselines.R |
z-score, PCA, Mahalanobis and Isolation Forest detectors, AUC helpers | fit_baselines(), score_baselines() |
R/graph.R |
Service graph, row-stochastic transition matrix, PageRank, articulation points, removal impact, tiers | analyse_service_graph() |
R/drift.R |
PSI, Wasserstein distance, KS tests with Holm correction | drift_metrics() |
R/pipeline.R |
One full run for one seed: simulate, preprocess, train, fit threshold, evaluate | run_pipeline() |
run_all.R |
Main run, gradient check, architecture sweep, bootstrap, calibration, declustering, attribution, drift demo, graph, and the 30-seed study | results/*.rds |
R/pages/setup.R |
Sourced by every page: loads packages, project functions and cached results; sets theme, palettes and number formats | Shared page objects |
R/repro_env.R |
Builds the environment table on this page | repro_env_table() |
How to read the table. Each row is one file in the repository, listed in the order the analysis uses them. The middle column says what the file does in plain terms. The last column names the main functions or files it produces, so you can find where any number on the site was computed. Files in R/ only define functions. run_all.R calls them, and the pages read what it saves.
What the table tells you. The analysis has one entry point and one place for assumptions. Changing a parameter means editing params.yaml, rerunning run_all.R and re-rendering; no page computes anything that the script did not. Every page sources the same setup file, so all five analysis pages work from identical objects and cannot disagree with each other. The functions are small and individually tested, which makes each step straightforward to check or replace.
Data
There are no input data files. All telemetry, attacks and the service graph are generated by R/sim.R and R/graph.R from the values in params.yaml. To replace the simulation with real data, see Model limitations below.
Because the inputs are code and parameters, the useful check is on the outputs. The table fingerprints the parameter file and the key numeric results. File-level checksums of results/main.rds and results/graph.rds are not used: those files store a fitted recipe and an igraph object that carry session-specific environments and IDs, so their bytes change from run to run even when every number is identical.
Display code
fingerprints <- tibble(
Item = c(
"params.yaml (file)", "Test-set reconstruction losses", "EVT thresholds",
"Main-run summary metrics", "Service criticality table", "30-seed robustness results",
"Bootstrap threshold draws", "Drift metrics"
),
Method = c("MD5 of file", rep("rlang::hash() of object", 7)),
Fingerprint = c(
unname(tools::md5sum("params.yaml")),
rlang::hash(main$test$recon_loss), rlang::hash(main$taus), rlang::hash(main$summary),
rlang::hash(graph$table), rlang::hash(robust), rlang::hash(analysis$boot), rlang::hash(analysis$drift)
)
)
fingerprints |>
gt() |>
tab_header(title = md("**Fingerprints of the inputs and results used in this render**")) |>
cols_align(align = "left") |>
tab_options(table.font.size = 12)| Fingerprints of the inputs and results used in this render | ||
| Item | Method | Fingerprint |
|---|---|---|
| params.yaml (file) | MD5 of file | 6a85abecd760e45faf66964f1ac2ef9b |
| Test-set reconstruction losses | rlang::hash() of object | 59a94885a9afda6231211c7e5d3e37f4 |
| EVT thresholds | rlang::hash() of object | 7a8295a43f2aaf7a5b59cdd23cdbbc8d |
| Main-run summary metrics | rlang::hash() of object | 4e3cce24c019cfed5a3406eebf5ef18a |
| Service criticality table | rlang::hash() of object | 574452205516e40102ee6727cd51ed66 |
| 30-seed robustness results | rlang::hash() of object | 02ec3d22651bc58ca409337c4adc8334 |
| Bootstrap threshold draws | rlang::hash() of object | acd31b71c64cceb4740295b9a7fdc9bd |
| Drift metrics | rlang::hash() of object | 3d293c1bef87fa4e7bd066faa55ccd16 |
How to read the table. Each row is one input or result. The fingerprint is a short code computed from its exact contents. For the parameter file it is a standard MD5 checksum of the file. For results it is a hash of the numbers themselves, computed in R with rlang::hash(). Changing even one value produces a completely different code.
What the table tells you. Anyone who reruns run_all.R with the restored packages can compute the same fingerprints. If they all match, the rerun reproduced this site’s numbers exactly. We checked this by running the pipeline repeatedly, including the parallel 30-seed study, and every fingerprint matched. A mismatch on params.yaml means the assumptions changed. A mismatch on results with the same parameters points to a different package version.
Parameters and seeds
All assumptions live in params.yaml, each labelled as an assumption with its range. The seeds are:
- Main run: seed 42, used for every single-run plot and table.
- Robustness study: seeds 1 to 30, one complete pipeline each.
- Service graph: seed 7 for the simulated call volumes.
- Secondary analyses in
run_all.R(gradient check, architecture sweep, bootstrap, drift demo, routing) use fixed offsets from the main seed.
run_pipeline() calls set.seed() with its own seed at the start, so each run draws the same random numbers whether the 30-seed study runs on one core or many. The page also re-derives the heatmap sample from the main seed, so the “random” incidents shown are the same in every render.
Tests
Core functions are covered by testthat tests in tests/testthat/. The table shows the result of running them during this render.
Display code
test_results <- testthat::test_dir("tests/testthat", reporter = "silent", stop_on_failure = FALSE) |>
as.data.frame()
test_results |>
transmute(
Test = test,
Checks = nb,
Passed = nb - failed - as.integer(error) - skipped,
Failed = failed + as.integer(error),
Skipped = as.integer(skipped)
) |>
gt() |>
tab_header(
title = md("**Unit test results**"),
subtitle = sprintf("%d tests, %d checks", nrow(test_results), sum(test_results$nb))
) |>
tab_options(table.font.size = 12)| Unit test results | ||||
| 8 tests, 18 checks | ||||
| Test | Checks | Passed | Failed | Skipped |
|---|---|---|---|---|
| gpd_tau handles xi = 0 with the exponential limit | 3 | 3 | 0 | 0 |
| gpd_tau returns u at the threshold's own exceedance probability | 1 | 1 | 0 | 0 |
| analytic gradients match finite differences | 2 | 2 | 0 | 0 |
| transition matrix is row-stochastic and PageRank matches igraph | 3 | 3 | 0 | 0 |
| removal impact of an entry point is zero and of a shared sink is positive | 2 | 2 | 0 | 0 |
| drift metrics are near zero for identical samples | 2 | 2 | 0 | 0 |
| rank AUC is 1 for complete separation and 0.5 for ties | 2 | 2 | 0 | 0 |
| simulated host has one row per 5-minute window and all features | 3 | 3 | 0 | 0 |
How to read the table. Each row is one automated test of a core function. “Checks” is the number of individual conditions the test verifies, such as “this value is finite” or “these two answers agree”. “Passed”, “Failed” and “Skipped” count how those checks came out when the tests ran during this render. A healthy project shows every check passed and none failed or skipped.
What the table tells you. All 8 tests pass, covering 18 checks. They confirm that the threshold formula handles the exponential special case, that the hand-derived gradients match numerical estimates, that the transition matrix is a valid probability table and PageRank matches igraph, and that the drift metrics, AUC helper and simulator behave as expected. Because they run at every render, a broken function would show up here.
Caching
- Results cache (
results/*.rds). Written byrun_all.Rand read by every page. Pages never recompute it, and the folder is not in git. Rerunrun_all.Rafter any change toparams.yamlor to a script inR/. Nothing invalidates the cache automatically. - Quarto freeze (
_freeze/)._quarto.ymlsetsfreeze: auto, so a fullquarto renderre-executes a page only when that page’s.qmdfile changes. Changes toresults/or theR/scripts do not count. After rerunningrun_all.R, delete_freeze/and render the whole site, or render each page explicitly (for examplequarto render evaluation.qmd), because Quarto always executes a page that is rendered on its own.
Known limitations
Limits of reproducibility
- Bit-for-bit equality is expected only on the same platform and package versions. Floating-point and BLAS differences across machines can change low-order digits, and with them the fingerprints in the Data table, even when every reported figure is unchanged.
renv::restore()installs packages from CRAN. If a pinned version is removed from CRAN or its archive, or cannot be built on a newer R or operating system, the restore fails and the environment has to be rebuilt by hand.- The fingerprints for results use
rlang::hash(), whose output can change betweenrlangversions. Compare fingerprints only between runs with the samerlangversion. - Quarto versions affect rendering, not the numbers.
Model limitations
- Simulated data. The latent factors, marginals, correlations, seasonality and host roles are all assumptions. Real telemetry has missing data, logging changes, holidays and populations of very different hosts.
- Simulated attacks. Each attack changes a few features in single windows or short runs. Real campaigns move across hosts and over days.
- Heavy, discrete tail. Rare count features dominate extreme normal losses, so a single GPD fits poorly and the threshold depends on the chosen level \(u\). Per-host or per-role thresholds, or separate models for count features, may change the picture.
- Fixed threshold. \(\tau_q\) is fitted once. Thresholds that adapt over time, by rolling refit or by time of day, are not implemented.
- Dependency graph. The graph, call volumes and tier cut-offs are illustrative. The first-order Markov assumption is stated, not tested. See also the limitations of the graph layer.
- Prevalence. The test set is about 28% attacks. Real environments are orders of magnitude lower, which is why the base-rate table matters more than the ROC curve.
What real data would replace each assumption.
| Assumption | Where it is set | What would replace it |
|---|---|---|
| Simulated telemetry | R/sim.R |
At least four weeks of host-by-window telemetry with an asset inventory |
| Simulated attacks | params.yaml: attacks |
Labelled red-team or incident data |
| Dependency graph and call volumes | R/graph.R, params.yaml: graph |
Service-mesh call logs and session traces |
How to read the table. Each row is one simulated input. The middle column says where it is defined in the code, and the last column names the real data that would take its place in a production version.
What the table tells you. Every result on this site rests on these three simulated inputs. None of them has been checked against real telemetry, real attacks or a real service graph, so the detection rates and tiers are evidence that the method works on data like the simulation, not evidence of how it would perform in a given environment.
How to use the results. Use them to compare methods, to see how the thresholds and the base rate interact, and as a template for validating a detector on real data. Do not use the detection rates, false-alarm rates or criticality tiers as estimates for a real environment, and do not use them to justify automated containment: at realistic attack rates most alerts at the 99.9% threshold would be false alarms.
Licenses
The code on this site is released under the MIT License. There are no third-party data. Every data set is generated by the code in this repository and falls under the same license. The NIST AI Risk Management Framework and OSFI Guideline E-23 pages are cited by link only, and none of their content is redistributed. R packages keep their own licenses. They are installed through renv from public repositories and are not redistributed here. Most are MIT-licensed; those with other terms are:
| Package | Used for | License |
|---|---|---|
evd |
Generalized Pareto fits for the EVT thresholds | GPL-3 |
igraph |
Service graph, PageRank, articulation points | GPL (>= 2) |
binom |
Wilson confidence intervals on the Evaluation page | GPL |
future |
Parallel backend for the 30-seed study | LGPL (>= 2.1) |
isotree |
Isolation Forest baseline | BSD 2-clause |
yaml |
Reading params.yaml |
BSD 3-clause |
sessioninfo |
Session information below | GPL-2 |
Session information
The site was built with R and Quarto. The analysis loads tidyverse, gt, patchwork, scales and ggraph, and also calls recipes, yardstick, evd, igraph, isotree, binom, furrr, future, rlang, yaml, testthat, renv and sessioninfo. Package versions are pinned in renv.lock; run renv::restore() to install them.