-
Notifications
You must be signed in to change notification settings - Fork 10
Getting Started
This page is the canonical workflow for getting from “zero” to a working CRML simulation using the reference engine.
If you prefer a fully worked example set, jump straight to Examples.
- Python 3.10+
pip
See: Installation
pip install crml-engineVerify:
crml --helpOption A: start from a repo example:
crml-lang validate examples/scenarios/scenario-phishing.yamlOption B: create your own my-first-scenario.yaml:
crml_scenario: "1.0"
meta:
name: "my-first-risk-model"
description: "A simple phishing risk model"
scenario:
frequency:
basis: per_organization_per_year
model: poisson
parameters:
lambda: 0.10
severity:
model: lognormal
parameters:
median: 22000
currency: USD
sigma: 1.0Validate it:
crml-lang validate my-first-scenario.yamlThe reference engine only executes portfolio bundles (crml_portfolio_bundle).
- A
crml_scenariois not executable “in a vacuum” (it needs exposure/frequency context). - A
crml_portfoliois non-executable (it may reference other files); bundle it first.
Create my-first-portfolio.yaml:
crml_portfolio: "1.0"
meta:
name: "my-first-portfolio"
portfolio:
semantics:
method: sum
constraints:
require_paths_exist: true
validate_scenarios: true
assets:
- name: "org"
cardinality: 1
scenarios:
- id: "s1"
path: ./my-first-scenario.yamlBundle + simulate:
crml-lang validate my-first-portfolio.yaml
crml-lang bundle-portfolio my-first-portfolio.yaml my-first-portfolio-bundle.yaml
crml simulate my-first-portfolio-bundle.yaml --runs 10000If you want a ready-made bundle from the repo:
crml simulate examples/portfolio_bundles/portfolio-bundle-documented.yaml --runs 20000For JSON output:
crml simulate examples/portfolio_bundles/portfolio-bundle-documented.yaml --runs 20000 --format json > result.jsonThe reference engine supports an FX config document for output currency conversion.
This repo includes an OSCAL endpoints config at crml_lang/src/crml_lang/oscal/api-endpoints.yaml.
To generate CRML control catalogs for all catalog endpoints into the examples folder:
python -m crml_lang oscal export-catalogs \
--config crml_lang/src/crml_lang/oscal/api-endpoints.yaml \
--out-dir examples/control_catalogs \
--sort-keysValidate the generated files:
python -m crml_lang validate examples/control_catalogs/cisv8_1-control-catalog.yaml
python -m crml_lang validate examples/control_catalogs/bsi_gspp_2023-control-catalog.yamlIf you want a visual interface, see: CRML Studio Setup
- Semantics + portability rules: CRML Specification (Overview)
- Practical guidance: Best Practices
- If you get stuck: Troubleshooting