IF Commons GitHub

integrations/pure/import-oscal-catalog

The importer of an OSCAL control catalog (commons 0019-mizan-integrations FR-005, FR-006, FR-009, FR-015): a slice of the controls of a catalog such as NIST SP 800-53, read from OSCAL's JSON, written as a generated TypeScript module of a typed code list whose keys are the control identifiers, so that a requirement cites ac-2 and the compiler knows it is a control of the pinned catalog.

The catalog's JSON is read once, here, into typed records (decodeCatalog); a control is its identifier, title, group and, for an enhancement, the control it enhances. The slice names control identifiers (ac-2, ac-2.1), never the whole catalog. The checks are those of the vocabulary importer: a pin that differs, no license and no right to copy are refused, a control the catalog lacks is named, and the same input gives the same text. The module carries the catalog's title, version and OSCAL version in its header.

import { importOscalCatalog } from "./import-oscal-catalog.ts";
// importOscalCatalog({ standard, sourceText, slice: ["ac-2", "ac-2.1"] })

Source: commons/mizan/src/integrations/pure/import-oscal-catalog.ts

2 of 12 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

integrations.Catalogtypeno test imports it
type Catalog = {
  readonly title: string;
  readonly version: string;
  readonly oscalVersion: string;
  readonly controls: readonly Control[];
};

A catalog as the importer reads it: what its metadata says, and every control, enhancements included.

integrations.Controltypeno test imports it
type Control = { readonly id: string; readonly title: string; readonly group: string; readonly enhancementOf?: string };

A control of a catalog as the importer reads it.

integrations.decodeCatalogfunctionno test imports it
function decodeCatalog(text: string): Result<Catalog, string>

The text of an OSCAL catalog's JSON as a typed catalog, or the sentence that says what is wrong with it.

integrations.importOscalCatalogfunctionno test imports it
function importOscalCatalog(i: OscalImportInput): Promise<Result<ImportOutput, readonly IntegrationFinding[]>>

A slice of an OSCAL catalog as a generated typed code list of controls, or what stops it.

integrations.OSCAL_GENERATORconstno test imports it
const OSCAL_GENERATOR: "commons/mizan/src/integrations/pure/import-oscal-catalog.ts"

The generator's name, as the provenance and the header of a generated module give it.

integrations.OscalImportInputtypeno test imports it
type OscalImportInput = {
  readonly standard: StandardRecord;
  /** The catalog's JSON, as the pinned bytes read as UTF-8 text. */
  readonly sourceText: string;
  /** The control identifiers to take (`ac-2`, `ac-2.1`), never the whole catalog. */
  readonly slice: readonly string[];
  /** The name the code list is exported as (`controls` by default). */
  readonly exportName?: string;
};

What an OSCAL import needs.

Catalogtypeno test imports it
type Catalog = {
  readonly title: string;
  readonly version: string;
  readonly oscalVersion: string;
  readonly controls: readonly Control[];
};

A catalog as the importer reads it: what its metadata says, and every control, enhancements included.

Controltypeno test imports it
type Control = { readonly id: string; readonly title: string; readonly group: string; readonly enhancementOf?: string };

A control of a catalog as the importer reads it.

decodeCatalogfunction
function decodeCatalog(text: string): Result<Catalog, string>

The text of an OSCAL catalog's JSON as a typed catalog, or the sentence that says what is wrong with it.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

importOscalCatalogfunction
function importOscalCatalog(i: OscalImportInput): Promise<Result<ImportOutput, readonly IntegrationFinding[]>>

A slice of an OSCAL catalog as a generated typed code list of controls, or what stops it.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

OSCAL_GENERATORconstno test imports it
const OSCAL_GENERATOR: "commons/mizan/src/integrations/pure/import-oscal-catalog.ts"

The generator's name, as the provenance and the header of a generated module give it.

OscalImportInputtypeno test imports it
type OscalImportInput = {
  readonly standard: StandardRecord;
  /** The catalog's JSON, as the pinned bytes read as UTF-8 text. */
  readonly sourceText: string;
  /** The control identifiers to take (`ac-2`, `ac-2.1`), never the whole catalog. */
  readonly slice: readonly string[];
  /** The name the code list is exported as (`controls` by default). */
  readonly exportName?: string;
};

What an OSCAL import needs.

Titles, headings, exports, tables, columns and requirements. Esc closes.