Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
648 changes: 228 additions & 420 deletions fedramp-consolidated-rules.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions schemas/fedramp-consolidated-rules.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@
"tag": { "type": "string" },
"alts": { "type": "array", "items": { "type": "string" } },
"do_not_link": { "type": "boolean" },
"ignore_in_terms": { "type": "boolean" },
"reference": { "type": "string" },
"reference_url": { "type": "string", "format": "uri" },
"referenceurl": { "type": "string", "format": "uri" },
Expand Down
5 changes: 5 additions & 0 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ normalizations. Focused aliases select individual scopes:
| `bun run fix:display-names` | Repairs inline rule IDs and their parenthesized display names. |
| `bun run fix:subset-affects` | Aligns FRR subset applicability `affects` with its requirements. |

Term synchronization excludes definitions with `ignore_in_terms: true`,
including their aliases, from FRR and KSI `terms` arrays. The term check reports
existing entries for these definitions, and the fixer removes them. An absent
or `false` flag keeps normal matching behavior.

Pass flags after `--`:

| Flag | Behavior |
Expand Down
4 changes: 4 additions & 0 deletions tools/src/terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ function buildTermLookup(document: RulesDocument): Map<string, string> {
const lookup = new Map<string, string>();

for (const { definition } of getDefinitionEntries(document)) {
if (definition.ignore_in_terms === true) {
continue;
}

lookup.set(definition.term.toLowerCase(), definition.term);

for (const alt of definition.alts ?? []) {
Expand Down
1 change: 1 addition & 0 deletions tools/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface UpdatedEntry {
export interface DefinitionEntry {
term: string;
alts?: string[];
ignore_in_terms?: boolean;
tag?: string;
definition: string;
note?: string;
Expand Down
9 changes: 8 additions & 1 deletion tools/tests/fix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ test("auto-fix applies ID, term, related, subset-affects, and property-order fix
properties: {
term: { type: "string" },
alts: { type: "array" },
ignore_in_terms: { type: "boolean" },
definition: { type: "string" },
updated: { type: "array" },
},
Expand Down Expand Up @@ -152,6 +153,12 @@ test("auto-fix applies ID, term, related, subset-affects, and property-order fix
definition: "Test definition",
updated: [],
},
"FRD-MST": {
term: "MUST",
ignore_in_terms: true,
definition: "Test definition",
updated: [],
},
},
},
},
Expand Down Expand Up @@ -181,7 +188,7 @@ test("auto-fix applies ID, term, related, subset-affects, and property-order fix
related: ["MAS-CSO-OLD"],
affects: ["Providers"],
name: "Test requirement",
terms: [],
terms: ["MUST"],
updated: [],
},
"MAS-CSO-REF": {
Expand Down
132 changes: 132 additions & 0 deletions tools/tests/terms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,141 @@ import {
collectDefinitionTermTitleChanges,
collectTermSyncChanges,
toDefaultTitleCase,
type TermSyncChange,
} from "../src/terms";
import type { RulesDocument } from "../src/types";

function createTermSyncDocument(ignoreInTerms?: boolean): RulesDocument {
return {
info: {
title: "Test",
description: "Test",
version: "1.0.0",
last_updated: "2026-09-13",
},
FRD: {
info: {},
data: {
all: {
"FRD-MST": {
term: "MUST",
alts: ["required"],
...(ignoreInTerms === undefined
? {}
: { ignore_in_terms: ignoreInTerms }),
definition: "Test definition",
},
"FRD-AGY": {
term: "Agency",
definition: "Test definition",
},
"FRD-PVD": {
term: "Provider",
alts: ["providers"],
ignore_in_terms: false,
definition: "Test definition",
},
},
},
},
FRR: {
MAS: {
info: {},
data: {
all: {
CSO: {
"MAS-CSO-TST": {
name: "Test requirement",
affects: ["Providers"],
statement: "Providers MUST notify an agency.",
force: "MUST",
terms: [],
},
},
},
},
},
},
KSI: {
IAM: {
id: "KSI-IAM",
name: "Test theme",
web_name: "Test theme",
short_name: "Test",
theme: "Test",
indicators: {
"KSI-IAM-TST": {
name: "Test indicator",
varies_by_class: {
b: { statement: "Providers are required to notify an agency." },
c: { statement: "Providers are required to notify an agency." },
},
terms: [],
},
},
},
},
};
}

test.each([
["absent", undefined],
["false", false],
["true", true],
] as const)("term sync honors ignore_in_terms=%s for terms and aliases", (_, ignoreInTerms) => {
const document = createTermSyncDocument(ignoreInTerms);
const expectedTerms = ignoreInTerms === true
? ["Agency", "Provider"]
: ["Agency", "MUST", "Provider"];
const expectedChanges: TermSyncChange[] = [
{
id: "MAS-CSO-TST",
location: "FRR.MAS.data.all.CSO.MAS-CSO-TST",
kind: "requirement",
currentTerms: [],
nextTerms: expectedTerms,
},
{
id: "KSI-IAM-TST",
location: "KSI.IAM.indicators.KSI-IAM-TST",
kind: "indicator",
currentTerms: [],
nextTerms: expectedTerms,
},
];
const original = structuredClone(document);

expect(collectTermSyncChanges(document)).toEqual(expectedChanges);
expect(document).toEqual(original);
expect(applyTermSync(document)).toEqual(expectedChanges);
expect(collectTermSyncChanges(document)).toEqual([]);
expect(applyTermSync(document)).toEqual([]);
});

test.each(["all", "20x", "rev5"])("term sync removes ignored definitions from %s even when their text still matches", (scope) => {
const document = createTermSyncDocument(true);
const definitions = document.FRD.data.all!;
document.FRD.data = { [scope]: definitions };
const requirement = document.FRR.MAS!.data.all!.CSO!["MAS-CSO-TST"]!;
const indicator = Object.values(document.KSI.IAM!.indicators)[0]!;
requirement.terms = ["Agency", "MUST", "Provider"];
indicator.varies_by_class = {
b: { statement: "This behavior is required." },
c: { statement: "This behavior is required." },
};
indicator.terms = ["MUST"];

const changes = collectTermSyncChanges(document);

expect(changes).toHaveLength(2);
expect(changes[0]!.nextTerms).toEqual(["Agency", "Provider"]);
expect(changes[1]!.nextTerms).toEqual([]);
expect(applyTermSync(document)).toEqual(changes);
expect(requirement.terms).toEqual(["Agency", "Provider"]);
expect(indicator.terms).toEqual([]);
expect(collectTermSyncChanges(document)).toEqual([]);
});

test("all FRD terms use the default title casing", () => {
const changes = collectDefinitionTermTitleChanges(loadRulesDocument());
expect(changes).toEqual([]);
Expand Down
Loading