import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react"; import { createPortal } from "react-dom"; import Link from "@site/src/react/shims/Link.jsx"; import data from "@site/src/data/test-builder.json"; import Markdown, { firstTable } from "./Markdown"; import { NEW, emptyState, exampleState, functionNameFor, validate, buildPs1, buildMd, buildCommand, folderFor, addByHand, registryChanges, withPrefix, splitList, stateFromTest, parsePermission, PARAMETER_TYPES, emptyParameter, parameterForSetting, resolveParameter, settingOf, buildConfigExample, scaffoldedSettings } from "./generate"; import { AttributeIcon, Badge, Button, Checkbox, Combobox, DeleteIcon, Flag, HelpButton, LevelIcon, OptionIcon, PlusIcon, osGlyph, Input, RadioCards, RadioPills, Select, Sheet, Tabs, TabsContent } from "./ui"; import GitHubPeople from "./GitHubPeople"; import { fieldHelp } from "./help"; import LicenseExplorer, { indexCatalog, planLabel } from "./LicenseExplorer"; import styles from "./styles.module.css"; import { productIcon, productInitials, featureIcon } from "../../lib/report-icons.mjs"; const REPO = "https://github.com/maester365/maester/blob/main/"; const tacticName = Object.fromEntries(data.attack.tactics.map((t) => [t.id, t.name])); const techniqueById = Object.fromEntries(data.attack.techniques.map((t) => [t.id, t])); const PREFIX_KEY = "maester.testBuilder.customPrefix"; // Requirements of the frameworks in the repository, and the controls they relate to. const requirementItems = data.frameworks.flatMap((f) => f.requirements.map((r) => { const detail = [f.name, r.level, r.criticality, r.tests.length ? "implemented by " + r.tests.join(", ") : "no test yet"].filter(Boolean).join(" · "); return { value: f.key + ":" + r.id, label: f.key + ":" + r.id, hint: detail, search: (f.key + ":" + r.id + " " + detail).toLowerCase() }; }) ); const relatedItems = [...new Set(data.frameworks.flatMap((f) => f.requirements.flatMap((r) => r.related || [])))].sort().map((c) => ({ value: c, label: c, hint: "Related to requirements in the repository" })); const nistItems = data.nist.controls.map((c) => ({ value: data.nist.key + ":" + c.id, label: data.nist.key + ":" + c.id, hint: c.title, search: (data.nist.key + ":" + c.id + " " + c.title).toLowerCase() })); const nistValues = new Set(nistItems.map((i) => i.value)); const controlItems = requirementItems.concat(nistItems, relatedItems.filter((i) => !nistValues.has(i.value))); const knownLicenses = new Set(data.licenses); const attackUrl = (id) => "https://attack.mitre.org/techniques/" + id.replace(".", "/") + "/"; function RepoFile({ path }) { return ( {path} ); } // Only one help panel is open at a time; this holds the id of the field it belongs to. const HelpContext = React.createContext({ openId: null, setOpenId: () => {} }); // With the form and the code side by side, the help panel covers the code column and leaves the form in view. // In one column it slides in at the right edge of the window. function useDock(open) { const [place, setPlace] = useState(undefined); useEffect(() => { if (!open) return undefined; const measure = () => { const dock = document.querySelector("[data-help-dock]"); const form = dock && dock.previousElementSibling; if (!dock || !form) return setPlace(undefined); const side = dock.getBoundingClientRect().left > form.getBoundingClientRect().right; setPlace(side ? { left: Math.max(0, dock.getBoundingClientRect().left - 12), width: "auto" } : undefined); }; measure(); window.addEventListener("resize", measure); return () => window.removeEventListener("resize", measure); }, [open]); return place; } // Links to the guides open in the help panel on this page, so the form stays in view while you read them: the // sidebar's guides, links in the page and the builder, and links in a field's help. Links to other guides inside // a guide open there too; anything else opens in a new tab. const SIDEBAR_LINKS = "#starlight__sidebar ul.top-level a[href]"; const PAGE_LINKS = "main a[href]:not([target]), [data-help-sheet] a[href]:not([target])"; const isGuide = (url) => url.origin === window.location.origin && url.pathname.startsWith("/docs/"); const plainClick = (e) => e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.defaultPrevented; function useGuides(setOpenId) { const [guide, setGuide] = useState(null); const latest = useRef(null); const openGuide = useCallback( (href) => { const url = new URL(href, window.location.href); latest.current = url.href; setGuide((g) => ({ href: url.href, title: g && g.href === url.href ? g.title : "Loading…", html: null, error: false })); setOpenId("guide"); fetch(url.pathname) .then((r) => (r.ok ? r.text() : Promise.reject(new Error(r.status)))) .then((text) => { if (latest.current !== url.href) return; const page = new DOMParser().parseFromString(text, "text/html"); const content = page.querySelector(".sl-markdown-content"); if (!content) throw new Error("No content"); // The styles and scripts a guide's components bring (code blocks bring their own) load once into this page. content.querySelectorAll('link[rel="stylesheet"], script[src]').forEach((el) => { const isLink = el.tagName === "LINK"; const src = new URL(el.getAttribute(isLink ? "href" : "src"), url).pathname; if (!document.head.querySelector(isLink ? 'link[href="' + src + '"]' : 'script[src="' + src + '"]')) { const copy = document.createElement(isLink ? "link" : "script"); if (isLink) { copy.rel = "stylesheet"; copy.href = src; } else { copy.type = "module"; copy.src = src; } document.head.appendChild(copy); } el.remove(); }); content.querySelectorAll("a[href], img[src]").forEach((el) => { const attr = el.tagName === "A" ? "href" : "src"; const raw = el.getAttribute(attr); if (raw.startsWith("#")) return; const target = new URL(raw, url); el.setAttribute(attr, target.origin === window.location.origin ? target.pathname + target.search + target.hash : target.href); if (attr === "href" && !isGuide(target)) { el.setAttribute("target", "_blank"); el.setAttribute("rel", "noreferrer"); } }); const h1 = page.querySelector("h1"); setGuide({ href: url.href, title: h1 ? h1.textContent.trim() : url.pathname, html: content.innerHTML, error: false }); }) .catch(() => latest.current === url.href && setGuide((g) => ({ ...g, title: "Could not load the guide", error: true }))); }, [setOpenId] ); // Sidebar links only while the sidebar is shown beside the page (Starlight's 50rem breakpoint); below that it is // a menu over the page, and a guide opens as a page of its own. useEffect(() => { const onClick = (e) => { if (!plainClick(e) || !e.target.closest) return; const a = (window.matchMedia("(min-width: 50rem)").matches && e.target.closest(SIDEBAR_LINKS)) || e.target.closest(PAGE_LINKS); if (!a) return; const url = new URL(a.href, window.location.href); if (!isGuide(url)) return; e.preventDefault(); openGuide(url.href); }; document.addEventListener("click", onClick); return () => document.removeEventListener("click", onClick); }, [openGuide]); return [guide, openGuide]; } function GuidePanel({ guide, open, onClose, openGuide }) { const place = useDock(open); const body = useRef(null); useEffect(() => { // A new guide starts at the top of the panel. if (body.current && body.current.parentElement) body.current.parentElement.scrollTop = 0; }, [guide]); const onClick = (e) => { const a = e.target.closest && e.target.closest("a[href]"); if (!a || !plainClick(e)) return; const raw = a.getAttribute("href"); if (raw.startsWith("#")) { e.preventDefault(); const target = body.current && body.current.querySelector("#" + CSS.escape(decodeURIComponent(raw.slice(1)))); if (target) target.scrollIntoView({ behavior: "smooth", block: "start" }); return; } const url = new URL(a.href, window.location.href); if (isGuide(url) && url.pathname !== window.location.pathname) { e.preventDefault(); openGuide(url.href); } }; return ( !o && onClose()} title={guide ? guide.title : ""} style={place} actions={ guide && ( ) } > {guide && guide.error &&

The guide could not be loaded. Open it in a new tab instead.

} {guide && !guide.error && !guide.html &&

Loading…

} {guide && guide.html &&
} ); } // A help panel and the button that opens it. The panel is rendered by the field itself, so it follows the form's state. function Help({ id, title, badge, label, children }) { const { openId, setOpenId } = useContext(HelpContext); const open = openId === id; const place = useDock(open); return ( <> setOpenId(open ? null : id)}> {label} !o && setOpenId(null)} title={title} badge={badge} style={place}> {children} ); } // A form field. The input and any problems are shown inline; what the attribute means, the rubric and how to // add a missing value open in the help panel, so the form stays short. function Field({ id, name, label, required, hint, guide, rubric, rubricTitle, notInList, problems, children }) { const mine = problems.filter((p) => p.field === id); const { builtin } = useContext(HelpContext); const extra = fieldHelp(id, builtin); const hasHelp = hint || guide || rubric || notInList || extra; return (
{!required && Optional} {hasHelp && ( {hint &&

{hint}

} {extra && extra.more && } {extra && extra.empty && ( <>

If you leave it empty

)} {guide} {rubric && ( <>

{rubricTitle || "How to choose"}

)} {notInList && ( <>

Not in the list?

{notInList} )}
)}
{children} {mine.map((p, i) => (

{p.text}

))}
); } function Checks({ id, values, options, onChange, describe, iconFor }) { const toggle = (v) => onChange(values.includes(v) ? values.filter((x) => x !== v) : [...values, v]); return (
{options.map((o) => ( toggle(o)}> {iconFor && } {describe ? describe(o) : o} ))}
); } const productIconOf = (key) => ({ icon: productIcon(key), initials: productIcon(key) ? undefined : productInitials(key) }); const techniqueItems = data.attack.techniques.map((t) => ({ value: t.id, label: t.id + " " + t.name, hint: t.tactics.map((x) => tacticName[x]).join(", ") })); function MitrePicker({ selected, none, onChange, onNone }) { return (
None: no attacker behaviour is behind this test (an inventory count, replication health) {!none && ( <> !selected.includes(id) && onChange([...selected, id])} /> {selected.length > 0 && (
    {selected.map((id) => { const t = techniqueById[id]; return (
  • {id} {" "} {t ? t.name : "Unknown"} {t && · {t.tactics.map((x) => tacticName[x]).join(", ")}}
  • ); })}
)} )}
); } const productSummary = (products) => { const names = products.slice(0, 3).map((p) => p.name); return "In " + names.join(", ") + (products.length > 3 ? " and " + (products.length - 3) + " more" : ""); }; // Parameters: the values an administrator can change. One card per parameter. A parameter bound to a registered // setting takes its type, default and allowed values from the registry, so only its name and description are typed. function ParameterBuilder({ parameters, builtin, onChange }) { const update = (index, patch) => onChange(parameters.map((p, i) => (i === index ? { ...p, ...patch } : p))); const remove = (index) => onChange(parameters.filter((_, i) => i !== index)); const bindable = data.settings.filter((s) => !s.connection && s.type !== "object"); const unused = bindable.filter((s) => !parameters.some((p) => settingOf(p, data) === s)); return (
{data.parameterNames.map((n) => ( ))} {parameters.map((raw, index) => { const p = resolveParameter(raw, data); const setting = settingOf(raw, data); const used = data.parameterNames.find((n) => n.name.toLowerCase() === p.name.trim().toLowerCase()); return (
Type {setting ? (
{setting.type}
) : ( update(index, { description: e.target.value.replace(/[\r\n]/g, " ") })} /> {setting ? (

Bound to the setting {setting.name}, which an administrator sets once in GlobalSettings. The settings registry gives it its type {p.default ? ", its default (" + p.default + ")" : ""} {p.allowedValues.length ? " and its allowed values (" + p.allowedValues.join(", ") + ")" : ""}.

) : ( <> {raw.type === "switch" ? (

A switch is off by default. Name it after what turning it on does.

) : (
{raw.type === "int" && ( <> )} {(raw.type === "string" || raw.type === "string[]") && ( <>
Holds update(index, { setting: e.target.value.trim() })} /> )} )} {used && !setting && used.type === p.type && (

{used.tests} built-in {used.tests === 1 ? "test uses" : "tests use"} {used.name}. Reuse the name only if it means the same thing here.

)}
); })}
setDraftFor(index, { service: v, kind: undefined })} placeholder="Service" options={registry.map((s) => ({ value: s.name, label: s.name }))} /> setDraftFor(index, { name: e.target.value })} onKeyDown={(e) => e.key === "Enter" && (e.preventDefault(), add())} /> {shown.length > 1 && ( )}
)}
); })}
{filled.length > 0 && (

The identity Maester signs in with needs {filled.map((g, i) => ( {i > 0 && and } {filled.length > 1 && g.length > 1 && "("} {g.map((text) => (parsePermission(text) || { name: text }).name).join(" or ")} {filled.length > 1 && g.length > 1 && ")"} ))} . Maester records this on the result; it does not skip the test on it yet.

)}
); } function LicenseBuilder({ groups, onChange }) { const [catalog, setCatalog] = useState(null); const [exploring, setExploring] = useState(null); useEffect(() => { let live = true; import("@site/src/data/license-service-plans.json").then((m) => live && setCatalog(indexCatalog(m.default || m))); return () => { live = false; }; }, []); const items = useMemo(() => { if (!catalog) return []; return catalog.plans.map((plan) => ({ value: plan.name, label: planLabel(plan), plan, hint: productSummary(plan.products), primary: plan.search, weight: plan.products.length, search: plan.search + " " + plan.products.map((p) => p.search).join(" "), })); }, [catalog]); // When the search text matched a product, not the plan itself, name that product first. const hintFor = (item, q) => { if (!q || item.primary.includes(q)) return item.hint; const product = item.plan.products.find((p) => p.search.includes(q)); return product ? "In " + product.name + " (" + product.stringId + ")" + (item.plan.products.length > 1 ? " and " + (item.plan.products.length - 1) + " more" : "") : item.hint; }; const shown = groups.length ? groups : [[]]; const update = (index, plans) => onChange(shown.map((g, i) => (i === index ? plans : g))); const known = (name) => catalog && catalog.planByName[name]; const label = (name) => (known(name) ? planLabel(known(name)) : name); const filled = shown.filter((g) => g.length); return (

A test requires service plans, the building blocks inside a product such as Microsoft 365 E5. Plans inside one box are joined with and: the tenant needs all of them. Boxes are joined with or: any one box is enough.

{shown.map((group, index) => ( {index > 0 &&
or
}
{group.length > 0 && (
    {group.map((name, n) => (
  • {n > 0 && and } {label(name)} {catalog && !known(name) && · not on Microsoft's list; matched as written} {known(name) && · {productSummary(known(name).products)}} {knownLicenses.has(name) && · Maester also counts its government and education variants}
  • ))}
)}
!group.includes(v) && update(index, [...group, v])} /> {shown.length > 1 && ( )}
))}
{filled.length > 0 && (

The test runs when the tenant has {filled.map((g, i) => ( {i > 0 && or } {filled.length > 1 && g.length > 1 && "("} {g.map((name) => (known(name) && known(name).friendly) || name).join(" and ")} {filled.length > 1 && g.length > 1 && ")"} ))} . Otherwise it is skipped.

)} {catalog && exploring !== null && shown[exploring] && ( !open && setExploring(null)} index={catalog} selected={shown[exploring]} onAdd={(name) => update(exploring, [...shown[exploring], name])} onRemove={(name) => update(exploring, shown[exploring].filter((x) => x !== name))} /> )}
); } function CopyBlock({ text, language }) { const [copied, setCopied] = useState(false); const copy = () => { const done = () => { setCopied(true); setTimeout(() => setCopied(false), 1500); }; if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(text).then(done, () => {}); }; return (
        {text}
      
); } // The icon beside each field's label and each step. An attribute the report shows has the report's icon. const FIELD_ICONS = { suite: "source", prefix: "tag", id: "id", title: "title", functionName: "code", product: "product", feature: "feature", relatedProducts: "related", area: "area", resourceType: "resource", severity: "severity", userImpact: "impact", implementationCost: "effort", mitre: "attack", control: "framework", services: "service", license: "licence", permission: "permission", tenantType: "tenant", cloud: "cloud", platform: "platform", parameters: "params", lifecycle: "lifecycle", replacedBy: "related", flags: "duration", author: "person", contributor: "impact", tags: "tag", }; const STEP_ICONS = { start: "person", name: "id", about: "product", priority: "severity", mapping: "framework", services: "service", licences: "licence", permissions: "permission", environment: "cloud", parameters: "params", lifecycle: "lifecycle" }; const LIFECYCLE_ICONS = { Preview: ["preview", "info"], Stable: ["stable", "ok"], Deprecated: ["deprecated", "low"] }; // Services show the icon of the product they connect to. Microsoft Graph has no icon of its own in the set, so it // shows Microsoft 365's; Dataverse has none either and shows its initials. const SERVICE_PRODUCT = { ActiveDirectory: "ad", Azure: "azure", AzureDevOps: "azure-devops", ExchangeOnline: "exchange", GitHub: "github", Graph: "microsoft-365", SecurityCompliance: "purview", SharePointOnline: "sharepoint", Teams: "teams" }; const serviceIconOf = (name) => (SERVICE_PRODUCT[name] && productIcon(SERVICE_PRODUCT[name]) ? { icon: productIcon(SERVICE_PRODUCT[name]) } : { initials: name.slice(0, 2) }); // Tenant types: the value written to the attribute stays Workforce or External; the label says what External // means. Workforce shows the Entra ID icon the report uses. External shows Microsoft's External ID icon // (public/img/icons/external-id.svg, from https://az-icons.com/icon/external-id-modified, unchanged). const TENANT_TYPES = { Workforce: { label: "Workforce", icon: productIcon("entra") }, External: { label: "External (Consumer)", icon: "/img/icons/external-id.svg" }, }; // Clouds: the country whose cloud it is, shown as a flag. Commercial is the worldwide cloud and shows a globe. const CLOUDS = { Commercial: { label: "Worldwide" }, GCC: { country: "us", label: "United States" }, GCCHigh: { country: "us", label: "United States" }, DoD: { country: "us", label: "United States" }, China: { country: "cn", label: "China" }, Bleu: { country: "fr", label: "France" }, Delos: { country: "de", label: "Germany" }, GovSG: { country: "sg", label: "Singapore" }, }; // The rating fields show a level icon on each choice, so the scale reads at a glance. const SEVERITY_LEVEL = { Critical: 4, High: 3, Medium: 2, Low: 1, Info: 0 }; const SCALE_LEVEL = { Low: 1, Medium: 2, High: 3 }; const SCALE_TONE = { Low: "low", Medium: "medium", High: "high" }; const severityOptions = (options) => options.map((o) => ({ ...o, icon: })); const scaleOptions = (options) => options.map((o) => ({ ...o, icon: })); // The form is shown one step at a time. Each step lists the fields whose problems count against it. const STEPS = [ { key: "start", label: "Who it is for", fields: [] }, { key: "name", label: "Name", fields: ["suite", "prefix", "id", "title", "functionName"] }, { key: "about", label: "Subject", fields: ["product", "feature", "relatedProducts", "area", "resourceType"] }, { key: "priority", label: "Priority", fields: ["severity", "userImpact", "implementationCost"] }, { key: "mapping", label: "Mapping", fields: ["mitre", "control"] }, { key: "services", label: "Service connections", fields: ["services"] }, { key: "licences", label: "Licences", fields: ["license"] }, { key: "permissions", label: "Permissions", fields: ["permission"] }, { key: "environment", label: "Where it applies", fields: ["tenantType", "cloud", "platform"] }, { key: "parameters", label: "Parameters", fields: ["parameters"] }, { key: "lifecycle", label: "Lifecycle and credit", fields: ["lifecycle", "replacedBy", "flags", "author", "contributor", "tags"] }, ]; const stepOfField = (field) => (STEPS.find((s) => s.fields.includes(field)) || STEPS[0]).key; const stepOfHash = (hash) => { const value = (hash || "").replace(/^#/, ""); if (value.startsWith("field-")) return stepOfField(value.slice(6)); return STEPS.some((s) => s.key === value) ? value : null; }; // The list of steps: in the site's sidebar on a wide screen, a row above the form on a narrow one. A step shows // a tick once it has been opened and has nothing to fix, or the number of things to fix. function StepList({ steps, step, onStep, className }) { return (
    {steps.map((s, index) => (
  1. ))}
); } // Start from a test that ships with Maester: type its ID or part of its title. The list is fetched the first // time the picker is used, so the page does not carry all the tests. function ExistingTestPicker({ onLoad }) { const [tests, setTests] = useState(null); const [failed, setFailed] = useState(false); const load = useCallback(() => { if (tests || failed) return; fetch("/data/builder-tests.json") .then((response) => (response.ok ? response.json() : Promise.reject(new Error(String(response.status))))) .then(setTests, () => setFailed(true)); }, [tests, failed]); const items = useMemo(() => (tests || []).map((t) => ({ value: t.Id, label: t.Id + " " + t.Title, hint: t.Suite, ...productIconOf(t.Product) })), [tests]); return (
{ const test = (tests || []).find((t) => t.Id === id); if (test) onLoad(test); }} />
); } export default function TestBuilder() { const [state, setState] = useState(exampleState); const [tab, setTab] = useState("ps1"); const [loaded, setLoaded] = useState(null); const [step, setStepState] = useState("start"); const [seen, setSeen] = useState(["start"]); const [railHost, setRailHost] = useState(null); const formRef = useRef(null); const jump = useRef(null); const [jumps, setJumps] = useState(0); const [helpId, setHelpId] = useState(null); const helpContext = useMemo(() => ({ openId: helpId, setOpenId: setHelpId, builtin: state.mode === "builtin" }), [helpId, state.mode]); const [guide, openGuide] = useGuides(setHelpId); const set = (patch) => setState((s) => ({ ...s, ...patch })); const builtin = state.mode === "builtin"; const P = data.properties; const R = data.rubric; const problems = useMemo(() => validate(state, data), [state]); const errors = problems.filter((p) => p.level === "error"); const product = data.products.find((p) => p.key === state.product); const features = product ? product.features : []; const suite = data.suites.find((s) => s.id === state.suite); const area = data.areas.find((a) => a.key === state.area); const resourceType = data.resourceTypes.find((r) => r.key === state.resourceType); const id = state.id.trim() || (builtin ? "MT.1234" : "CT.1001"); const folder = folderFor(state, data); const changes = registryChanges(state, data); const byHand = addByHand(state); const firstFramework = state.controls.find((c) => data.frameworks.some((f) => c.startsWith(f.key + ":") && f.requirements.some((r) => f.key + ":" + r.id === c))); const need = (name) => builtin && P[name].required !== "No"; // Steps. The address keeps the step, so a link or a reload opens it; a link to a field opens the field's step. const setStep = useCallback((key, field) => { setStepState(key); setSeen((list) => (list.includes(key) ? list : [...list, key])); setHelpId(null); try { window.history.replaceState(null, "", "#" + key); } catch (e) { // The address is not updated; the step still opens. } jump.current = { field }; setJumps((n) => n + 1); }, []); const goField = (field) => setStep(stepOfField(field), field); // After the step is on the page: bring the field, or the top of the form, into view. useEffect(() => { if (!jump.current) return; const { field } = jump.current; jump.current = null; const target = field ? document.getElementById("field-" + field) : formRef.current; if (!target) return; if (field) target.scrollIntoView({ block: "center" }); else if (target.getBoundingClientRect().top < 0) target.scrollIntoView({ block: "start" }); const input = field && document.getElementById("input-" + field); if (input && input.focus) input.focus({ preventScroll: true }); }, [jumps]); useEffect(() => { setRailHost(document.getElementById("mt-builder-steps")); const open = () => { const hash = window.location.hash; const key = stepOfHash(hash); if (key) setStep(key, hash.startsWith("#field-") ? hash.slice(7) : undefined); }; open(); window.addEventListener("hashchange", open); return () => window.removeEventListener("hashchange", open); }, [setStep]); const steps = STEPS.map((s) => { const count = errors.filter((p) => s.fields.includes(p.field)).length; return { ...s, errors: count, done: seen.includes(s.key) && count === 0 && s.key !== step, optional: !builtin && !["start", "name"].includes(s.key) }; }); const stepIndex = STEPS.findIndex((s) => s.key === step); // The prefix of custom tests is remembered in this browser. useEffect(() => { try { const saved = window.localStorage.getItem(PREFIX_KEY); if (saved && /^[A-Za-z][A-Za-z0-9]*$/.test(saved)) setState((s) => ({ ...s, customPrefix: saved, id: s.mode === "custom" ? withPrefix(s.id, saved) : s.id })); } catch (e) { // Storage is not available: the default prefix is used. } }, []); const setPrefix = (value) => { const prefix = value.trim(); const valid = /^[A-Za-z][A-Za-z0-9]*$/.test(prefix); setState((s) => ({ ...s, customPrefix: value, id: valid ? withPrefix(s.id, prefix) : s.id })); if (valid) { try { window.localStorage.setItem(PREFIX_KEY, prefix); } catch (e) { // Not saved; the prefix still applies to this visit. } } }; const customId = (current) => withPrefix(current, /^[A-Za-z][A-Za-z0-9]*$/.test(state.customPrefix.trim()) ? state.customPrefix.trim() : "CT"); const setMode = (mode) => set(mode === "custom" ? { mode, id: customId(state.id) } : { mode, tags: "", id: withPrefix(state.id, "MT") }); const reset = (base) => setState({ ...base, mode: state.mode, customPrefix: state.customPrefix, id: builtin ? base.id : base.id ? customId(base.id) : "" }); const setProduct = (value) => { const next = data.products.find((p) => p.key === value); const keepFeature = state.feature === NEW || (next && next.features.some((f) => f.key === state.feature)) || !builtin; set({ product: value, feature: keepFeature ? state.feature : "", relatedProducts: state.relatedProducts.filter((r) => r !== value) }); }; // Products show the icon the report and the test catalog use; features show theirs when they have one. const iconOf = (field, key) => field === "product" ? productIconOf(key) : field === "feature" && state.product ? { icon: featureIcon(state.product, key) } : {}; const registrySelect = (field, options, placeholder) => { const change = (value) => (field === "product" ? setProduct(value) : set({ [field]: value })); const items = options.map((o) => ({ value: o.key, label: o.name ? o.name : o.key, hint: o.name ? o.key : undefined, ...iconOf(field, o.key) })); return builtin ? ( set({ [slot]: { ...state[slot], [key]: e.target.value } })} />; })}

A new value is added to the registry in the same pull request. The files to change are listed with the code.

); const taxonomyHelp = (what, extra) => ( <>

Search the list first. {what} is a deliberate addition, because every key becomes a filter in the report. If nothing fits, choose Not in the list above, and add the entry to in the same pull request as the first test that needs it.

{extra} ); const configExample = buildConfigExample(state, data); const handParameters = (state.parameters || []).filter((p) => p.name.trim()).length - scaffoldedSettings(state, data).length; const tabs = [ ["ps1", "Test." + id + ".ps1"], ["md", "Test." + id + ".md"], ["cmd", "New-MtTest"], ]; return (
Step {stepIndex + 1} of {STEPS.length} {stepIndex < STEPS.length - 1 ? ( ) : ( {errors.length ? "Fix what is listed with the code, then copy it." : "Done. Copy the code."} )}
{railHost && createPortal(, railHost)}
setHelpId(null)} openGuide={openGuide} />
); }