diff --git a/.cfusa-hara.json b/.cfusa-hara.json deleted file mode 100644 index 43d3837..0000000 --- a/.cfusa-hara.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "project": "c-FuSa", - "version": "0.1.0", - "created": "2026-06-09T18:34:23Z", - "standard": "ISO 26262-3:2018", - "hazards": [ - { - "id": "HAZ-001", - "item": "cfusa check / cfusa lint", - "hazardous_event": "Tool reports no violations on a file that contains real safety violations (false-negative), leading developer to believe code is safe when it is not", - "severity": 3, - "exposure": 4, - "controllability": 2, - "asil": "ASIL-C", - "safe_state": "Developer independently reviews code and uses additional static analysis tools", - "safety_goal": "cfusa shall not suppress or omit any finding for which the rule engine is configured to detect", - "ftti_ms": 0 - }, - { - "id": "HAZ-002", - "item": "cfusa check / cfusa lint", - "hazardous_event": "Tool reports excessive false-positives causing developer to disable checks or ignore findings, masking real violations", - "severity": 2, - "exposure": 4, - "controllability": 3, - "asil": "ASIL-C", - "safe_state": "Developer uses disposition system to explicitly accept findings with rationale", - "safety_goal": "cfusa shall limit false-positive rate to a level that does not cause systematic check-disabling", - "ftti_ms": 0 - }, - { - "id": "HAZ-003", - "item": "cfusa impact", - "hazardous_event": "Command injection via unsanitised --from/--to git refs passed to popen(), allowing arbitrary shell execution on developer machine", - "severity": 3, - "exposure": 2, - "controllability": 1, - "asil": "QM", - "safe_state": "validate_git_ref() whitelist prevents injection; tool exits 1 with error message", - "safety_goal": "cfusa impact shall validate all git ref arguments before constructing shell commands", - "ftti_ms": 0 - }, - { - "id": "HAZ-004", - "item": "cfusa release / cfusa qualify", - "hazardous_event": "SBOM or qualification record is generated with incorrect checksums or version info, leading to incorrect evidence being submitted to a safety case", - "severity": 2, - "exposure": 3, - "controllability": 2, - "asil": "ASIL-A", - "safe_state": "Reviewer independently verifies SBOM checksums against source", - "safety_goal": "cfusa release shall compute SHA-256 checksums deterministically and embed correct project/version from .cfusa.json", - "ftti_ms": 0 - }, - { - "id": "HAZ-005", - "item": "cfusa hara asil", - "hazardous_event": "Incorrect ASIL determination output (wrong table lookup) causes developer to under-design safety measures for a hazardous item", - "severity": 3, - "exposure": 3, - "controllability": 2, - "asil": "ASIL-B", - "safe_state": "Developer cross-checks ASIL with ISO 26262-3:2018 Table 4 directly", - "safety_goal": "cfusa hara asil shall implement ISO 26262-3:2018 Table 4 correctly for all S/E/C combinations", - "ftti_ms": 0 - } - ] -} diff --git a/.fusa-hara.json b/.fusa-hara.json new file mode 100644 index 0000000..6a261c2 --- /dev/null +++ b/.fusa-hara.json @@ -0,0 +1,132 @@ +{ + "project": "c-FuSa", + "standard": "iso26262", + "createdAt": "2026-06-09T18:34:23Z", + "operationalSituations": [ + { + "id": "OS-001", + "description": "Developer runs cfusa check/lint in CI or as a pre-commit gate as the sole safety-relevant static analysis step for a change" + }, + { + "id": "OS-002", + "description": "Developer runs cfusa impact locally against a git repository, passing --from/--to ref arguments that may originate from an untrusted source (e.g. a CI job templated from a pull request)" + }, + { + "id": "OS-003", + "description": "cfusa release/qualify artifacts (SBOM, provenance, qualification record) are generated and submitted as evidence into an external safety case or certification package" + }, + { + "id": "OS-004", + "description": "Developer manually computes an ASIL rating via cfusa hara asil from S/E/C parameters during hazard analysis" + } + ], + "hazards": [ + { + "id": "H-001", + "description": "Tool reports no violations on a file that contains real safety violations (false-negative), leading the developer to believe code is safe when it is not", + "source": "c-FuSa self-analysis", + "situations": ["OS-001"], + "risk": { + "severity": "S3", + "exposure": "E4", + "controllability": "C2", + "asil": "ASIL-D" + }, + "safetyGoals": ["SG-001"] + }, + { + "id": "H-002", + "description": "Tool reports excessive false-positives, causing the developer to disable checks or ignore findings, masking real violations", + "source": "c-FuSa self-analysis", + "situations": ["OS-001"], + "risk": { + "severity": "S2", + "exposure": "E4", + "controllability": "C3", + "asil": "ASIL-D" + }, + "safetyGoals": ["SG-002"] + }, + { + "id": "H-003", + "description": "Command injection via unsanitised --from/--to git refs passed to popen(), allowing arbitrary shell execution on the developer's machine", + "source": "c-FuSa self-analysis / cyber review", + "situations": ["OS-002"], + "risk": { + "severity": "S3", + "exposure": "E2", + "controllability": "C1", + "asil": "ASIL-B" + }, + "safetyGoals": ["SG-003"] + }, + { + "id": "H-004", + "description": "SBOM or qualification record is generated with incorrect checksums or version info, leading to incorrect evidence being submitted to a safety case", + "source": "c-FuSa self-analysis", + "situations": ["OS-003"], + "risk": { + "severity": "S2", + "exposure": "E3", + "controllability": "C2", + "asil": "ASIL-B" + }, + "safetyGoals": ["SG-004"] + }, + { + "id": "H-005", + "description": "Incorrect ASIL determination output (wrong table lookup) causes the developer to under-design safety measures for a hazardous item", + "source": "c-FuSa self-analysis", + "situations": ["OS-004"], + "risk": { + "severity": "S3", + "exposure": "E3", + "controllability": "C2", + "asil": "ASIL-D" + }, + "safetyGoals": ["SG-005"] + } + ], + "safetyGoals": [ + { + "id": "SG-001", + "description": "cfusa shall not suppress or omit any finding for which the rule engine is configured to detect", + "hazards": ["H-001"], + "asil": "ASIL-D", + "safeState": "Developer independently reviews code and uses additional static analysis tools", + "fssrRefs": ["REQ-FSR-CHECK001"] + }, + { + "id": "SG-002", + "description": "cfusa shall limit its false-positive rate to a level that does not cause systematic check-disabling", + "hazards": ["H-002"], + "asil": "ASIL-D", + "safeState": "Developer uses the disposition system to explicitly accept findings with rationale", + "fssrRefs": ["REQ-FSR-CHECK002"] + }, + { + "id": "SG-003", + "description": "cfusa impact shall validate all git ref arguments before constructing shell commands", + "hazards": ["H-003"], + "asil": "ASIL-B", + "safeState": "validate_git_ref() whitelist prevents injection; the tool exits 1 with an error message", + "fssrRefs": ["REQ-IMP001"] + }, + { + "id": "SG-004", + "description": "cfusa release/qualify shall compute SHA-256 checksums deterministically and embed the correct project/version from .fusa.json", + "hazards": ["H-004"], + "asil": "ASIL-B", + "safeState": "Reviewer independently verifies SBOM checksums against source", + "fssrRefs": ["REQ-REL002", "REQ-UTIL015"] + }, + { + "id": "SG-005", + "description": "cfusa hara asil shall implement ISO 26262-3:2018 Table 4 correctly for all S/E/C combinations", + "hazards": ["H-005"], + "asil": "ASIL-D", + "safeState": "Developer cross-checks the ASIL result with ISO 26262-3:2018 Table 4 directly", + "fssrRefs": ["REQ-HARA009"] + } + ] +} diff --git a/.fusa-reqs.json b/.fusa-reqs.json index 52458b2..518e82c 100644 --- a/.fusa-reqs.json +++ b/.fusa-reqs.json @@ -326,6 +326,36 @@ {"id":"REQ-VULN005","title":"cfusa vuln --format json output contains the detected findings","standard":"c-FuSa CLI","level":"ASIL-A"}, {"id":"REQ-VULN006","title":"cfusa vuln --output-dir writes the vulnerability report to the given directory","standard":"c-FuSa CLI","level":"ASIL-A"}, {"id":"REQ-VULN007","title":"cfusa vuln --format text writes findings to an output file","standard":"c-FuSa CLI","level":"ASIL-A"}, - {"id":"REQ-VULN008","title":"cfusa vuln word-boundary matching avoids false positives on substrings of vulnerable function names","standard":"c-FuSa CLI","level":"ASIL-A"} + {"id":"REQ-VULN008","title":"cfusa vuln word-boundary matching avoids false positives on substrings of vulnerable function names","standard":"c-FuSa CLI","level":"ASIL-A"}, + + {"id":"REQ-QB001","title":"qualitybar FUSA-STUB001 deny-list scan detects bracket placeholders and instructional substrings","standard":"x-FuSa spec §1.6.1","level":"ASIL-D"}, + {"id":"REQ-QB002","title":"qualitybar FUSA-STUB002 distinct-value-ratio check flags <0.1 ratio across >=10 entries","standard":"x-FuSa spec §1.6.1","level":"ASIL-B"}, + {"id":"REQ-QB003","title":"qualitybar content hash is deterministic and sha256:-prefixed","standard":"x-FuSa spec §1.6.2","level":"ASIL-B"}, + {"id":"REQ-QB004","title":"qualitybar attestation validity requires independent reviewer and a non-stale content hash","standard":"x-FuSa spec §1.6.2","level":"ASIL-B"}, + {"id":"REQ-QB005","title":"qualitybar attestation object extraction round-trips status/author/reviewer/reviewedAt/contentHash","standard":"x-FuSa spec §1.6.2","level":"ASIL-B"}, + {"id":"REQ-QB006","title":"qualitybar rule-level disposition lookup suppresses FUSA-STUB001 via .fusa-dispositions.json","standard":"x-FuSa spec §1.6.1","level":"ASIL-B"}, + + {"id":"REQ-HARA-SCHEMA001","title":"cfusa hara init scaffolds empty operationalSituations/hazards/safetyGoals collections, never dummy rows","standard":"x-FuSa spec §1.2.5","level":"ASIL-D"}, + {"id":"REQ-HARA-SCHEMA002","title":"cfusa hara show --format json reports completeness including safetyGoalsWithFssrRefs and danglingReferences","standard":"x-FuSa spec §1.2.5","level":"ASIL-B"}, + {"id":"REQ-HARA-SCHEMA003","title":"cfusa hara show detects and gates on FUSA-STUB001 placeholder text in hazard/safety-goal descriptions","standard":"x-FuSa spec §1.6.1","level":"ASIL-D"}, + + {"id":"REQ-FMEA-SCHEMA001","title":"cfusa fmea --format json emits ratingScale, failureMode/effect/cause, actionPriority, and summary.componentsInProject/coveragePct","standard":"x-FuSa spec §9.2","level":"ASIL-B"}, + {"id":"REQ-FMEA-SCHEMA002","title":"cfusa fmea failureMode/effect/cause text varies per function rather than one fixed string for every entry","standard":"x-FuSa spec §1.6.1","level":"ASIL-B"}, + {"id":"REQ-FMEA-COV001","title":"cfusa fmea --min-coverage N exits 1 when summary.coveragePct < N (N=0 disables the gate)","standard":"x-FuSa spec §9.2","level":"ASIL-B"}, + {"id":"REQ-FMEA-ATTEST001","title":"cfusa fmea --attest stamps a valid §1.6.2 attestation that suppresses FUSA-STUB002","standard":"x-FuSa spec §1.6.2","level":"ASIL-B"}, + + {"id":"REQ-TARA-SCHEMA001","title":"cfusa tara --format json emits threats[].impact as an SFOP object and summary.assetInventoryMethod","standard":"x-FuSa spec §9.2","level":"ASIL-B"}, + {"id":"REQ-TARA006","title":"cfusa tara summary rolls up assetsAnalyzed/assetsInProject/coveragePct/assetInventoryMethod","standard":"ISO 21434","level":"ASIL-B"}, + + {"id":"REQ-SC002","title":"cfusa safety-case --format json emits nodes[]/edges[]/completeness using the six GSN node types","standard":"x-FuSa spec §9.2","level":"ASIL-B"}, + {"id":"REQ-SC003","title":"cfusa safety-case solution nodes cite evidence only for files that actually exist in the project","standard":"x-FuSa spec §9.2","level":"ASIL-B"}, + {"id":"REQ-SC-SCHEMA001","title":"cfusa safety-case JSON node/edge types conform to the GSN Community Standard v3 vocabulary","standard":"x-FuSa spec §9.2","level":"ASIL-B"}, + + {"id":"REQ-SAS-SCHEMA001","title":"cfusa sas --format json emits checklist[]/summary and always writes the sas.md companion","standard":"x-FuSa spec §9.3","level":"ASIL-A"}, + + {"id":"REQ-SCI-SCHEMA001","title":"cfusa sci --format json emits artifacts[].hash as sha256:-prefixed per x-FuSa spec §2.7","standard":"x-FuSa spec §2.7","level":"ASIL-A"}, + + {"id":"REQ-FSR-CHECK001","title":"cfusa check/lint shall not suppress or omit any finding for which the rule engine is configured to detect (functional safety requirement decomposing .fusa-hara.json SG-001)","standard":"ISO 26262-3","level":"ASIL-C"}, + {"id":"REQ-FSR-CHECK002","title":"cfusa check shall keep its false-positive rate low enough, via the disposition system, that it does not cause systematic check-disabling (functional safety requirement decomposing .fusa-hara.json SG-002)","standard":"ISO 26262-3","level":"ASIL-C"} ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b00e11..8033b0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,77 @@ and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0. ## [Unreleased] +## v0.5.46 — 2026-07-28 + +x-FuSa spec v1.13.0/v1.14.0 conformance sprint (issue #71): `hara`/`fmea`/ +`tara`/`safety-case`/`sas`/`sci` schemas, the §1.6 content-quality baseline +(FUSA-STUB001/002 detection + §1.6.2 attestation), and `fmea`/`tara` +coverage metrics. + ### Added -- `docker-publish.yml` now notifies `SoundMatt/FuSaOps` via `repository_dispatch` - (`xfusa-released`) after a successful image push, so FuSaOps rebuilds its - bundled image promptly instead of waiting for its weekly cron. Requires a - `FUSAOPS_DISPATCH_TOKEN` secret in this repo; falls back silently - (`continue-on-error`) to the weekly rebuild if it's not set. +- **`.fusa-hara.json` three-collection schema (§1.2.5).** `operationalSituations[]`/ + `hazards[]`/`safetyGoals[]` replace the old flat `hazards[]` shape (each with a + singular `safety_goal` string). `safetyGoals[].fssrRefs` is now **MUST, ≥1 + entry**, cross-checked against `.fusa-reqs.json`. `hara init` scaffolds + empty collections (never dummy rows); `hara show`/`--format json` add a + `completeness` block (`safetyGoalsWithFssrRefs`, `danglingReferences`) and + the §1.6.1 content-quality scan. +- **`fmea`/`tara`/`safety-case` real schemas (§9.2).** `fmea.json` gets + `ratingScale`, `failureMode`/`effect`/`cause` text that's heuristically + templated per function (name/file/category) instead of static/blank + fields, `actionPriority`, and `summary.componentsInProject`/`coveragePct`. + `tara.json` gets an SFOP `impact` object (safety/financial/operational/ + privacy) per ISO 21434 Clause 15.7 instead of one generic severity, plus + `summary.assetsInProject`/`coveragePct`/`assetInventoryMethod`. `tara`'s + assets/threats are now discovered by scanning for functions that look + like they handle network/file/auth/memory input, instead of a static + placeholder-filled template. `safety-case --format json` is new: + `nodes[]`/`edges[]`/`completeness` using the six real GSN node types + (goal/strategy/solution/context/assumption/justification); `solution` + nodes only cite `evidence` for a file that actually exists. +- **`sas`/`sci` real schemas (§9.3).** `sas --format json` emits + `checklist[]`/`summary` (`present` reflects a real evidence-file check, + not a hardcoded `false`) and always also writes the `sas.md` companion. + `sci --format json` renames `files`→`artifacts` and `sha256`→`hash` + (`sha256:`-prefixed, per §2.7 — a field *named* `hash` carries a + algorithm-prefixed value, unlike a field named for its algorithm). +- **`--min-coverage N` on `fmea`/`tara`** (mirrors `trace --func-coverage`): + exits 1 when `summary.coveragePct < N`; `N=0` disables the gate. + `componentsInProject`/`assetsInProject` now exclude test files + (`test_*.c`/`*_test.c`), matching `trace --func-coverage`'s own + denominator, so the FMEA/TARA aren't diluted by test scaffolding. +- **§1.6.1 content-quality baseline**: a new `qualitybar` module implements + Rule A / `FUSA-STUB001` (always `ERROR`, a placeholder/template-text + deny-list scan; suppressible only via `.fusa-dispositions.json`, never + attestation) and Rule B / `FUSA-STUB002` (`WARNING` by default; a + distinct-value-ratio check across ≥10 entries), wired into + `hara`/`fmea`/`tara`/`safety-case`/`sas`. +- **§1.6.2 attestation**: any of the above commands accept + `--strict`/`--require-attestation` (escalates an unsuppressed Rule B to + exit 1) and `--attest ` (stamps a `status: "reviewed"` + attestation with a canonical-content `sha256:` hash). A non-stale, + genuinely-independent attestation suppresses Rule B; a self-attestation + or one whose content hash no longer matches falls back to `"heuristic"` + (fail-safe). +- Regenerated this repo's own `.fusa-hara.json` (migrated from the retired + `.cfusa-hara.json`), `fmea.json`/`fmea.csv`, `tara.json`/`tara.md`, and + added `safety-case.json` against the new schemas — c-FuSa dogfooding its + own spec conformance work, mirroring FuSaOps' own PR #84/PR2. + +### Fixed +- **`fmea.json`/`fmea.csv` could contain invalid JSON/CSV.** The function-name + scanner's naive paren-based heuristic occasionally misdetects a quoted + string literal (e.g. a known-answer-test table entry) as a function name; + the `item`/`Function` field was written unescaped, so an embedded `"` + broke both the JSON and CSV output. Every free-text field is now escaped + for its target format (JSON string-escaping; CSV quote-doubling per RFC + 4180). +- `cmd_safety_rules.c`'s `HARA002`/`HARA003`/`HARA004` engine rules read the + old flat `.fusa-hara.json` shape; updated to the new nested + `risk.severity`/`.exposure`/`.controllability` and `safetyGoals[]` + reference-array fields, and scoped to the `hazards`/`safetyGoals` arrays + specifically so they don't cross-match a same-named nested key in a + sibling collection. ## v0.5.45 — 2026-07-27 diff --git a/CMakeLists.txt b/CMakeLists.txt index 04cc612..ff6bf23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) project(cfusa - VERSION 0.5.45 + VERSION 0.5.46 DESCRIPTION "C functional safety toolkit" LANGUAGES C ) @@ -37,6 +37,7 @@ add_library(cfusa_core STATIC src/config.c src/utils.c src/cfusa_runtime.c + src/qualitybar.c ) target_include_directories(cfusa_core PUBLIC include) set_target_properties(cfusa_core PROPERTIES @@ -157,6 +158,7 @@ cfusa_test(test_hlr_llr) cfusa_test(test_qualify_vv) cfusa_test(test_mcdc) cfusa_test(test_gap_coverage) +cfusa_test(test_xfusa_v114) # ---- Installation ---- include(GNUInstallDirs) diff --git a/README.md b/README.md index 468705f..2c13ea7 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ cfusa fix --dir src/ | `verify` | Collect and bundle test evidence | | `release` | SBOM (SPDX-3.0.1 JSON), SLSA v0.2 provenance, artifact manifest | | `qualify` | Tool self-test and qualification record | -| `safety-case` | GSN safety case skeleton + evidence index | +| `safety-case` | GSN safety case (`--format json` → `nodes`/`edges`/`completeness`) + evidence index | | `boundary` | Component dependency graph → `boundary.mermaid` + `boundary.dot` | | `vuln` | Known-vulnerable function pattern scan (CWE/CVE) | | `audit-pack` | Bundle all artifacts into audit package | diff --git a/cmd/cfusa/cmd_fmea.c b/cmd/cfusa/cmd_fmea.c index b764493..fbebce7 100644 --- a/cmd/cfusa/cmd_fmea.c +++ b/cmd/cfusa/cmd_fmea.c @@ -1,34 +1,48 @@ /* - * cfusa fmea — Design FMEA skeleton generator. + * cfusa fmea — Design FMEA generator (IEC 60812:2018 / AIAG-VDA FMEA + * Handbook 2019 / ISO 26262 Part 5), x-FuSa spec §9.2. * - * Scans C source for function definitions and emits a template FMEA table - * in Markdown, JSON, or CSV format (IEC 60812 / ISO 26262 Part 5). + * Scans C source for public (non-static) function definitions and emits an + * FMEA table in JSON, CSV, or Markdown. Failure mode / effect / cause text + * is heuristically templated from each function's actual name, file, and a + * keyword-based risk category — it varies per entry (x-FuSa spec §1.6 rule + * 3 / §1.6.1 rule B), rather than a single canned string repeated for every + * row, and never ships bracket/instructional placeholder text (§1.6 rule 1). */ -//cfusa:req REQ-CLI-FMEA001 REQ-FMEA001 REQ-FMEA002 +//cfusa:req REQ-CLI-FMEA001 REQ-FMEA001 REQ-FMEA002 REQ-FMEA006 REQ-FMEA007 REQ-FMEA008 #include #include #include #include #include "cfusa/config.h" +#include "cfusa/qualitybar.h" #include "cfusa/report.h" #include "cfusa/utils.h" #include "cfusa/version.h" -#define MAX_FUNS 1024 +#define MAX_FUNS 1024 +#define FMEA_RATING_SCALE "cfusa-heuristic-1-10" typedef struct { char name[128]; char file[256]; int line; - char sig[256]; - int severity; /* 1–10, inferred from function profile */ + int severity; /* 1-10, inferred from a keyword heuristic */ + int occurrence; /* 1-10 */ + int detection; /* 1-10 */ + const char *category; /* "safety-critical" | "monitoring/control" | "general" */ + const char *action_priority; /* "high" | "medium" | "low" */ } fn_entry_t; static fn_entry_t g_fns[MAX_FUNS]; static int g_fn_count = 0; +static int g_total_found = 0; /* uncapped — x-FuSa spec §9.2 componentsInProject */ -/* Heuristic: elevated severity if name contains safety-critical keywords */ -static int infer_severity(const char *name) +/* Heuristic: elevated severity if name contains safety-critical keywords. + * Mirrors the same public-function detection x-FuSa spec §5/§1.4.1 + * `trace --func-coverage` uses (non-static functions with a body), so + * componentsInProject/componentsAnalyzed share one methodology. */ +static void infer_profile(const char *name, fn_entry_t *fn) { static const char * const hi[] = { "brake","steer","throttle","safety","shutdown","critical", @@ -38,23 +52,58 @@ static int infer_severity(const char *name) "init","config","check","validate","monitor","log", NULL }; for (int i = 0; hi[i]; i++) - if (strstr(name, hi[i])) return 9; + if (strstr(name, hi[i])) { + fn->severity = 9; fn->occurrence = 4; fn->detection = 6; + fn->category = "safety-critical"; fn->action_priority = "high"; + return; + } for (int i = 0; med[i]; i++) - if (strstr(name, med[i])) return 5; - return 3; + if (strstr(name, med[i])) { + fn->severity = 5; fn->occurrence = 3; fn->detection = 4; + fn->category = "monitoring/control"; fn->action_priority = "medium"; + return; + } + fn->severity = 3; fn->occurrence = 2; fn->detection = 3; + fn->category = "general"; fn->action_priority = "low"; } -static const char *sev_string(int s) +/* ---- qualitative-field rendering (varies per entry — x-FuSa spec §1.6.1 rule B) ---- */ + +static void render_failure_mode(char *out, size_t sz, const fn_entry_t *fn) { - if (s >= 8) return "High"; - if (s >= 5) return "Medium"; - return "Low"; + snprintf(out, sz, "%s (%s function) does not perform its intended action", fn->name, fn->category); +} + +static void render_effect(char *out, size_t sz, const fn_entry_t *fn) +{ + snprintf(out, sz, "Failure of %s could propagate undetected to callers in %s", + fn->name, cfusa_basename(fn->file)); +} + +/* RFC 4180 CSV escaping: a quoted field's embedded '"' MUST be doubled. */ +static void csv_escape(const char *in, char *out, size_t sz) +{ + size_t k = 0; + while (*in && k + 2 < sz) { + if (*in == '"') out[k++] = '"'; + out[k++] = *in++; + } + out[k] = '\0'; +} + +static void render_cause(char *out, size_t sz, const fn_entry_t *fn) +{ + if (strcmp(fn->category, "safety-critical") == 0) + snprintf(out, sz, "Unhandled fault or invalid input condition within %s", fn->name); + else if (strcmp(fn->category, "monitoring/control") == 0) + snprintf(out, sz, "Configuration or state inconsistency affecting %s", fn->name); + else + snprintf(out, sz, "Logic error or untested edge case in %s", fn->name); } static void fmea_line(const char *path, int lineno, const char *line, void *vctx) { (void)vctx; - if (g_fn_count >= MAX_FUNS) return; const char *p = line; while (*p == ' ' || *p == '\t') p++; if (!*p || *p == '/' || *p == '#' || *p == '*' || *p == '}') return; @@ -80,55 +129,207 @@ static void fmea_line(const char *path, int lineno, const char *line, void *vctx while (*fn_name == '*') fn_name++; if (!*fn_name || strlen(fn_name) < 2) return; + /* Counted for componentsInProject regardless of the per-run table cap, + * so coveragePct honestly reflects truncation on very large projects + * instead of silently reporting 100% either way. */ + g_total_found++; + if (g_fn_count >= MAX_FUNS) return; + strncpy(g_fns[g_fn_count].name, fn_name, 127); strncpy(g_fns[g_fn_count].file, path, 255); - strncpy(g_fns[g_fn_count].sig, p, 255); g_fns[g_fn_count].line = lineno; - g_fns[g_fn_count].severity = infer_severity(fn_name); + infer_profile(fn_name, &g_fns[g_fn_count]); g_fn_count++; } +/* Mirrors cmd_trace.c's is_test_file(): a design FMEA is over the + * project's own safety-relevant public functions, not its test scaffolding + * — same exclusion used by trace --func-coverage's componentsInProject- + * equivalent denominator (x-FuSa spec §1.4.1/§5), which this command's + * summary.componentsInProject is intentionally aligned with. */ +static int fmea_is_test_file(const char *path) +{ + const char *b = strrchr(path, '/'); + b = b ? b + 1 : path; + if (strncmp(b, "test_", 5) == 0) return 1; + size_t n = strlen(b); + return n > 7 && strcmp(b + n - 7, "_test.c") == 0; +} + static int fmea_file(const char *path, void *v) -{ cfusa_scan_lines(path, fmea_line, v); return 0; } +{ + if (fmea_is_test_file(path)) return 0; + cfusa_scan_lines(path, fmea_line, v); + return 0; +} + +/* ---- canonical content hash (x-FuSa spec §1.6.2) ---- */ + +static size_t fmea_canonical_content(char *buf, size_t bufsz) +{ + size_t off = 0; + off += (size_t)snprintf(buf + off, bufsz - off, "{\"entries\":["); + for (int i = 0; i < g_fn_count; i++) { + char fm[192], ef[224], ca[192], esc_item[192]; + char esc_fm[256], esc_ef[288], esc_ca[256]; + render_failure_mode(fm, sizeof(fm), &g_fns[i]); + render_effect(ef, sizeof(ef), &g_fns[i]); + render_cause(ca, sizeof(ca), &g_fns[i]); + cfusa_str_escape_json(g_fns[i].name, esc_item, sizeof(esc_item)); + cfusa_str_escape_json(fm, esc_fm, sizeof(esc_fm)); + cfusa_str_escape_json(ef, esc_ef, sizeof(esc_ef)); + cfusa_str_escape_json(ca, esc_ca, sizeof(esc_ca)); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + "%s{\"actionPriority\":\"%s\",\"cause\":\"%s\",\"detection\":%d," + "\"effect\":\"%s\",\"failureMode\":\"%s\",\"file\":\"%s\",\"id\":\"FM-%03d\"," + "\"item\":\"%s\",\"occurrence\":%d,\"severity\":%d}", + i ? "," : "", g_fns[i].action_priority, esc_ca, g_fns[i].detection, esc_ef, esc_fm, + cfusa_basename(g_fns[i].file), i + 1, esc_item, g_fns[i].occurrence, + g_fns[i].severity); + } + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, "]}"); + return off; +} + +/* ---- quality-bar scan + attestation (x-FuSa spec §1.6.1/§1.6.2) ---- */ + +static const char *g_qb_modes[MAX_FUNS]; +static char g_qb_mode_bufs[MAX_FUNS][192]; +static char g_canonical_buf[262144]; + +static int run_quality_bar(const char *dir, const char *fresh_hash, + cfusa_attestation_t *existing, int require_attestation) +{ + for (int i = 0; i < g_fn_count; i++) { + render_failure_mode(g_qb_mode_bufs[i], sizeof(g_qb_mode_bufs[i]), &g_fns[i]); + g_qb_modes[i] = g_qb_mode_bufs[i]; + } + const char **modes = g_qb_modes; + + int rule_a_hits = 0; + for (int i = 0; i < g_fn_count; i++) + if (cfusa_qb_is_stub_text(modes[i])) rule_a_hits++; + + int rule_a_disposed = rule_a_hits > 0 && cfusa_qb_rule_disposed(dir, CFUSA_QB_RULE_A); + if (rule_a_hits > 0) + fprintf(stderr, "cfusa fmea: %s: %d entr%s with placeholder-looking text%s\n", + CFUSA_QB_RULE_A, rule_a_hits, rule_a_hits == 1 ? "y" : "ies", + rule_a_disposed ? " (disposed)" : ""); + + int rule_b = cfusa_qb_rule_b_flagged(modes, g_fn_count); + int reviewed = 0; + if (rule_b) { + reviewed = cfusa_qb_attestation_valid(existing, fresh_hash); + fprintf(stderr, "cfusa fmea: %s: failureMode text shows low distinct-value ratio " + "across >=10 entries%s\n", CFUSA_QB_RULE_B, + reviewed ? " (suppressed by a valid attestation)" : ""); + } + + if (rule_a_hits > 0 && !rule_a_disposed) return 1; + if (require_attestation && rule_b && !reviewed) return 1; + return 0; +} + +/* ---- rendering ---- */ + +static void write_entry_json(FILE *f, const fn_entry_t *fn, int idx, int last, int with_cyber) +{ + char fm[192], ef[224], ca[192]; + render_failure_mode(fm, sizeof(fm), fn); + render_effect(ef, sizeof(ef), fn); + render_cause(ca, sizeof(ca), fn); + char esc_fm[256], esc_ef[288], esc_ca[256], esc_item[192]; + cfusa_str_escape_json(fm, esc_fm, sizeof(esc_fm)); + cfusa_str_escape_json(ef, esc_ef, sizeof(esc_ef)); + cfusa_str_escape_json(ca, esc_ca, sizeof(esc_ca)); + /* x-FuSa spec §1.6 rule 2 (structural validity): the scanner's naive + * paren-based heuristic occasionally misdetects a quoted string literal + * as a function name (e.g. a known-answer-test table entry) — escape + * `item` like every other free-text field rather than assume it's + * always a clean identifier. */ + cfusa_str_escape_json(fn->name, esc_item, sizeof(esc_item)); + fprintf(f, + " {\n" + " \"id\": \"FM-%03d\",\n" + " \"item\": \"%s\",\n" + " \"file\": \"%s\",\n" + " \"line\": %d,\n" + " \"failureMode\": \"%s\",\n" + " \"effect\": \"%s\",\n" + " \"cause\": \"%s\",\n" + " \"severity\": %d,\n" + " \"occurrence\": %d,\n" + " \"detection\": %d,\n" + " \"actionPriority\": \"%s\",\n" + " \"mitigations\": [],\n" + " \"requirementIds\": []%s\n" + " }%s\n", + idx + 1, esc_item, cfusa_basename(fn->file), fn->line, + esc_fm, esc_ef, esc_ca, fn->severity, fn->occurrence, fn->detection, + fn->action_priority, + with_cyber ? ",\n \"cyberFailureMode\": \"\"" : "", + last ? "" : ","); +} int cmd_fmea(int argc, char **argv) { const char *dir = "."; const char *out_dir = NULL; /* --output-dir (go-FuSa style) */ const char *fmt_s = NULL; /* NULL → both json+csv; "md"/"json"/"csv" → single */ + const char *attest = NULL; /* --attest convenience flag */ int with_cyber = 0; + int strict = 0; + int require_attestation = 0; + int min_coverage = 0; static const struct option lo[] = { - {"dir", required_argument, NULL, 'd'}, - {"output-dir", required_argument, NULL, 'D'}, - {"format", required_argument, NULL, 'f'}, - {"cyber", no_argument, NULL, 'c'}, - {"help", no_argument, NULL, 'h'}, + {"dir", required_argument, NULL, 'd'}, + {"output-dir", required_argument, NULL, 'D'}, + {"format", required_argument, NULL, 'f'}, + {"cyber", no_argument, NULL, 'c'}, + {"strict", no_argument, NULL, 'S'}, + {"require-attestation",no_argument, NULL, 'A'}, + {"attest", required_argument, NULL, 'T'}, + {"min-coverage", required_argument, NULL, 'm'}, + {"help", no_argument, NULL, 'h'}, {NULL,0,NULL,0} }; int ch; optind = 1; - while ((ch = getopt_long(argc, argv, "d:D:f:ch", lo, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, "d:D:f:cSAT:m:h", lo, NULL)) != -1) { switch (ch) { case 'd': dir = optarg; break; case 'D': out_dir = optarg; break; case 'f': fmt_s = optarg; break; case 'c': with_cyber = 1; break; + case 'S': strict = 1; break; + case 'A': require_attestation = 1; break; + case 'T': attest = optarg; break; + case 'm': min_coverage = atoi(optarg); break; case 'h': printf("Usage: cfusa fmea [--dir ] [--output-dir ]\n" - " [--format md|json|csv] [--cyber]\n\n" - "Generates a design FMEA skeleton from function signatures.\n" - "Default: generates both fmea.json and fmea.csv (IEC 60812 / ISO 26262-5).\n" - "--format md generates fmea.md instead.\n" - "--cyber enriches entries with cybersecurity failure modes.\n"); + " [--format md|json|csv] [--cyber]\n" + " [--strict] [--require-attestation] [--attest ]\n" + " [--min-coverage N]\n\n" + "Generates a design FMEA from public function signatures\n" + "(IEC 60812 / ISO 26262-5 / AIAG-VDA FMEA Handbook).\n" + "Default: generates both fmea.json and fmea.csv.\n" + "--format md generates fmea.md instead.\n" + "--cyber enriches entries with cybersecurity failure modes.\n" + "--strict implies --require-attestation.\n" + "--require-attestation escalates an unsuppressed FUSA-STUB002 to exit 1.\n" + "--attest stamps a §1.6.2 attestation (independent reviewer name).\n" + "--min-coverage N exit 1 when componentsInProject coverage < N%% (0 disables).\n"); return 0; default: return 2; } } + if (strict) require_attestation = 1; cfusa_config_t cfg; cfusa_config_load(dir, &cfg); g_fn_count = 0; + g_total_found = 0; static const char * const exts[] = {".c"}; cfusa_walk_sources(dir, exts, 1, fmea_file, NULL); @@ -136,10 +337,67 @@ int cmd_fmea(int argc, char **argv) const char *base = out_dir ? out_dir : dir; char ts[32]; cfusa_timestamp_now(ts); + int coverage_pct = (g_total_found == 0) ? 100 : (g_fn_count * 100 / g_total_found); + int high = 0; + for (int i = 0; i < g_fn_count; i++) + if (strcmp(g_fns[i].action_priority, "high") == 0) high++; + + /* Read back a prior fmea.json's attestation (if any) so a genuine, + * non-stale, independent review carries forward across regenerations + * (x-FuSa spec §1.6.2). */ + char existing_path[512]; + cfusa_path_join(existing_path, sizeof(existing_path), base, "fmea.json"); + size_t existing_len = 0; + char *existing_json = cfusa_read_file(existing_path, &existing_len); + cfusa_attestation_t attestation; + if (existing_json) cfusa_qb_attestation_read(existing_json, existing_len, &attestation); + else memset(&attestation, 0, sizeof(attestation)); + free(existing_json); + + size_t clen = fmea_canonical_content(g_canonical_buf, sizeof(g_canonical_buf)); + if (clen >= sizeof(g_canonical_buf)) clen = sizeof(g_canonical_buf) - 1; + char fresh_hash[80]; + cfusa_qb_content_hash(g_canonical_buf, clen, fresh_hash); + + if (attest) { + attestation.present = 1; + strncpy(attestation.status, "reviewed", sizeof(attestation.status) - 1); + strncpy(attestation.implementation_author, "auto", sizeof(attestation.implementation_author) - 1); + strncpy(attestation.independent_reviewer, attest, sizeof(attestation.independent_reviewer) - 1); + strncpy(attestation.reviewed_at, ts, sizeof(attestation.reviewed_at) - 1); + strncpy(attestation.content_hash, fresh_hash, sizeof(attestation.content_hash) - 1); + } + + int qb_gate = run_quality_bar(dir, fresh_hash, &attestation, require_attestation); + int attestation_valid = cfusa_qb_attestation_valid(&attestation, fresh_hash); + + int cov_gate = 0; + if (min_coverage > 0 && coverage_pct < min_coverage) { + fprintf(stderr, "cfusa fmea: --min-coverage gate failed: %d%% < required %d%%\n", + coverage_pct, min_coverage); + cov_gate = 1; + } + +#define WRITE_ATTESTATION(fp) do { \ + if (attestation_valid) { \ + fprintf((fp), ",\n \"attestation\": {\n" \ + " \"status\": \"reviewed\",\n" \ + " \"implementationAuthor\": \"%s\",\n" \ + " \"independentReviewer\": \"%s\",\n" \ + " \"reviewedAt\": \"%s\",\n" \ + " \"contentHash\": \"%s\"\n" \ + " }\n", \ + attestation.implementation_author, attestation.independent_reviewer, \ + attestation.reviewed_at, attestation.content_hash); \ + } else { \ + fprintf((fp), "\n"); \ + } \ +} while (0) + /* Helper: open output file relative to base directory */ #define OPEN_OUT(name, var) do { \ char _p[512]; cfusa_path_join(_p, sizeof(_p), base, (name)); \ - (var) = fopen(_p, "w"); \ + (var) = cfusa_fopen_write(_p); \ if (!(var)) { perror(_p); return 3; } \ printf("FMEA written to %s (%d functions)\n", _p, g_fn_count); \ } while(0) @@ -150,57 +408,53 @@ int cmd_fmea(int argc, char **argv) OPEN_OUT("fmea.json", jf); OPEN_OUT("fmea.csv", cf); - /* JSON */ fprintf(jf, "{\n" - " \"tool\": \"cfusa fmea\",\n" + " \"schemaVersion\": \"" CFUSA_SCHEMA_VERSION "\",\n" + " \"kind\": \"fmea-report\",\n" + " \"tool\": \"c-FuSa\",\n" + " \"toolVersion\": \"" CFUSA_VERSION_STRING "\",\n" + " \"language\": \"c\",\n" + " \"generatedAt\": \"%s\",\n" " \"project\": \"%s\",\n" " \"version\": \"%s\",\n" - " \"generated\": \"%s\",\n" - " \"standard\": \"IEC 60812 / ISO 26262-5\",\n" + " \"standard\": \"IEC 60812:2018 / ISO 26262-5\",\n" + " \"ratingScale\": \"" FMEA_RATING_SCALE "\",\n" " \"entries\": [\n", - cfg.project, cfg.version, ts); - /* CSV header */ + ts, cfg.project, cfg.version); if (with_cyber) - fprintf(cf, "ID,Function,File,Line,Failure Mode,Effect,Cause,Severity,O,D,RPN,Action,Cyber Failure Mode\n"); + fprintf(cf, "ID,Function,File,Line,Failure Mode,Effect,Cause,Severity,O,D,ActionPriority,Cyber Failure Mode\n"); else - fprintf(cf, "ID,Function,File,Line,Failure Mode,Effect,Cause,Severity,O,D,RPN,Action\n"); + fprintf(cf, "ID,Function,File,Line,Failure Mode,Effect,Cause,Severity,O,D,ActionPriority\n"); - int high = 0, med_cnt = 0, low = 0; for (int i = 0; i < g_fn_count; i++) { - int s = g_fns[i].severity; - const char *sv = sev_string(s); - if (s >= 8) high++; else if (s >= 5) med_cnt++; else low++; - /* JSON entry */ - fprintf(jf, - " {\n" - " \"id\": \"FM-%03d\",\n" - " \"function\": \"%s\",\n" - " \"file\": \"%s\",\n" - " \"line\": %d,\n" - " \"failure_mode\": \"\",\n" - " \"effect\": \"\",\n" - " \"cause\": \"\",\n" - " \"severity\": \"%s\",\n" - " \"occurrence\": 1,\n" - " \"detection\": 1,\n" - " \"rpn\": %d%s\n" - " }%s\n", - i + 1, g_fns[i].name, - cfusa_basename(g_fns[i].file), g_fns[i].line, - sv, s, - with_cyber ? ",\n \"cyber_failure_mode\": \"\"" : "", - (i < g_fn_count - 1) ? "," : ""); - /* CSV row */ - fprintf(cf, "FM-%03d,\"%s\",\"%s\",%d,,,,\"%s\",1,1,%d,", - i + 1, g_fns[i].name, - cfusa_basename(g_fns[i].file), g_fns[i].line, sv, s); + write_entry_json(jf, &g_fns[i], i, i == g_fn_count - 1, with_cyber); + char fm[192], ef[224], ca[192]; + char csv_name[192], csv_fm[256], csv_ef[288], csv_ca[256]; + render_failure_mode(fm, sizeof(fm), &g_fns[i]); + render_effect(ef, sizeof(ef), &g_fns[i]); + render_cause(ca, sizeof(ca), &g_fns[i]); + csv_escape(g_fns[i].name, csv_name, sizeof(csv_name)); + csv_escape(fm, csv_fm, sizeof(csv_fm)); + csv_escape(ef, csv_ef, sizeof(csv_ef)); + csv_escape(ca, csv_ca, sizeof(csv_ca)); + fprintf(cf, "FM-%03d,\"%s\",\"%s\",%d,\"%s\",\"%s\",\"%s\",%d,%d,%d,\"%s\"", + i + 1, csv_name, cfusa_basename(g_fns[i].file), g_fns[i].line, + csv_fm, csv_ef, csv_ca, g_fns[i].severity, g_fns[i].occurrence, + g_fns[i].detection, g_fns[i].action_priority); if (with_cyber) fprintf(cf, ",\n"); else fprintf(cf, "\n"); } - fprintf(jf, " ]\n}\n"); + fprintf(jf, " ],\n \"summary\": {\n" + " \"total\": %d, \"highPriority\": %d,\n" + " \"componentsAnalyzed\": %d, \"componentsInProject\": %d, \"coveragePct\": %d\n" + " }", + g_fn_count, high, g_fn_count, g_total_found, coverage_pct); + WRITE_ATTESTATION(jf); + fprintf(jf, "}\n"); fclose(jf); fclose(cf); - printf("Severity: %d high, %d medium, %d low\n", high, med_cnt, low); - return 0; + printf("Priority: %d high\n", high); + printf("Coverage: %d%% (%d/%d public functions)\n", coverage_pct, g_fn_count, g_total_found); + return qb_gate || cov_gate; } cfusa_format_t fmt = cfusa_format_parse(fmt_s); @@ -213,85 +467,85 @@ int cmd_fmea(int argc, char **argv) fprintf(f, "{\n" " \"schemaVersion\": \"" CFUSA_SCHEMA_VERSION "\",\n" - " \"kind\": \"fmea\",\n" + " \"kind\": \"fmea-report\",\n" " \"tool\": \"c-FuSa\",\n" " \"toolVersion\": \"" CFUSA_VERSION_STRING "\",\n" " \"language\": \"c\",\n" " \"generatedAt\": \"%s\",\n" " \"project\": \"%s\",\n" " \"version\": \"%s\",\n" - " \"standard\": \"IEC 60812 / ISO 26262-5\",\n" + " \"standard\": \"IEC 60812:2018 / ISO 26262-5\",\n" + " \"ratingScale\": \"" FMEA_RATING_SCALE "\",\n" " \"entries\": [\n", ts, cfg.project, cfg.version); - for (int i = 0; i < g_fn_count; i++) { - int s = g_fns[i].severity; - const char *sv = sev_string(s); - fprintf(f, - " {\n" - " \"id\": \"FM-%03d\",\n" - " \"function\": \"%s\",\n" - " \"file\": \"%s\",\n" - " \"line\": %d,\n" - " \"failure_mode\": \"\",\n" - " \"effect\": \"\",\n" - " \"cause\": \"\",\n" - " \"severity\": \"%s\",\n" - " \"occurrence\": 1,\n" - " \"detection\": 1,\n" - " \"rpn\": %d%s\n" - " }%s\n", - i + 1, g_fns[i].name, - cfusa_basename(g_fns[i].file), g_fns[i].line, - sv, s, - with_cyber ? ",\n \"cyber_failure_mode\": \"\"" : "", - (i < g_fn_count - 1) ? "," : ""); - } - fprintf(f, " ]\n}\n"); + for (int i = 0; i < g_fn_count; i++) + write_entry_json(f, &g_fns[i], i, i == g_fn_count - 1, with_cyber); + fprintf(f, " ],\n \"summary\": {\n" + " \"total\": %d, \"highPriority\": %d,\n" + " \"componentsAnalyzed\": %d, \"componentsInProject\": %d, \"coveragePct\": %d\n" + " }", + g_fn_count, high, g_fn_count, g_total_found, coverage_pct); + WRITE_ATTESTATION(f); + fprintf(f, "}\n"); } else if (fmt == FMT_CSV) { if (with_cyber) - fprintf(f, "ID,Function,File,Line,Failure Mode,Effect,Cause,Severity,O,D,RPN,Action,Cyber Failure Mode\n"); + fprintf(f, "ID,Function,File,Line,Failure Mode,Effect,Cause,Severity,O,D,ActionPriority,Cyber Failure Mode\n"); else - fprintf(f, "ID,Function,File,Line,Failure Mode,Effect,Cause,Severity,O,D,RPN,Action\n"); + fprintf(f, "ID,Function,File,Line,Failure Mode,Effect,Cause,Severity,O,D,ActionPriority\n"); for (int i = 0; i < g_fn_count; i++) { - int s = g_fns[i].severity; - const char *sv = sev_string(s); - fprintf(f, "FM-%03d,\"%s\",\"%s\",%d,,,,\"%s\",1,1,%d,", - i + 1, g_fns[i].name, - cfusa_basename(g_fns[i].file), g_fns[i].line, sv, s); + char fm[192], ef[224], ca[192]; + char csv_name[192], csv_fm[256], csv_ef[288], csv_ca[256]; + render_failure_mode(fm, sizeof(fm), &g_fns[i]); + render_effect(ef, sizeof(ef), &g_fns[i]); + render_cause(ca, sizeof(ca), &g_fns[i]); + csv_escape(g_fns[i].name, csv_name, sizeof(csv_name)); + csv_escape(fm, csv_fm, sizeof(csv_fm)); + csv_escape(ef, csv_ef, sizeof(csv_ef)); + csv_escape(ca, csv_ca, sizeof(csv_ca)); + fprintf(f, "FM-%03d,\"%s\",\"%s\",%d,\"%s\",\"%s\",\"%s\",%d,%d,%d,\"%s\"", + i + 1, csv_name, cfusa_basename(g_fns[i].file), g_fns[i].line, + csv_fm, csv_ef, csv_ca, g_fns[i].severity, g_fns[i].occurrence, + g_fns[i].detection, g_fns[i].action_priority); if (with_cyber) fprintf(f, ",\n"); else fprintf(f, "\n"); } } else { /* Markdown */ fprintf(f, "# Design FMEA — %s v%s\n" - "Generated: %s | Standard: IEC 60812 / ISO 26262 Part 5\n\n" - "**Instructions:** For each function, identify failure modes and effects. " - "S/O/D rated 1-10; RPN = S*O*D.\n\n", + "Generated: %s | Standard: IEC 60812:2018 / ISO 26262 Part 5\n" + "Rating scale: " FMEA_RATING_SCALE "\n\n", cfg.project, cfg.version, ts); fprintf(f, "| ID | Function | File | Failure Mode | Effect | " - "Cause | S | O | D | RPN | Action |"); + "Cause | S | O | D | Action Priority |"); if (with_cyber) fprintf(f, " Cyber Failure Mode |"); - fprintf(f, "\n|---|---|---|---|---|---|---|---|---|---|---|"); + fprintf(f, "\n|---|---|---|---|---|---|---|---|---|---|"); if (with_cyber) fprintf(f, "---|"); fprintf(f, "\n"); for (int i = 0; i < g_fn_count; i++) { + char fm[192], ef[224], ca[192]; + render_failure_mode(fm, sizeof(fm), &g_fns[i]); + render_effect(ef, sizeof(ef), &g_fns[i]); + render_cause(ca, sizeof(ca), &g_fns[i]); fprintf(f, - "| FM-%03d | `%s` | %s:%d | [describe] | [effect] | [cause] " - "| %d | 1 | 1 | %d | [action] |", + "| FM-%03d | `%s` | %s:%d | %s | %s | %s " + "| %d | %d | %d | %s |", i + 1, g_fns[i].name, cfusa_basename(g_fns[i].file), g_fns[i].line, - g_fns[i].severity, g_fns[i].severity); - if (with_cyber) fprintf(f, " [cyber] |"); + fm, ef, ca, + g_fns[i].severity, g_fns[i].occurrence, g_fns[i].detection, + g_fns[i].action_priority); + if (with_cyber) fprintf(f, " |"); fprintf(f, "\n"); } fprintf(f, "\n---\n" - "_Total functions analysed: %d_ \n" - "_Review: [name / date]_\n", g_fn_count); + "_Total functions analysed: %d (%d%% of %d public functions found)_ \n", + g_fn_count, coverage_pct, g_total_found); } fclose(f); - return 0; + return qb_gate || cov_gate; #undef OPEN_OUT +#undef WRITE_ATTESTATION } diff --git a/cmd/cfusa/cmd_hara.c b/cmd/cfusa/cmd_hara.c index 9179a86..d66c5a5 100644 --- a/cmd/cfusa/cmd_hara.c +++ b/cmd/cfusa/cmd_hara.c @@ -2,25 +2,41 @@ # define _GNU_SOURCE #endif +#include #include #include #include #include #include "cfusa/config.h" +#include "cfusa/qualitybar.h" #include "cfusa/utils.h" #include "cfusa/version.h" /* * Hazard Analysis and Risk Assessment (ISO 26262-3:2018 Clause 6). * + * .fusa-hara.json is an *input* file (like .fusa-reqs.json): a project + * author writes/maintains it; `cfusa hara` validates and reports on it + * (x-FuSa spec §1.2.5, §9.2). Three cross-referenced collections — + * operationalSituations[] / hazards[] / safetyGoals[] — replace this + * tool's previous single flat "hazards[]" shape. + * * Subcommands: - * init — write a .cfusa-hara.json skeleton - * show — display all hazard entries with ASIL rating + * init — write a .fusa-hara.json skeleton (empty collections, never + * dummy rows — x-FuSa spec §1.6 rule 1) + * show — validate + report all three collections, with completeness and + * referential-integrity checks, and the §1.6.1 content-quality scan * asil — compute ASIL from S/E/C parameters */ #define HARA_FILE ".fusa-hara.json" #define HARA_FILE_LEGACY ".cfusa-hara.json" +#define REQS_FILE ".fusa-reqs.json" +#define REQS_FILE_LEGACY ".cfusa-reqs.json" + +#define MAX_ITEMS 256 +#define MAX_REFS 16 +#define REF_LEN 32 /* * ISO 26262-3:2018 Table 4 ASIL determination with C0 extension. @@ -67,7 +83,383 @@ static void do_asil(int s, int e, int c) printf(" Result %s\n", compute_asil(s, e, c)); } -static int do_init(const char *dir, const char *project, const char *version) +/* Parse a "Sx"/"Ex"/"Cx" (or bare "x") code into an integer. */ +static int parse_sec_code(const char *v) +{ + if (!v || !*v) return -1; + if (isalpha((unsigned char)v[0])) v++; + return atoi(v); +} + +/* ------------------------------------------------------------------ */ +/* Minimal, schema-scoped JSON reading (no generic parser — mirrors the */ +/* ad hoc field-extraction style already used by cmd_req.c/cmd_disposition.c) */ +/* ------------------------------------------------------------------ */ + +/* Extracts the balanced bracket/brace substring (inclusive) for "key": + * starting at `open` (`{` or `[`), string-aware so a literal delimiter + * inside a quoted value doesn't miscount depth. Caller frees the result. + * When `end_after` is non-NULL, it's set to a pointer just past the closing + * delimiter *within the original `json` text* — so a caller can scope a + * subsequent sibling-key search to start there, avoiding a false match on + * a same-named key nested *inside* this bracket (e.g. .fusa-hara.json's + * top-level "safetyGoals" collection vs. each hazard's own nested + * "safetyGoals": [...] reference array — see x-FuSa spec §1.2.5). */ +static char *extract_bracket_at(const char *json, const char *key, char open, char close, + const char **end_after) +{ + char pat[64]; + snprintf(pat, sizeof(pat), "\"%s\"", key); + const char *p = strstr(json, pat); + if (!p) return NULL; + p = strchr(p + strlen(pat), open); + if (!p) return NULL; + + int depth = 0, in_str = 0; + const char *start = p, *end = NULL; + for (; *p; p++) { + if (in_str) { + if (*p == '\\') { p++; continue; } + if (*p == '"') in_str = 0; + continue; + } + if (*p == '"') { in_str = 1; continue; } + if (*p == open) depth++; + else if (*p == close) { depth--; if (depth == 0) { end = p; break; } } + } + if (!end) return NULL; + if (end_after) *end_after = end + 1; + + size_t n = (size_t)(end - start) + 1; + char *out = malloc(n + 1); + if (!out) return NULL; + memcpy(out, start, n); + out[n] = '\0'; + return out; +} + +static char *extract_bracket(const char *json, const char *key, char open, char close) +{ + return extract_bracket_at(json, key, open, close, NULL); +} + +/* Splits the top-level elements of a `[ ... ]` array string (objects or + * bare strings) into `elems`, string-content unescaped/unquoted for bare + * string elements. Returns the element count. */ +static int split_array(const char *arr, char elems[][512], int max_elems) +{ + if (!arr) return 0; + const char *p = strchr(arr, '['); + if (!p) return 0; + p++; + int n = 0; + while (*p) { + while (*p == ' ' || *p == '\n' || *p == '\t' || *p == '\r' || *p == ',') p++; + if (*p == ']' || !*p) break; + + const char *start = p; + int is_str = (*p == '"'); + if (*p == '{') { + int depth = 0, in_str = 0; + for (; *p; p++) { + if (in_str) { + if (*p == '\\') { p++; continue; } + if (*p == '"') in_str = 0; + continue; + } + if (*p == '"') { in_str = 1; continue; } + if (*p == '{') depth++; + else if (*p == '}') { depth--; if (depth == 0) { p++; break; } } + } + } else if (is_str) { + p++; + while (*p && *p != '"') { if (*p == '\\' && p[1]) p++; p++; } + if (*p == '"') p++; + } else { + while (*p && *p != ',' && *p != ']') p++; + } + + size_t len = (size_t)(p - start); + if (n < max_elems && len < 511) { + if (is_str && len >= 2) { + /* strip surrounding quotes for bare string elements */ + memcpy(elems[n], start + 1, len - 2); + elems[n][len - 2] = '\0'; + } else { + memcpy(elems[n], start, len); + elems[n][len] = '\0'; + } + n++; + } + } + return n; +} + +static void extract_str(const char *block, const char *key, char *out, size_t out_sz) +{ + out[0] = '\0'; + char pat[64]; + snprintf(pat, sizeof(pat), "\"%s\":", key); + const char *fp = strstr(block, pat); + if (!fp) return; + fp += strlen(pat); + while (*fp == ' ' || *fp == '\t' || *fp == '\n') fp++; + if (*fp != '"') return; + fp++; + size_t k = 0; + while (*fp && *fp != '"' && k < out_sz - 1) { + if (*fp == '\\' && fp[1]) fp++; + out[k++] = *fp++; + } + out[k] = '\0'; +} + +typedef struct { + char id[REF_LEN]; + char description[256]; +} os_entry_t; + +typedef struct { + char id[REF_LEN]; + char description[256]; + char source[128]; + char situations[MAX_REFS][REF_LEN]; int situations_count; + char severity[8], exposure[8], controllability[8], asil[16]; + char safety_goals[MAX_REFS][REF_LEN]; int safety_goals_count; +} hazard_entry_t; + +typedef struct { + char id[REF_LEN]; + char description[256]; + char hazards[MAX_REFS][REF_LEN]; int hazards_count; + char asil[16]; + char safe_state[128]; + char fssr_refs[MAX_REFS][REF_LEN]; int fssr_refs_count; +} safety_goal_entry_t; + +typedef struct { + char project[128], standard[64], created_at[40]; + os_entry_t situations[MAX_ITEMS]; int situations_count; + hazard_entry_t hazards[MAX_ITEMS]; int hazards_count; + safety_goal_entry_t goals[MAX_ITEMS]; int goals_count; + cfusa_attestation_t attestation; +} hara_doc_t; + +static void parse_hara_doc(const char *json, size_t len, hara_doc_t *doc) +{ + memset(doc, 0, sizeof(*doc)); + extract_str(json, "project", doc->project, sizeof(doc->project)); + extract_str(json, "standard", doc->standard, sizeof(doc->standard)); + extract_str(json, "createdAt", doc->created_at, sizeof(doc->created_at)); + cfusa_qb_attestation_read(json, len, &doc->attestation); + + char *os_arr = extract_bracket(json, "operationalSituations", '[', ']'); + if (os_arr) { + char elems[MAX_ITEMS][512]; + int n = split_array(os_arr, elems, MAX_ITEMS); + for (int i = 0; i < n && i < MAX_ITEMS; i++) { + extract_str(elems[i], "id", doc->situations[i].id, sizeof(doc->situations[i].id)); + extract_str(elems[i], "description", doc->situations[i].description, + sizeof(doc->situations[i].description)); + } + doc->situations_count = n; + free(os_arr); + } + + const char *hz_end_ptr = NULL; + char *hz_arr = extract_bracket_at(json, "hazards", '[', ']', &hz_end_ptr); + if (hz_arr) { + char elems[MAX_ITEMS][512]; + int n = split_array(hz_arr, elems, MAX_ITEMS); + for (int i = 0; i < n && i < MAX_ITEMS; i++) { + hazard_entry_t *h = &doc->hazards[i]; + extract_str(elems[i], "id", h->id, sizeof(h->id)); + extract_str(elems[i], "description", h->description, sizeof(h->description)); + extract_str(elems[i], "source", h->source, sizeof(h->source)); + + char *sit_arr = extract_bracket(elems[i], "situations", '[', ']'); + if (sit_arr) { + char sub[MAX_REFS][512]; + h->situations_count = split_array(sit_arr, sub, MAX_REFS); + for (int k = 0; k < h->situations_count; k++) + strncpy(h->situations[k], sub[k], REF_LEN - 1); + free(sit_arr); + } + + char *risk = extract_bracket(elems[i], "risk", '{', '}'); + if (risk) { + extract_str(risk, "severity", h->severity, sizeof(h->severity)); + extract_str(risk, "exposure", h->exposure, sizeof(h->exposure)); + extract_str(risk, "controllability", h->controllability, sizeof(h->controllability)); + extract_str(risk, "asil", h->asil, sizeof(h->asil)); + free(risk); + } + + char *sg_arr = extract_bracket(elems[i], "safetyGoals", '[', ']'); + if (sg_arr) { + char sub[MAX_REFS][512]; + h->safety_goals_count = split_array(sg_arr, sub, MAX_REFS); + for (int k = 0; k < h->safety_goals_count; k++) + strncpy(h->safety_goals[k], sub[k], REF_LEN - 1); + free(sg_arr); + } + } + doc->hazards_count = n; + free(hz_arr); + } + + /* Scoped to start *after* the hazards array (when present) so this + * doesn't match the first hazard's own nested "safetyGoals": [...] + * reference array instead of the document's top-level collection. */ + char *sg_arr_top = extract_bracket(hz_end_ptr ? hz_end_ptr : json, "safetyGoals", '[', ']'); + if (sg_arr_top) { + char elems[MAX_ITEMS][512]; + int n = split_array(sg_arr_top, elems, MAX_ITEMS); + for (int i = 0; i < n && i < MAX_ITEMS; i++) { + safety_goal_entry_t *g = &doc->goals[i]; + extract_str(elems[i], "id", g->id, sizeof(g->id)); + extract_str(elems[i], "description", g->description, sizeof(g->description)); + extract_str(elems[i], "asil", g->asil, sizeof(g->asil)); + extract_str(elems[i], "safeState", g->safe_state, sizeof(g->safe_state)); + + char *hz_refs = extract_bracket(elems[i], "hazards", '[', ']'); + if (hz_refs) { + char sub[MAX_REFS][512]; + g->hazards_count = split_array(hz_refs, sub, MAX_REFS); + for (int k = 0; k < g->hazards_count; k++) + strncpy(g->hazards[k], sub[k], REF_LEN - 1); + free(hz_refs); + } + + char *fssr = extract_bracket(elems[i], "fssrRefs", '[', ']'); + if (fssr) { + char sub[MAX_REFS][512]; + g->fssr_refs_count = split_array(fssr, sub, MAX_REFS); + for (int k = 0; k < g->fssr_refs_count; k++) + strncpy(g->fssr_refs[k], sub[k], REF_LEN - 1); + free(fssr); + } + } + doc->goals_count = n; + free(sg_arr_top); + } +} + +static char *read_hara_file(const char *dir, size_t *len_out) +{ + char path[512]; + cfusa_path_join(path, sizeof(path), dir, HARA_FILE); + char *content = cfusa_read_file(path, len_out); + if (!content) { + cfusa_path_join(path, sizeof(path), dir, HARA_FILE_LEGACY); + content = cfusa_read_file(path, len_out); + } + return content; +} + +/* Loads just the requirement ids out of .fusa-reqs.json, for fssrRefs + * referential-integrity checking (x-FuSa spec §1.2.5). */ +#define MAX_REQ_IDS 2048 +static int load_req_ids(const char *dir, char ids[][REF_LEN]) +{ + char path[512]; + cfusa_path_join(path, sizeof(path), dir, REQS_FILE); + size_t len; + char *json = cfusa_read_file(path, &len); + if (!json) { + cfusa_path_join(path, sizeof(path), dir, REQS_FILE_LEGACY); + json = cfusa_read_file(path, &len); + } + if (!json) return 0; + + int n = 0; + char *p = json; + while ((p = strstr(p, "\"id\":")) != NULL && n < MAX_REQ_IDS) { + char id[REF_LEN] = ""; + sscanf(p, "\"id\":\"%31[^\"]", id); + if (id[0]) { strncpy(ids[n], id, REF_LEN - 1); n++; } + p += 5; + } + free(json); + return n; +} + +static int id_in_set(const char *id, char set[][REF_LEN], int n) +{ + for (int i = 0; i < n; i++) + if (strcmp(id, set[i]) == 0) return 1; + return 0; +} + +/* Builds the RFC-8785-style canonical fragment over the document's + * substantive content (operationalSituations/hazards/safetyGoals) — + * object members in ASCII-lexicographic key order, no insignificant + * whitespace — for x-FuSa spec §1.6.2 attestation content-hashing. + * Excludes `attestation` itself and any generatedAt/tool provenance, per + * spec. Truncates silently on overflow (bufsz is sized generously by the + * caller; a truncated-but-still-deterministic hash only ever produces a + * false "stale" verdict, never a false "valid" one, so this is fail-safe). */ +static size_t append_ref_array(char *buf, size_t bufsz, size_t off, + char refs[][REF_LEN], int n) +{ + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, "["); + for (int i = 0; i < n; i++) + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + "%s\"%s\"", i ? "," : "", refs[i]); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, "]"); + return off; +} + +static size_t hara_canonical_content(hara_doc_t *doc, char *buf, size_t bufsz) +{ + size_t off = 0; + char esc[256]; + + off += (size_t)snprintf(buf + off, bufsz - off, "{\"hazards\":["); + for (int i = 0; i < doc->hazards_count; i++) { + hazard_entry_t *h = &doc->hazards[i]; + cfusa_str_escape_json(h->description, esc, sizeof(esc)); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + "%s{\"asil\":\"%s\",\"controllability\":\"%s\",\"description\":\"%s\"," + "\"exposure\":\"%s\",\"id\":\"%s\",\"safetyGoals\":", + i ? "," : "", h->asil, h->controllability, esc, h->exposure, h->id); + off = append_ref_array(buf, bufsz, off, h->safety_goals, h->safety_goals_count); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + ",\"severity\":\"%s\",\"situations\":", h->severity); + off = append_ref_array(buf, bufsz, off, h->situations, h->situations_count); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + ",\"source\":\"%s\"}", h->source); + } + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + "],\"operationalSituations\":["); + for (int i = 0; i < doc->situations_count; i++) { + cfusa_str_escape_json(doc->situations[i].description, esc, sizeof(esc)); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + "%s{\"description\":\"%s\",\"id\":\"%s\"}", + i ? "," : "", esc, doc->situations[i].id); + } + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, "],\"safetyGoals\":["); + for (int i = 0; i < doc->goals_count; i++) { + safety_goal_entry_t *g = &doc->goals[i]; + cfusa_str_escape_json(g->description, esc, sizeof(esc)); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + "%s{\"asil\":\"%s\",\"description\":\"%s\",\"fssrRefs\":", + i ? "," : "", g->asil, esc); + off = append_ref_array(buf, bufsz, off, g->fssr_refs, g->fssr_refs_count); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, ",\"hazards\":"); + off = append_ref_array(buf, bufsz, off, g->hazards, g->hazards_count); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + ",\"id\":\"%s\",\"safeState\":\"%s\"}", g->id, g->safe_state); + } + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, "]}"); + return off; +} + +/* ------------------------------------------------------------------ */ +/* init */ +/* ------------------------------------------------------------------ */ + +static int do_init(const char *dir, const char *project) { char path[512]; cfusa_path_join(path, sizeof(path), dir, HARA_FILE); @@ -77,11 +469,15 @@ static int do_init(const char *dir, const char *project, const char *version) return 2; } - FILE *f = fopen(path, "w"); + FILE *f = cfusa_fopen_write(path); if (!f) { perror(path); return 3; } char ts[32]; cfusa_timestamp_now(ts); + char esc_project[256]; + cfusa_str_escape_json(project, esc_project, sizeof(esc_project)); + /* x-FuSa spec §1.6 rule 1: an unanalyzed section MUST be an empty + * array, never a dummy/placeholder row. */ fprintf(f, "{\n" " \"schemaVersion\": \"" CFUSA_SCHEMA_VERSION "\",\n" @@ -89,189 +485,286 @@ static int do_init(const char *dir, const char *project, const char *version) " \"tool\": \"c-FuSa\",\n" " \"toolVersion\": \"" CFUSA_VERSION_STRING "\",\n" " \"language\": \"c\",\n" - " \"generatedAt\": \"%s\",\n" " \"project\": \"%s\",\n" - " \"version\": \"%s\",\n" - " \"standard\": \"ISO 26262-3:2018\",\n" - " \"hazards\": [\n" - " {\n" - " \"id\": \"HAZ-001\",\n" - " \"item\": \"[item under analysis]\",\n" - " \"hazardous_event\": \"[describe hazardous event]\",\n" - " \"severity\": 3,\n" - " \"exposure\": 3,\n" - " \"controllability\": 2,\n" - " \"asil\": \"ASIL-C\",\n" - " \"safe_state\": \"[describe safe state]\",\n" - " \"safety_goal\": \"[derive safety goal]\",\n" - " \"ftti_ms\": 100\n" - " }\n" - " ]\n" + " \"standard\": \"iso26262\",\n" + " \"createdAt\": \"%s\",\n" + " \"operationalSituations\": [],\n" + " \"hazards\": [],\n" + " \"safetyGoals\": []\n" "}\n", - ts, project, version); + esc_project, ts); fclose(f); printf("HARA skeleton written to %s\n", path); - printf("Edit hazards and run 'cfusa hara show' to review.\n"); + printf("Edit operationalSituations/hazards/safetyGoals and run 'cfusa hara show' to review.\n"); return 0; } -static void do_show_json(const char *dir, FILE *out) +/* ------------------------------------------------------------------ */ +/* show — text */ +/* ------------------------------------------------------------------ */ + +/* Runs the x-FuSa spec §1.6.1 content-quality scan over every qualitative + * field in `doc`. Returns the number of Rule A (always-ERROR, + * disposition-suppressible-only) hits still outstanding after disposition + * lookup, for the caller's exit-code decision. Rule B is advisory + * (WARNING) unless `require_attestation`, and is suppressed entirely by a + * valid, non-stale, independent attestation. */ +static int run_quality_bar(const char *dir, hara_doc_t *doc, int require_attestation, + FILE *out, int quiet) { - char path[512]; - cfusa_path_join(path, sizeof(path), dir, HARA_FILE); - size_t len; - char *content = cfusa_read_file(path, &len); - if (!content) { - char legacy[512]; - cfusa_path_join(legacy, sizeof(legacy), dir, HARA_FILE_LEGACY); - content = cfusa_read_file(legacy, &len); + int rule_a_hits = 0, rule_a_disposed = 0; + const char *texts[3 * MAX_ITEMS]; + int ntext = 0; + + for (int i = 0; i < doc->situations_count; i++) { + const char *d = doc->situations[i].description; + if (cfusa_qb_is_stub_text(d)) { + rule_a_hits++; + if (!quiet) fprintf(out, " [ERROR] %s operationalSituations[%s].description contains placeholder text\n", + CFUSA_QB_RULE_A, doc->situations[i].id); + } + if (d[0]) texts[ntext++] = d; } - if (!content) { - fprintf(stderr, "cfusa hara: no %s found — run 'cfusa hara init' first\n", HARA_FILE); - return; + for (int i = 0; i < doc->hazards_count; i++) { + const char *d = doc->hazards[i].description; + if (cfusa_qb_is_stub_text(d)) { + rule_a_hits++; + if (!quiet) fprintf(out, " [ERROR] %s hazards[%s].description contains placeholder text\n", + CFUSA_QB_RULE_A, doc->hazards[i].id); + } + if (d[0]) texts[ntext++] = d; } - fwrite(content, 1, len, out); - if (len > 0 && content[len - 1] != '\n') fputc('\n', out); - free(content); + for (int i = 0; i < doc->goals_count; i++) { + const char *d = doc->goals[i].description; + if (cfusa_qb_is_stub_text(d)) { + rule_a_hits++; + if (!quiet) fprintf(out, " [ERROR] %s safetyGoals[%s].description contains placeholder text\n", + CFUSA_QB_RULE_A, doc->goals[i].id); + } + if (d[0]) texts[ntext++] = d; + } + + if (rule_a_hits > 0 && cfusa_qb_rule_disposed(dir, CFUSA_QB_RULE_A)) { + rule_a_disposed = 1; + if (!quiet) fprintf(out, " (%s disposed — see cfusa disposition list)\n", CFUSA_QB_RULE_A); + } + + int rule_b = cfusa_qb_rule_b_flagged(texts, ntext); + if (rule_b) { + char canonical[16384]; + size_t clen = hara_canonical_content(doc, canonical, sizeof(canonical)); + if (clen >= sizeof(canonical)) clen = sizeof(canonical) - 1; + char fresh[80]; + cfusa_qb_content_hash(canonical, clen, fresh); + int reviewed = cfusa_qb_attestation_valid(&doc->attestation, fresh); + if (!reviewed && !quiet) + fprintf(out, " [WARNING] %s hazard/safety-goal descriptions show low distinct-value " + "ratio across >=10 entries (possible templated content)\n", CFUSA_QB_RULE_B); + rule_b = (!reviewed && require_attestation) ? 1 : 0; + } + + if (rule_a_hits > 0 && !rule_a_disposed) return 1; /* Rule A always gates unless disposed */ + if (require_attestation && rule_b) return 1; + return 0; } -static void do_show_md(const char *dir, FILE *out) +static void print_completeness(FILE *out, hara_doc_t *doc, const char *dir) { - char path[512]; - cfusa_path_join(path, sizeof(path), dir, HARA_FILE); - size_t len; - char *content = cfusa_read_file(path, &len); - if (!content) { - char legacy[512]; - cfusa_path_join(legacy, sizeof(legacy), dir, HARA_FILE_LEGACY); - content = cfusa_read_file(legacy, &len); + int total_hazards = doc->hazards_count; + int hazards_with_asil = 0, hazards_with_sg = 0; + int total_goals = doc->goals_count; + int goals_with_fssr = 0; + int dangling = 0; + + for (int i = 0; i < total_hazards; i++) { + hazard_entry_t *h = &doc->hazards[i]; + if (h->asil[0]) hazards_with_asil++; + if (h->safety_goals_count > 0) hazards_with_sg++; + for (int k = 0; k < h->situations_count; k++) { + int found = 0; + for (int s = 0; s < doc->situations_count; s++) + if (strcmp(h->situations[k], doc->situations[s].id) == 0) { found = 1; break; } + if (!found) dangling++; + } + for (int k = 0; k < h->safety_goals_count; k++) { + int found = 0; + for (int g = 0; g < doc->goals_count; g++) + if (strcmp(h->safety_goals[k], doc->goals[g].id) == 0) { found = 1; break; } + if (!found) dangling++; + } } - if (!content) { - fprintf(stderr, "cfusa hara: no %s found — run 'cfusa hara init' first\n", HARA_FILE); - return; - } - - fprintf(out, "# Hazard Analysis and Risk Assessment (HARA)\n\n"); - fprintf(out, "| ID | Hazardous Event | S | E | C | ASIL | Safety Goal |\n"); - fprintf(out, "|---|---|---|---|---|---|---|\n"); - - char *p = content; - while ((p = strstr(p, "\"id\"")) != NULL) { - char id[32]="", event[128]="", asil[16]="", goal[128]=""; - int sev=0, exp=0, ctl=0; - char *blk = p; - char *end = strstr(blk + 1, "\"id\""); - if (!end) end = content + len; - { char *fp = strstr(blk,"\"id\":"); if (fp) { fp+=5; while(*fp==' ') fp++; if(*fp=='"') fp++; sscanf(fp,"%31[^\"]",id); } } - { char *fp = strstr(blk,"\"hazardous_event\":"); if (fp) { fp+=18; while(*fp==' ') fp++; if(*fp=='"') fp++; sscanf(fp,"%127[^\"]",event); } } - { char *fp = strstr(blk,"\"asil\":"); if (fp) { fp+=7; while(*fp==' ') fp++; if(*fp=='"') fp++; sscanf(fp,"%15[^\"]",asil); } } - { char *fp = strstr(blk,"\"safety_goal\":"); if (fp) { fp+=14; while(*fp==' ') fp++; if(*fp=='"') fp++; sscanf(fp,"%127[^\"]",goal); } } - { char *fp = strstr(blk,"\"severity\":"); if (fp) sscanf(fp,"\"severity\": %d",&sev); } - { char *fp = strstr(blk,"\"exposure\":"); if (fp) sscanf(fp,"\"exposure\": %d",&exp); } - { char *fp = strstr(blk,"\"controllability\":"); if (fp) sscanf(fp,"\"controllability\": %d",&ctl); } - fprintf(out, "| %s | %s | %d | %d | %d | %s | %s |\n", id, event, sev, exp, ctl, asil, goal); - p = end; + + char req_ids[MAX_REQ_IDS][REF_LEN]; + int req_count = load_req_ids(dir, req_ids); + + for (int i = 0; i < total_goals; i++) { + safety_goal_entry_t *g = &doc->goals[i]; + if (g->fssr_refs_count > 0) goals_with_fssr++; + for (int k = 0; k < g->hazards_count; k++) { + int found = 0; + for (int h = 0; h < doc->hazards_count; h++) + if (strcmp(g->hazards[k], doc->hazards[h].id) == 0) { found = 1; break; } + if (!found) dangling++; + } + for (int k = 0; k < g->fssr_refs_count; k++) { + if (req_count == 0 || !id_in_set(g->fssr_refs[k], req_ids, req_count)) dangling++; + } } - free(content); + + fprintf(out, "\nCompleteness:\n"); + fprintf(out, " totalHazards: %d\n", total_hazards); + fprintf(out, " hazardsWithAsil: %d\n", hazards_with_asil); + fprintf(out, " hazardsWithSafetyGoal: %d\n", hazards_with_sg); + fprintf(out, " safetyGoalsWithFssrRefs: %d / %d\n", goals_with_fssr, total_goals); + fprintf(out, " danglingReferences: %d\n", dangling); + if (total_goals > 0 && goals_with_fssr < total_goals) + fprintf(out, " WARNING: %d safety goal(s) missing fssrRefs (MUST, >=1 entry — x-FuSa spec §1.2.5)\n", + total_goals - goals_with_fssr); } -static void do_show(const char *dir, FILE *out) +static int do_show(const char *dir, FILE *out, int require_attestation) { - char path[512]; - cfusa_path_join(path, sizeof(path), dir, HARA_FILE); - size_t len; - char *content = cfusa_read_file(path, &len); + char *content = read_hara_file(dir, &len); if (!content) { - /* legacy fallback */ - char legacy[512]; - cfusa_path_join(legacy, sizeof(legacy), dir, HARA_FILE_LEGACY); - content = cfusa_read_file(legacy, &len); - if (content) { - strncpy(path, legacy, sizeof(path) - 1); - } else { - fprintf(stderr, "cfusa hara: no %s found — run 'cfusa hara init' first\n", - HARA_FILE); - return; - } + fprintf(stderr, "cfusa hara: no %s found — run 'cfusa hara init' first\n", HARA_FILE); + return 3; } + hara_doc_t doc; + parse_hara_doc(content, len, &doc); + free(content); + fprintf(out, "Hazard Analysis and Risk Assessment\n"); fprintf(out, "=====================================\n"); + fprintf(out, "Project: %s Standard: %s\n", doc.project, doc.standard); + + fprintf(out, "\nOperational Situations (%d):\n", doc.situations_count); + for (int i = 0; i < doc.situations_count; i++) + fprintf(out, " %-10s %s\n", doc.situations[i].id, doc.situations[i].description); + + fprintf(out, "\nHazards (%d):\n", doc.hazards_count); + for (int i = 0; i < doc.hazards_count; i++) { + hazard_entry_t *h = &doc.hazards[i]; + int s = parse_sec_code(h->severity), e = parse_sec_code(h->exposure), + c = parse_sec_code(h->controllability); + const char *computed = compute_asil(s, e, c); + fprintf(out, "\n%s [%s]\n", h->id, h->asil[0] ? h->asil : "(no asil)"); + fprintf(out, " Description: %s\n", h->description); + fprintf(out, " %s/%s/%s\n", h->severity, h->exposure, h->controllability); + if (h->asil[0] && strcmp(computed, h->asil) != 0) + fprintf(out, " WARNING: stored ASIL %s differs from computed %s\n", h->asil, computed); + } - /* Simple extraction: find each hazard block */ - int count = 0; - char *p = content; - while ((p = strstr(p, "\"id\"")) != NULL) { - char id[32]="", event[128]="", asil[16]="", goal[128]="", safe[128]=""; - int sev=0, exp=0, ctl=0, ftti=0; - char *blk = p; - - /* Scan ahead to collect fields in this block */ - char *end = strstr(blk+1, "\"id\""); - if (!end) end = content + len; - - if (strstr(blk, "\"id\"")) { - char *fp = strstr(blk, "\"id\":"); - if (fp) { fp += 5; while(*fp==' '||*fp=='\t') fp++; if(*fp=='"') fp++; sscanf(fp, "%31[^\"]", id); } - } - { - char *fp = strstr(blk, "\"hazardous_event\":"); - if (fp) { fp += 18; while(*fp==' '||*fp=='\t') fp++; if(*fp=='"') fp++; sscanf(fp, "%127[^\"]", event); } - } - { - char *fp = strstr(blk, "\"asil\":"); - if (fp) { fp += 7; while(*fp==' '||*fp=='\t') fp++; if(*fp=='"') fp++; sscanf(fp, "%15[^\"]", asil); } - } - { - char *fp = strstr(blk, "\"safety_goal\":"); - if (fp) { fp += 14; while(*fp==' '||*fp=='\t') fp++; if(*fp=='"') fp++; sscanf(fp, "%127[^\"]", goal); } - } - { - char *fp = strstr(blk, "\"safe_state\":"); - if (fp) { fp += 13; while(*fp==' '||*fp=='\t') fp++; if(*fp=='"') fp++; sscanf(fp, "%127[^\"]", safe); } - } - { - char *fp = strstr(blk, "\"severity\":"); - if (fp) sscanf(fp, "\"severity\": %d", &sev); - } - { - char *fp = strstr(blk, "\"exposure\":"); - if (fp) sscanf(fp, "\"exposure\": %d", &exp); - } - { - char *fp = strstr(blk, "\"controllability\":"); - if (fp) sscanf(fp, "\"controllability\": %d", &ctl); - } - { - char *fp = strstr(blk, "\"ftti_ms\":"); - if (fp) sscanf(fp, "\"ftti_ms\": %d", &ftti); - } + fprintf(out, "\nSafety Goals (%d):\n", doc.goals_count); + for (int i = 0; i < doc.goals_count; i++) { + safety_goal_entry_t *g = &doc.goals[i]; + fprintf(out, "\n%s [%s]\n", g->id, g->asil[0] ? g->asil : "(no asil)"); + fprintf(out, " Description: %s\n", g->description); + fprintf(out, " fssrRefs: %d\n", g->fssr_refs_count); + if (g->fssr_refs_count == 0) + fprintf(out, " WARNING: no fssrRefs (MUST, >=1 entry per x-FuSa spec §1.2.5)\n"); + } - fprintf(out, "\n%s [%s]\n", id, asil); - fprintf(out, " Event: %s\n", event); - fprintf(out, " S%d/E%d/C%d Safety Goal: %s\n", sev, exp, ctl, goal); - fprintf(out, " Safe State: %s\n", safe); - if (ftti > 0) - fprintf(out, " FTTI: %d ms\n", ftti); + print_completeness(out, &doc, dir); + + fprintf(out, "\nContent-quality scan (x-FuSa spec §1.6.1):\n"); + int gate = run_quality_bar(dir, &doc, require_attestation, out, 0); + + if (doc.situations_count == 0 && doc.hazards_count == 0 && doc.goals_count == 0) + fprintf(out, "\n(No hazards/safety-goals/operational-situations recorded yet.)\n"); + + return gate; +} - /* Recompute ASIL from parameters to verify */ - const char *computed = compute_asil(sev, exp, ctl); - if (strcmp(computed, asil) != 0) - fprintf(out, " WARNING: stored ASIL %s differs from computed %s\n", - asil, computed); - count++; - p = end; +static int do_show_json(const char *dir, FILE *out, int require_attestation) +{ + size_t len; + char *content = read_hara_file(dir, &len); + if (!content) { + fprintf(stderr, "cfusa hara: no %s found — run 'cfusa hara init' first\n", HARA_FILE); + return 3; } - free(content); + hara_doc_t doc; + parse_hara_doc(content, len, &doc); - if (count == 0) { - fprintf(out, "No hazard entries found in %s\n", path); - } else { - fprintf(out, "\n%d hazard(s) listed.\n", count); + int total_hazards = doc.hazards_count, hazards_with_asil = 0, hazards_with_sg = 0; + int goals_with_fssr = 0, dangling = 0; + for (int i = 0; i < total_hazards; i++) { + if (doc.hazards[i].asil[0]) hazards_with_asil++; + if (doc.hazards[i].safety_goals_count > 0) hazards_with_sg++; + } + char req_ids[MAX_REQ_IDS][REF_LEN]; + int req_count = load_req_ids(dir, req_ids); + for (int i = 0; i < doc.goals_count; i++) { + if (doc.goals[i].fssr_refs_count > 0) goals_with_fssr++; + for (int k = 0; k < doc.goals[i].fssr_refs_count; k++) + if (req_count == 0 || !id_in_set(doc.goals[i].fssr_refs[k], req_ids, req_count)) dangling++; + } + + char ts[32]; cfusa_timestamp_now(ts); + + fprintf(out, + "{\n" + " \"schemaVersion\": \"" CFUSA_SCHEMA_VERSION "\",\n" + " \"kind\": \"hara-report\",\n" + " \"tool\": \"c-FuSa\",\n" + " \"toolVersion\": \"" CFUSA_VERSION_STRING "\",\n" + " \"language\": \"c\",\n" + " \"generatedAt\": \"%s\",\n" + " \"project\": \"%s\",\n" + " \"standard\": \"%s\",\n", + ts, doc.project, doc.standard); + + fprintf(out, " \"operationalSituations\": [\n"); + for (int i = 0; i < doc.situations_count; i++) { + char esc[256]; cfusa_str_escape_json(doc.situations[i].description, esc, sizeof(esc)); + fprintf(out, " {\"id\": \"%s\", \"description\": \"%s\"}%s\n", + doc.situations[i].id, esc, (i < doc.situations_count - 1) ? "," : ""); } + fprintf(out, " ],\n"); + + fprintf(out, " \"hazards\": [\n"); + for (int i = 0; i < doc.hazards_count; i++) { + hazard_entry_t *h = &doc.hazards[i]; + char esc[256]; cfusa_str_escape_json(h->description, esc, sizeof(esc)); + fprintf(out, " {\"id\": \"%s\", \"description\": \"%s\", \"risk\": " + "{\"severity\": \"%s\", \"exposure\": \"%s\", \"controllability\": \"%s\", " + "\"asil\": \"%s\"}}%s\n", + h->id, esc, h->severity, h->exposure, h->controllability, h->asil, + (i < doc.hazards_count - 1) ? "," : ""); + } + fprintf(out, " ],\n"); + + fprintf(out, " \"safetyGoals\": [\n"); + for (int i = 0; i < doc.goals_count; i++) { + safety_goal_entry_t *g = &doc.goals[i]; + char esc[256]; cfusa_str_escape_json(g->description, esc, sizeof(esc)); + fprintf(out, " {\"id\": \"%s\", \"description\": \"%s\", \"asil\": \"%s\", \"fssrRefs\": [", + g->id, esc, g->asil); + for (int k = 0; k < g->fssr_refs_count; k++) + fprintf(out, "%s\"%s\"", k ? ", " : "", g->fssr_refs[k]); + fprintf(out, "]}%s\n", (i < doc.goals_count - 1) ? "," : ""); + } + fprintf(out, " ],\n"); + + fprintf(out, + " \"completeness\": {\n" + " \"totalHazards\": %d, \"hazardsWithAsil\": %d, \"hazardsWithSafetyGoal\": %d,\n" + " \"safetyGoalsWithFssrRefs\": %d, \"danglingReferences\": %d\n" + " }\n" + "}\n", + total_hazards, hazards_with_asil, hazards_with_sg, goals_with_fssr, dangling); + + /* Quality-bar scan drives the exit code but is not re-printed as JSON + * members here (this document mirrors the x-FuSa spec §9.2 shape + * verbatim); it still gates like `show` (text) does. */ + int gate = run_quality_bar(dir, &doc, require_attestation, stderr, 1); + + free(content); + return gate; } int cmd_hara(int argc, char **argv) @@ -281,15 +774,18 @@ int cmd_hara(int argc, char **argv) const char *format = "text"; const char *output = NULL; int s = -1, e = -1, c = -1; + int strict = 0, require_attestation = 0; static const struct option long_opts[] = { - {"dir", required_argument, NULL, 'd'}, - {"format", required_argument, NULL, 'F'}, - {"output", required_argument, NULL, 'o'}, - {"severity", required_argument, NULL, 's'}, - {"exposure", required_argument, NULL, 'e'}, - {"controllability",required_argument, NULL, 'c'}, - {"help", no_argument, NULL, 'h'}, + {"dir", required_argument, NULL, 'd'}, + {"format", required_argument, NULL, 'F'}, + {"output", required_argument, NULL, 'o'}, + {"severity", required_argument, NULL, 's'}, + {"exposure", required_argument, NULL, 'e'}, + {"controllability", required_argument, NULL, 'c'}, + {"strict", no_argument, NULL, 'S'}, + {"require-attestation", no_argument, NULL, 'A'}, + {"help", no_argument, NULL, 'h'}, {NULL,0,NULL,0} }; @@ -302,7 +798,7 @@ int cmd_hara(int argc, char **argv) int opt; optind = 1; - while ((opt = getopt_long(argc, argv, "d:F:o:s:e:c:h", long_opts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "d:F:o:s:e:c:SAh", long_opts, NULL)) != -1) { switch (opt) { case 'd': dir = optarg; break; case 'F': format = optarg; break; @@ -310,15 +806,19 @@ int cmd_hara(int argc, char **argv) case 's': { const char *v = optarg; if (v[0]=='S'||v[0]=='s') v++; s = atoi(v); break; } case 'e': { const char *v = optarg; if (v[0]=='E'||v[0]=='e') v++; e = atoi(v); break; } case 'c': { const char *v = optarg; if (v[0]=='C'||v[0]=='c') v++; c = atoi(v); break; } + case 'S': strict = 1; break; + case 'A': require_attestation = 1; break; case 'h': printf("Usage: cfusa hara [options]\n\n" "Subcommands:\n" " init Write a .fusa-hara.json skeleton\n" - " show Display all hazard entries with ASIL rating\n" + " show Validate + report all hazard/safety-goal entries\n" " asil Compute ASIL from S/E/C parameters\n\n" "Options for 'show':\n" " --format text|json|markdown Output format (default: text)\n" - " --output Write output to file (default: stdout)\n\n" + " --output Write output to file (default: stdout)\n" + " --strict Implies --require-attestation\n" + " --require-attestation Escalate an unsuppressed FUSA-STUB002 to exit 1\n\n" "Options for 'asil':\n" " --severity N Severity class S0-S3 (0-3, per ISO 26262-3 Table 4)\n" " --exposure N Exposure class E0-E4 (0-4)\n" @@ -328,35 +828,37 @@ int cmd_hara(int argc, char **argv) default: return 2; } } + if (strict) require_attestation = 1; cfusa_config_t cfg; cfusa_config_load(dir, &cfg); if (!strcmp(subcmd, "init")) { - return do_init(dir, cfg.project, cfg.version); + return do_init(dir, cfg.project); } else if (!strcmp(subcmd, "asil")) { if (s < 0 || e < 0 || c < 0) { fprintf(stderr, "cfusa hara asil: requires --severity, --exposure, --controllability\n"); return 2; } do_asil(s, e, c); + return 0; } else if (!strcmp(subcmd, "show")) { FILE *out = stdout; if (output) { - out = fopen(output, "w"); + out = cfusa_fopen_write(output); if (!out) { perror(output); return 3; } } + int rc; if (!strcmp(format, "json")) - do_show_json(dir, out); - else if (!strcmp(format, "markdown") || !strcmp(format, "md")) - do_show_md(dir, out); + rc = do_show_json(dir, out, require_attestation); else - do_show(dir, out); + rc = do_show(dir, out, require_attestation); + /* markdown output not yet formalized for the new schema; fall back + * to the text report rather than emit stale field names. */ if (output && out != stdout) fclose(out); + return rc; } else { fprintf(stderr, "cfusa hara: unknown subcommand '%s' (init|show|asil)\n", subcmd); return 2; } - - return 0; } diff --git a/cmd/cfusa/cmd_safety_case.c b/cmd/cfusa/cmd_safety_case.c index 42464dc..cdf3474 100644 --- a/cmd/cfusa/cmd_safety_case.c +++ b/cmd/cfusa/cmd_safety_case.c @@ -1,119 +1,329 @@ +/* + * cfusa safety-case — GSN (Goal Structuring Notation) safety-case argument, + * per the GSN Community Standard (Assurance Case Working Group, v3, 2021), + * x-FuSa spec §9.2. + * + * `--format json` writes safety-case.json: nodes[]/edges[]/completeness per + * the six real GSN node types (goal/strategy/solution/context/assumption/ + * justification). A `solution` node only cites `evidence` for a file that + * actually exists in the project — a claimed-but-absent evidence file is + * worse than an honestly-missing solution (x-FuSa spec §9.2), and a goal + * with no supporting chain is counted in `completeness.undeveloped` rather + * than silently omitted. + */ #include +#include #include #include #include "cfusa/config.h" +#include "cfusa/qualitybar.h" #include "cfusa/utils.h" +#include "cfusa/version.h" -//cfusa:req REQ-SC001 +//cfusa:req REQ-SC001 REQ-SC002 REQ-SC003 -/* - * Generates a GSN (Goal Structuring Notation) safety case skeleton - * and assembles available evidence into a safety case index. - */ +typedef struct { + const char *id, *type, *text, *evidence; /* evidence: NULL when not a solution */ + int has_evidence_file; /* only meaningful for type "solution" */ +} gsn_node_t; + +typedef struct { const char *from, *to, *type; } gsn_edge_t; + +#define MAX_NODES 16 +#define MAX_EDGES 16 int cmd_safety_case(int argc, char **argv) { const char *dir = "."; - const char *output = "safety-case.md"; + const char *output = NULL; + const char *fmt_s = NULL; /* NULL -> markdown (legacy default output name) */ const char *standard = NULL; - int gsn_only = 0; + const char *attest = NULL; + int gsn_only = 0, strict = 0, require_attestation = 0; static const struct option long_opts[] = { - {"dir", required_argument, NULL, 'd'}, - {"output", required_argument, NULL, 'o'}, - {"standard", required_argument, NULL, 'S'}, - {"gsn", no_argument, NULL, 'g'}, - {"help", no_argument, NULL, 'h'}, + {"dir", required_argument, NULL, 'd'}, + {"output", required_argument, NULL, 'o'}, + {"format", required_argument, NULL, 'f'}, + {"standard", required_argument, NULL, 'S'}, + {"gsn", no_argument, NULL, 'g'}, + {"strict", no_argument, NULL, 's'}, + {"require-attestation", no_argument, NULL, 'A'}, + {"attest", required_argument, NULL, 'T'}, + {"help", no_argument, NULL, 'h'}, {NULL,0,NULL,0} }; int c; optind = 1; - while ((c = getopt_long(argc, argv, "d:o:S:gh", long_opts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "d:o:f:S:gsAT:h", long_opts, NULL)) != -1) { switch (c) { case 'd': dir = optarg; break; case 'o': output = optarg; break; + case 'f': fmt_s = optarg; break; case 'S': standard = optarg; break; case 'g': gsn_only = 1; break; + case 's': strict = 1; break; + case 'A': require_attestation = 1; break; + case 'T': attest = optarg; break; case 'h': printf("Usage: cfusa safety-case [--dir ] [--output safety-case.md]\n" + " [--format md|json] [--gsn]\n" " [--standard iso26262|do178c|iec61508|iso21434|unece-r155]\n" - " [--gsn]\n\n" - "Generates a GSN safety case skeleton with evidence index.\n"); + " [--strict] [--require-attestation] [--attest ]\n\n" + "Generates a GSN safety case (GSN Community Standard v3).\n" + "--format json writes safety-case.json (nodes/edges/completeness).\n" + "Default (no --format) writes the markdown safety-case + evidence index.\n"); return 0; default: return 2; } } + if (strict) require_attestation = 1; cfusa_config_t cfg; cfusa_config_load(dir, &cfg); if (!standard) standard = cfg.standards_count ? cfg.standards[0] : "iso26262"; + char ts[32]; cfusa_timestamp_now(ts); + + /* Evidence files this safety case can cite — only ever cited when they + * actually exist (x-FuSa spec §9.2 "real referents only"). */ + struct { const char *name; int present; } ev_hara = {"hara.md", 0}, + ev_check = {"cfusa-self-check.json", 0}, ev_fmea = {"fmea.json", 0}, + ev_tara = {"tara.json", 0}, ev_qualify = {"qualify-report.json", 0}, + ev_sci = {"sci.json", 0}; + struct { const char *name; int *present; } evs[] = { + {ev_hara.name, &ev_hara.present}, {ev_check.name, &ev_check.present}, + {ev_fmea.name, &ev_fmea.present}, {ev_tara.name, &ev_tara.present}, + {ev_qualify.name, &ev_qualify.present}, {ev_sci.name, &ev_sci.present}, + }; + for (size_t i = 0; i < sizeof(evs)/sizeof(evs[0]); i++) { + char p[512]; cfusa_path_join(p, sizeof(p), dir, evs[i].name); + *evs[i].present = cfusa_file_exists(p); + } + + char g1_text[384], c1_text[256], g11_text[320], g12_text[320], a1_text[256]; + snprintf(g1_text, sizeof(g1_text), + "%s v%s has no unmitigated hazard from .fusa-hara.json and no unresolved " + "ERROR finding from `cfusa check` at the %s analysis boundary", + cfg.project, cfg.version, standard); + snprintf(c1_text, sizeof(c1_text), + "Scope: %s source under \"%s\", analyzed against %s by c-FuSa v%s", + cfg.project, dir, standard, CFUSA_VERSION_STRING); + snprintf(g11_text, sizeof(g11_text), + "Every hazard recorded in .fusa-hara.json is eliminated or controlled to its " + "assigned ASIL (ISO 26262-3 Clause 6)"); + snprintf(g12_text, sizeof(g12_text), + "The %s development process gives justified confidence: static analysis, FMEA/TARA, " + "and tool qualification evidence are current", cfg.project); + snprintf(a1_text, sizeof(a1_text), + "The underlying hardware/platform on which %s runs meets its own safety requirements " + "independently of this software safety case", cfg.project); + + gsn_node_t nodes[MAX_NODES]; + int nn = 0; + nodes[nn++] = (gsn_node_t){"G1", "goal", g1_text, NULL, 0}; + nodes[nn++] = (gsn_node_t){"St1", "strategy", "Argue over hazard elimination and process confidence separately", NULL, 0}; + nodes[nn++] = (gsn_node_t){"C1", "context", c1_text, NULL, 0}; + nodes[nn++] = (gsn_node_t){"A1", "assumption", a1_text, NULL, 0}; + nodes[nn++] = (gsn_node_t){"G1.1","goal", g11_text, NULL, 0}; + nodes[nn++] = (gsn_node_t){"G1.2","goal", g12_text, NULL, 0}; + if (ev_hara.present) + nodes[nn++] = (gsn_node_t){"Sn1", "solution", "Hazard analysis and risk assessment", "hara.md", 1}; + if (ev_check.present) + nodes[nn++] = (gsn_node_t){"Sn2", "solution", "Static analysis / lint / cyber self-check results", "cfusa-self-check.json", 1}; + if (ev_fmea.present) + nodes[nn++] = (gsn_node_t){"Sn3", "solution", "Design FMEA", "fmea.json", 1}; + if (ev_tara.present) + nodes[nn++] = (gsn_node_t){"Sn4", "solution", "Threat analysis and risk assessment", "tara.json", 1}; + if (ev_qualify.present) + nodes[nn++] = (gsn_node_t){"Sn5", "solution", "Tool qualification record", "qualify-report.json", 1}; + + gsn_edge_t edges[MAX_EDGES]; + int ne = 0; + edges[ne++] = (gsn_edge_t){"G1", "St1", "supportedBy"}; + edges[ne++] = (gsn_edge_t){"G1", "C1", "inContextOf"}; + edges[ne++] = (gsn_edge_t){"St1", "A1", "inContextOf"}; + edges[ne++] = (gsn_edge_t){"St1", "G1.1", "supportedBy"}; + edges[ne++] = (gsn_edge_t){"St1", "G1.2", "supportedBy"}; + if (ev_hara.present) edges[ne++] = (gsn_edge_t){"G1.1", "Sn1", "supportedBy"}; + if (ev_check.present) edges[ne++] = (gsn_edge_t){"G1.2", "Sn2", "supportedBy"}; + if (ev_fmea.present) edges[ne++] = (gsn_edge_t){"G1.2", "Sn3", "supportedBy"}; + if (ev_tara.present) edges[ne++] = (gsn_edge_t){"G1.2", "Sn4", "supportedBy"}; + if (ev_qualify.present) edges[ne++] = (gsn_edge_t){"G1.2", "Sn5", "supportedBy"}; + + int total_goals = 0, goals_with_evidence = 0, undeveloped = 0; + for (int i = 0; i < nn; i++) { + if (strcmp(nodes[i].type, "goal") != 0) continue; + total_goals++; + int has_child = 0, has_solution = 0; + for (int k = 0; k < ne; k++) { + if (strcmp(edges[k].from, nodes[i].id) != 0) continue; + if (strcmp(edges[k].type, "supportedBy") != 0) continue; + has_child = 1; + for (int j = 0; j < nn; j++) + if (strcmp(nodes[j].id, edges[k].to) == 0 && strcmp(nodes[j].type, "solution") == 0) + has_solution = 1; + } + if (has_solution) goals_with_evidence++; + if (!has_child) undeveloped++; + } + + /* ---- canonical content hash + quality-bar scan ---- */ + char canonical[8192]; + size_t off = 0; + off += (size_t)snprintf(canonical + off, sizeof(canonical) - off, "{\"edges\":["); + for (int i = 0; i < ne; i++) + off += (size_t)snprintf(canonical + off, off < sizeof(canonical) ? sizeof(canonical) - off : 0, + "%s{\"from\":\"%s\",\"to\":\"%s\",\"type\":\"%s\"}", + i ? "," : "", edges[i].from, edges[i].to, edges[i].type); + off += (size_t)snprintf(canonical + off, off < sizeof(canonical) ? sizeof(canonical) - off : 0, "],\"nodes\":["); + for (int i = 0; i < nn; i++) { + char esc[512]; + cfusa_str_escape_json(nodes[i].text, esc, sizeof(esc)); + if (nodes[i].evidence) + off += (size_t)snprintf(canonical + off, off < sizeof(canonical) ? sizeof(canonical) - off : 0, + "%s{\"evidence\":\"%s\",\"id\":\"%s\",\"text\":\"%s\",\"type\":\"%s\"}", + i ? "," : "", nodes[i].evidence, nodes[i].id, esc, nodes[i].type); + else + off += (size_t)snprintf(canonical + off, off < sizeof(canonical) ? sizeof(canonical) - off : 0, + "%s{\"id\":\"%s\",\"text\":\"%s\",\"type\":\"%s\"}", + i ? "," : "", nodes[i].id, esc, nodes[i].type); + } + off += (size_t)snprintf(canonical + off, off < sizeof(canonical) ? sizeof(canonical) - off : 0, "]}"); + if (off >= sizeof(canonical)) off = sizeof(canonical) - 1; + + char fresh_hash[80]; + cfusa_qb_content_hash(canonical, off, fresh_hash); + + char existing_path[512]; + cfusa_path_join(existing_path, sizeof(existing_path), dir, "safety-case.json"); + size_t existing_len = 0; + char *existing_json = cfusa_read_file(existing_path, &existing_len); + cfusa_attestation_t attestation; + if (existing_json) cfusa_qb_attestation_read(existing_json, existing_len, &attestation); + else memset(&attestation, 0, sizeof(attestation)); + free(existing_json); + + if (attest) { + attestation.present = 1; + strncpy(attestation.status, "reviewed", sizeof(attestation.status) - 1); + strncpy(attestation.implementation_author, "auto", sizeof(attestation.implementation_author) - 1); + strncpy(attestation.independent_reviewer, attest, sizeof(attestation.independent_reviewer) - 1); + strncpy(attestation.reviewed_at, ts, sizeof(attestation.reviewed_at) - 1); + strncpy(attestation.content_hash, fresh_hash, sizeof(attestation.content_hash) - 1); + } + + const char *node_texts[MAX_NODES]; + for (int i = 0; i < nn; i++) node_texts[i] = nodes[i].text; + int rule_a_hits = 0; + for (int i = 0; i < nn; i++) if (cfusa_qb_is_stub_text(nodes[i].text)) rule_a_hits++; + int rule_a_disposed = rule_a_hits > 0 && cfusa_qb_rule_disposed(dir, CFUSA_QB_RULE_A); + if (rule_a_hits > 0) + fprintf(stderr, "cfusa safety-case: %s: %d node(s) with placeholder-looking text%s\n", + CFUSA_QB_RULE_A, rule_a_hits, rule_a_disposed ? " (disposed)" : ""); + int rule_b = cfusa_qb_rule_b_flagged(node_texts, nn); + int reviewed = 0; + if (rule_b) { + reviewed = cfusa_qb_attestation_valid(&attestation, fresh_hash); + fprintf(stderr, "cfusa safety-case: %s: node text shows low distinct-value ratio%s\n", + CFUSA_QB_RULE_B, reviewed ? " (suppressed by a valid attestation)" : ""); + } + int attestation_valid = cfusa_qb_attestation_valid(&attestation, fresh_hash); + int qb_gate = (rule_a_hits > 0 && !rule_a_disposed) ? 1 + : (require_attestation && rule_b && !reviewed) ? 1 : 0; + + /* ---- JSON output ---- */ + if (fmt_s && !strcmp(fmt_s, "json")) { + char out_path[512]; + if (output) { + if (output[0] == '/') strncpy(out_path, output, sizeof(out_path) - 1); + else cfusa_path_join(out_path, sizeof(out_path), dir, output); + } else { + cfusa_path_join(out_path, sizeof(out_path), dir, "safety-case.json"); + } + FILE *f = cfusa_fopen_write(out_path); + if (!f) { perror(out_path); return 3; } + + fprintf(f, + "{\n" + " \"schemaVersion\": \"" CFUSA_SCHEMA_VERSION "\",\n" + " \"kind\": \"safety-case\",\n" + " \"tool\": \"c-FuSa\",\n" + " \"toolVersion\": \"" CFUSA_VERSION_STRING "\",\n" + " \"language\": \"c\",\n" + " \"generatedAt\": \"%s\",\n" + " \"project\": \"%s\",\n" + " \"standard\": \"%s\",\n" + " \"nodes\": [\n", + ts, cfg.project, standard); + for (int i = 0; i < nn; i++) { + char esc[512]; + cfusa_str_escape_json(nodes[i].text, esc, sizeof(esc)); + if (nodes[i].evidence) + fprintf(f, " {\"id\": \"%s\", \"type\": \"%s\", \"text\": \"%s\", \"evidence\": \"%s\"}%s\n", + nodes[i].id, nodes[i].type, esc, nodes[i].evidence, (i < nn - 1) ? "," : ""); + else + fprintf(f, " {\"id\": \"%s\", \"type\": \"%s\", \"text\": \"%s\"}%s\n", + nodes[i].id, nodes[i].type, esc, (i < nn - 1) ? "," : ""); + } + fprintf(f, " ],\n \"edges\": [\n"); + for (int i = 0; i < ne; i++) + fprintf(f, " {\"from\": \"%s\", \"to\": \"%s\", \"type\": \"%s\"}%s\n", + edges[i].from, edges[i].to, edges[i].type, (i < ne - 1) ? "," : ""); + fprintf(f, " ],\n \"completeness\": {\n" + " \"totalGoals\": %d, \"goalsWithEvidence\": %d, \"undeveloped\": %d\n" + " }", + total_goals, goals_with_evidence, undeveloped); + if (attestation_valid) { + fprintf(f, + ",\n \"attestation\": {\n" + " \"status\": \"reviewed\",\n" + " \"implementationAuthor\": \"%s\",\n" + " \"independentReviewer\": \"%s\",\n" + " \"reviewedAt\": \"%s\",\n" + " \"contentHash\": \"%s\"\n" + " }\n", + attestation.implementation_author, attestation.independent_reviewer, + attestation.reviewed_at, attestation.content_hash); + } else { + fprintf(f, "\n"); + } + fprintf(f, "}\n"); + fclose(f); + printf("Safety case written to %s\n", out_path); + return qb_gate; + } + + /* ---- Markdown output (default, legacy filename) ---- */ char out_path[512]; - if (output[0]=='/') strncpy(out_path,output,sizeof(out_path)-1); - else cfusa_path_join(out_path,sizeof(out_path),dir,output); + const char *out_name = output ? output : "safety-case.md"; + if (out_name[0]=='/') strncpy(out_path,out_name,sizeof(out_path)-1); + else cfusa_path_join(out_path,sizeof(out_path),dir,out_name); - FILE *f = fopen(out_path,"w"); + FILE *f = cfusa_fopen_write(out_path); if (!f) { perror(out_path); return 3; } - char ts[32]; cfusa_timestamp_now(ts); - - fprintf(f, - "# Safety Case — %s v%s\n\n" - "**Standard:** %s | **Generated:** %s\n\n" - "---\n\n" - "## G1 — Top-Level Goal\n\n" - "> **%s is acceptably safe for its intended use in its intended environment**\n\n" - "### Evidence for G1\n\n" - "| Evidence Item | Source | Status |\n|---|---|---|\n" - "| Hazard analysis complete | hara.md | [ ] |\n" - "| Safety requirements defined | safety-plan.md | [ ] |\n" - "| MISRA-C lint clean | cfusa lint | [ ] |\n" - "| Static analysis clean | cfusa analyze | [ ] |\n" - "| Cybersecurity analysis complete | cfusa cyber / tara.md | [ ] |\n" - "| Test evidence complete | cfusa verify | [ ] |\n" - "| Coverage targets met | cfusa coverage | [ ] |\n" - "| FMEA complete | fmea.md | [ ] |\n" - "| Tool qualification | cfusa qualify | [ ] |\n" - "| SCI produced | cfusa sci | [ ] |\n\n" - "---\n\n" - "## G1.1 — Hazard Elimination\n\n" - "> **All identified hazards are either eliminated or controlled to an acceptable level**\n\n" - "- Context: C1 — Operating environment is [describe]\n" - "- Strategy: S1 — Argue over identified hazardous events\n\n" - "### G1.1 Sub-goals\n\n" - "| ID | Sub-goal | Evidence |\n|---|---|---|\n" - "| G1.1.1 | Hazardous event HE-001 risk is [ASIL] or below | hara.md §2 |\n" - "| G1.1.2 | Software contributes no additional hazards | cfusa check (exit 0) |\n\n" - "---\n\n" - "## G1.2 — Process Confidence\n\n" - "> **The software development process is sufficient to give confidence in the result**\n\n" - "- S2 — Argue over process compliance\n\n" - "| ID | Sub-goal | Evidence |\n|---|---|---|\n" - "| G1.2.1 | Coding standard followed | cfusa lint (exit 0) |\n" - "| G1.2.2 | Requirements traced to code | cfusa trace |\n" - "| G1.2.3 | Test coverage meets threshold | cfusa coverage |\n" - "| G1.2.4 | All PRs resolved | cfusa pr --status open |\n\n" - "---\n\n" - "## Assumptions\n\n" - "- A1: The hardware is assumed safe as per [HW safety case reference]\n" - "- A2: The operating environment is as described in [SRS reference]\n\n" - "---\n\n" - "_Safety case owner: [name / role]_ \n" - "_Last reviewed: [date]_ \n" - "_Next review: [date]_\n", - cfg.project, cfg.version, standard, ts, cfg.project); + fprintf(f, "# Safety Case — %s v%s\n\n", cfg.project, cfg.version); + fprintf(f, "**Standard:** %s | **Generated:** %s\n\n---\n\n", standard, ts); + for (int i = 0; i < nn; i++) { + fprintf(f, "## %s — %s\n\n> %s\n\n", nodes[i].id, nodes[i].type, nodes[i].text); + if (nodes[i].evidence) + fprintf(f, "Evidence: `%s`\n\n", nodes[i].evidence); + } + fprintf(f, "---\n\n## Argument Structure\n\n| From | To | Relation |\n|---|---|---|\n"); + for (int i = 0; i < ne; i++) + fprintf(f, "| %s | %s | %s |\n", edges[i].from, edges[i].to, edges[i].type); + fprintf(f, "\n_Completeness: %d goal(s), %d with cited evidence, %d undeveloped._\n", + total_goals, goals_with_evidence, undeveloped); if (!gsn_only) { - /* Check for existing evidence files */ - fprintf(f, "\n---\n\n## Evidence Index\n\n" - "| File | Present | SHA-256 |\n|---|---|---|\n"); + fprintf(f, "\n---\n\n## Evidence Index\n\n| File | Present | SHA-256 |\n|---|---|---|\n"); static const char * const evidence_files[] = { "hara.md","safety-plan.md","tara.md","fmea.md", "test-evidence.md","sas.md",".fusa.json",NULL }; - /* ISO 21434 / UN R.155 extra evidence */ static const char * const cyber_evidence[] = { "tara.json","vuln-report.json","cfusa-self-check.json", "cyber-plan.json","provenance.json",NULL @@ -128,9 +338,9 @@ int cmd_safety_case(int argc, char **argv) if (cfusa_file_exists(ep)) { char hex[65]; cfusa_sha256_file(ep, hex); - fprintf(f,"| %s | ✓ | `%s` |\n", evidence_files[i], hex); + fprintf(f,"| %s | present | `%s` |\n", evidence_files[i], hex); } else { - fprintf(f,"| %s | ✗ (missing) | — |\n", evidence_files[i]); + fprintf(f,"| %s | absent | — |\n", evidence_files[i]); } } if (extra) { @@ -140,9 +350,9 @@ int cmd_safety_case(int argc, char **argv) if (cfusa_file_exists(ep)) { char hex[65]; cfusa_sha256_file(ep, hex); - fprintf(f,"| %s | ✓ | `%s` |\n", extra[i], hex); + fprintf(f,"| %s | present | `%s` |\n", extra[i], hex); } else { - fprintf(f,"| %s | ✗ (missing) | — |\n", extra[i]); + fprintf(f,"| %s | absent | — |\n", extra[i]); } } } @@ -150,5 +360,5 @@ int cmd_safety_case(int argc, char **argv) fclose(f); printf("Safety case written to %s\n", out_path); - return 0; + return qb_gate; } diff --git a/cmd/cfusa/cmd_safety_rules.c b/cmd/cfusa/cmd_safety_rules.c index 0d4536c..b975aa5 100644 --- a/cmd/cfusa/cmd_safety_rules.c +++ b/cmd/cfusa/cmd_safety_rules.c @@ -43,6 +43,72 @@ static char *read_file_at(const char *dir, const char *name, size_t *out_len) return cfusa_read_file(path, out_len); } +/* Finds the balanced `open`...`close` substring for the first `"key"` at or + * after `from` (string-aware, so a literal delimiter inside a quoted value + * doesn't miscount depth). Sets *end_after to just past the closing + * delimiter and returns a pointer to the opening delimiter, or NULL. Used + * to scope a scan to (e.g.) .fusa-hara.json's "hazards": [...] array so it + * doesn't also match "id"/"asil" fields belonging to the sibling + * operationalSituations[]/safetyGoals[] collections (x-FuSa spec §1.2.5). */ +static const char *json_bracket(const char *from, const char *key, + char open, char close, const char **end_after) +{ + char pat[64]; + snprintf(pat, sizeof(pat), "\"%s\"", key); + const char *p = strstr(from, pat); + if (!p) return NULL; + p = strchr(p + strlen(pat), open); + if (!p) return NULL; + + int depth = 0, in_str = 0; + const char *start = p; + for (; *p; p++) { + if (in_str) { + if (*p == '\\') { p++; continue; } + if (*p == '"') in_str = 0; + continue; + } + if (*p == '"') { in_str = 1; continue; } + if (*p == open) depth++; + else if (*p == close) { + depth--; + if (depth == 0) { if (end_after) *end_after = p + 1; return start; } + } + } + return NULL; +} + +/* Extracts a quoted string field's value from `block` (bounded at `blk_end`). */ +static void json_str_field(const char *block, const char *blk_end, const char *key, + char *out, size_t out_sz) +{ + out[0] = '\0'; + char pat[64]; + snprintf(pat, sizeof(pat), "\"%s\":", key); + const char *fp = strstr(block, pat); + if (!fp || (blk_end && fp >= blk_end)) return; + fp += strlen(pat); + while (*fp == ' ' || *fp == '\t' || *fp == '\n') fp++; + if (*fp != '"') return; + fp++; + size_t k = 0; + while (*fp && *fp != '"' && k < out_sz - 1) { + if (*fp == '\\' && fp[1]) fp++; + out[k++] = *fp++; + } + out[k] = '\0'; +} + +/* Parses a "Sx"/"Ex"/"Cx" (or bare "x") risk code into an integer, -1 when + * absent/unparseable. Mirrors cmd_hara.c's parse_sec_code(). */ +static int json_sec_code(const char *v) +{ + if (!v || !*v) return -1; + if (isalpha((unsigned char)v[0])) v++; + if (!*v) return -1; + return atoi(v); +} + /* ── HARA001 — .fusa-hara.json must be present ───────────────────────── */ static int rule_hara001(const char *dir, const cfusa_config_t *cfg, @@ -70,33 +136,49 @@ static int rule_hara002(const char *dir, const cfusa_config_t *cfg, if (!json) json = read_file_at(dir, ".cfusa-hara.json", &len); if (!json) return 0; /* HARA001 already fired */ + /* x-FuSa spec §1.2.5: risk ratings live in each hazard's nested "risk" + * object as "Sx"/"Ex"/"Cx" strings, not flat integer fields — and the + * scan MUST be scoped to the "hazards" array so it doesn't also walk + * the sibling operationalSituations[]/safetyGoals[] collections' + * unrelated "id" entries. */ + const char *hz_end = NULL; + const char *hz_start = json_bracket(json, "hazards", '[', ']', &hz_end); + int findings = 0; - const char *p = json; - while ((p = strstr(p, "\"id\"")) != NULL) { - char id[64] = ""; int sev = -1, exp = -1, ctl = -1; - const char *blk = p; - const char *end = strstr(blk + 1, "\"id\""); - if (!end) end = json + len; + if (hz_start) { + const char *p = hz_start; + while ((p = strstr(p, "\"id\"")) != NULL && p < hz_end) { + char id[64] = ""; + const char *blk = p; + const char *blk_end = strstr(blk + 1, "\"id\""); + if (!blk_end || blk_end > hz_end) blk_end = hz_end; + + json_str_field(blk, blk_end, "id", id, sizeof(id)); + + const char *risk_end = NULL; + const char *risk = json_bracket(blk, "risk", '{', '}', &risk_end); + int sev = -1, exp = -1, ctl = -1; + if (risk && risk < blk_end) { + char sevs[8] = "", exps[8] = "", ctls[8] = ""; + json_str_field(risk, risk_end, "severity", sevs, sizeof(sevs)); + json_str_field(risk, risk_end, "exposure", exps, sizeof(exps)); + json_str_field(risk, risk_end, "controllability", ctls, sizeof(ctls)); + sev = json_sec_code(sevs); + exp = json_sec_code(exps); + ctl = json_sec_code(ctls); + } - { char *fp = strstr(blk, "\"id\":"); - if (fp) { fp += 5; while (*fp==' ') fp++; if (*fp=='"') fp++; - sscanf(fp, "%63[^\"]", id); } } - { char *fp = strstr(blk, "\"severity\":"); - if (fp && fp < end) sscanf(fp, "\"severity\": %d", &sev); } - { char *fp = strstr(blk, "\"exposure\":"); - if (fp && fp < end) sscanf(fp, "\"exposure\": %d", &exp); } - { char *fp = strstr(blk, "\"controllability\":"); - if (fp && fp < end) sscanf(fp, "\"controllability\": %d", &ctl); } - - if (id[0] && (sev <= 0 || exp <= 0 || ctl <= 0)) { - cfusa_report_add(rpt, "HARA002", "safety", SEV_ERROR, - ".fusa-hara.json", 0, - "hazard '%s' has incomplete risk rating (S=%d E=%d C=%d); " - "all must be > 0 (ISO 26262-3 Clause 6.4)", - id, sev, exp, ctl); - findings++; + if (id[0] && (sev < 0 || exp < 0 || ctl < 0)) { + cfusa_report_add(rpt, "HARA002", "safety", SEV_ERROR, + ".fusa-hara.json", 0, + "hazard '%s' has an incomplete risk rating (missing/unparseable " + "risk.severity/exposure/controllability); ISO 26262-3 Clause 6.4 " + "requires all three (x-FuSa spec §1.2.5)", + id); + findings++; + } + p = blk_end; } - p = end; } free(json); return findings; @@ -112,32 +194,42 @@ static int rule_hara003(const char *dir, const cfusa_config_t *cfg, if (!json) json = read_file_at(dir, ".cfusa-hara.json", &len); if (!json) return 0; + /* x-FuSa spec §1.2.5: a hazard's safety goal(s) live in its + * "safetyGoals": [...] reference array (>=1 entry required), not a + * single "safety_goal" string field — scoped to "hazards" for the same + * reason as HARA002. */ + const char *hz_end = NULL; + const char *hz_start = json_bracket(json, "hazards", '[', ']', &hz_end); + int findings = 0; - const char *p = json; - while ((p = strstr(p, "\"id\"")) != NULL) { - char id[64] = "", goal[256] = ""; - const char *blk = p; - const char *end = strstr(blk + 1, "\"id\""); - if (!end) end = json + len; + if (hz_start) { + const char *p = hz_start; + while ((p = strstr(p, "\"id\"")) != NULL && p < hz_end) { + char id[64] = ""; + const char *blk = p; + const char *blk_end = strstr(blk + 1, "\"id\""); + if (!blk_end || blk_end > hz_end) blk_end = hz_end; - { char *fp = strstr(blk, "\"id\":"); - if (fp) { fp += 5; while (*fp==' ') fp++; if (*fp=='"') fp++; - sscanf(fp, "%63[^\"]", id); } } - { char *fp = strstr(blk, "\"safety_goal\":"); - if (fp && fp < end) { - fp += 14; while (*fp==' ') fp++; - if (*fp=='"') fp++; - sscanf(fp, "%255[^\"]", goal); } } - - if (id[0] && (goal[0] == '\0' || - strncmp(goal, "[", 1) == 0 || - strstr(goal, "derive safety goal") != NULL)) { - cfusa_report_add(rpt, "HARA003", "safety", SEV_ERROR, - ".fusa-hara.json", 0, - "hazard '%s' has no safety goal — required by ISO 26262-3 §6.4.9", id); - findings++; + json_str_field(blk, blk_end, "id", id, sizeof(id)); + + const char *sg_end = NULL; + const char *sg = json_bracket(blk, "safetyGoals", '[', ']', &sg_end); + int has_goal = 0; + if (sg && sg < blk_end) { + for (const char *q = sg; q < sg_end; q++) + if (*q == '"') { has_goal = 1; break; } + } + + if (id[0] && !has_goal) { + cfusa_report_add(rpt, "HARA003", "safety", SEV_ERROR, + ".fusa-hara.json", 0, + "hazard '%s' has no safetyGoals reference — ISO 26262-3 §6.4.9 " + "requires every hazard to drive at least one safety goal " + "(x-FuSa spec §1.2.5)", id); + findings++; + } + p = blk_end; } - p = end; } free(json); return findings; @@ -145,42 +237,71 @@ static int rule_hara003(const char *dir, const cfusa_config_t *cfg, /* ── HARA004 — safety goals must have ASIL assigned ─────────────────── */ -static int rule_hara004(const char *dir, const cfusa_config_t *cfg, - cfusa_report_t *rpt) +/* Shared by rule_hara004: scans one already-bracket-scoped collection + * ("hazards", where asil lives nested in "risk", or "safetyGoals", where + * it's a direct field) for entries with a missing/placeholder asil. + * `search_from` lets the caller scope the collection lookup itself — the + * top-level "safetyGoals" collection must be searched for *after* the + * "hazards" array ends, since each hazard also carries its own nested + * "safetyGoals": [...] reference array under the same key name (x-FuSa + * spec §1.2.5). When `end_after` is non-NULL it receives a pointer just + * past this collection's closing bracket, for exactly that chaining. */ +static int hara004_scan(const char *json, const char *search_from, const char *collection_key, + int asil_is_nested, cfusa_report_t *rpt, const char **end_after) { - (void)cfg; - size_t len; char *json = read_file_at(dir, ".fusa-hara.json", &len); - if (!json) json = read_file_at(dir, ".cfusa-hara.json", &len); - if (!json) return 0; + const char *end = NULL; + const char *start = json_bracket(search_from ? search_from : json, collection_key, + '[', ']', &end); + if (end_after) *end_after = end; + if (!start) return 0; int findings = 0; - const char *p = json; - while ((p = strstr(p, "\"id\"")) != NULL) { + const char *p = start; + while ((p = strstr(p, "\"id\"")) != NULL && p < end) { char id[64] = "", asil[32] = ""; const char *blk = p; - const char *end = strstr(blk + 1, "\"id\""); - if (!end) end = json + len; - - { char *fp = strstr(blk, "\"id\":"); - if (fp) { fp += 5; while (*fp==' ') fp++; if (*fp=='"') fp++; - sscanf(fp, "%63[^\"]", id); } } - { char *fp = strstr(blk, "\"asil\":"); - if (fp && fp < end) { - fp += 7; while (*fp==' ') fp++; - if (*fp=='"') fp++; - sscanf(fp, "%31[^\"]", asil); } } + const char *blk_end = strstr(blk + 1, "\"id\""); + if (!blk_end || blk_end > end) blk_end = end; + + json_str_field(blk, blk_end, "id", id, sizeof(id)); + + if (asil_is_nested) { + const char *risk_end = NULL; + const char *risk = json_bracket(blk, "risk", '{', '}', &risk_end); + if (risk && risk < blk_end) + json_str_field(risk, risk_end, "asil", asil, sizeof(asil)); + } else { + json_str_field(blk, blk_end, "asil", asil, sizeof(asil)); + } if (id[0] && (asil[0] == '\0' || strcmp(asil, "TBD") == 0 || strcmp(asil, "unknown") == 0)) { cfusa_report_add(rpt, "HARA004", "safety", SEV_WARNING, ".fusa-hara.json", 0, - "hazard '%s' has undetermined ASIL '%s' — " + "'%s' has undetermined ASIL '%s' — " "must be QM, ASIL-A, B, C, or D (ISO 26262-3 §6.4.6)", id, asil[0] ? asil : "(empty)"); findings++; } - p = end; + p = blk_end; } + return findings; +} + +static int rule_hara004(const char *dir, const cfusa_config_t *cfg, + cfusa_report_t *rpt) +{ + (void)cfg; + size_t len; char *json = read_file_at(dir, ".fusa-hara.json", &len); + if (!json) json = read_file_at(dir, ".cfusa-hara.json", &len); + if (!json) return 0; + + /* x-FuSa spec §1.2.5: both hazards[].risk.asil and safetyGoals[].asil + * are MUST fields; operationalSituations[] carries no asil and is + * deliberately excluded from this scan. */ + const char *hz_end = NULL; + int findings = hara004_scan(json, json, "hazards", 1, rpt, &hz_end); + findings += hara004_scan(json, hz_end ? hz_end : json, "safetyGoals", 0, rpt, NULL); free(json); return findings; } diff --git a/cmd/cfusa/cmd_sas.c b/cmd/cfusa/cmd_sas.c index 63e4a6a..93f26a2 100644 --- a/cmd/cfusa/cmd_sas.c +++ b/cmd/cfusa/cmd_sas.c @@ -1,44 +1,92 @@ #include +#include #include #include #include "cfusa/config.h" +#include "cfusa/qualitybar.h" #include "cfusa/utils.h" #include "cfusa/version.h" //cfusa:req REQ-SAS001 REQ-SAS002 REQ-SAS-PREP001 REQ-SAS-STDOUT001 -/* Software Accomplishment Summary (DO-178C §11.20) */ +/* Software Accomplishment Summary (DO-178C §11.20), x-FuSa spec §9.3. + * + * `checklist[].present` reflects a real check for an expected evidence + * file under --dir, rather than a hardcoded "pending" regardless of + * project state — an empty `evidence` string is an honest "no single + * file produces this evidence" rather than a fabricated reference. */ typedef struct { const char *id; const char *description; const char *evidence_type; + const char *evidence_file; /* "" when no single file corresponds */ } sas_item_t; static const sas_item_t SAS_ITEMS[] = { - {"SAS-01", "System overview and SW functions", "Document"}, - {"SAS-02", "Software level (DAL)", "Document"}, - {"SAS-03", "Software development environment", "Tool qualification records"}, - {"SAS-04", "SW development process summary", "Process evidence"}, - {"SAS-05", "SW verification process summary", "Test evidence"}, - {"SAS-06", "SW configuration management process summary", "CM records"}, - {"SAS-07", "SW quality assurance process summary", "QA records"}, - {"SAS-08", "Compliance statement for each SW life cycle data item", "Traceability matrix"}, - {"SAS-09", "Problem reports status", "PR log"}, - {"SAS-10", "Changes and their classification", "Change log"}, - {"SAS-11", "Deviations from plans/standards", "Deviation records"}, - {"SAS-12", "Unresolved anomalies with justification", "Anomaly log"}, - {"SAS-13", "SW verification results", "Test reports"}, - {"SAS-14", "Structural coverage results", "Coverage report"}, - {"SAS-15", "Additional considerations (partitioning, etc.)", "Analysis report"}, - {"SAS-16", "Summary of test environment qualification", "Tool qual record"}, - {"SAS-17", "PSAC compliance", "PSAC cross-reference"}, - {"SAS-18", "PHAC data (if applicable)", "PHAC document"}, - {"SAS-19", "COTS components used", "COTS qualification data"}, - {"SAS-20", "SW configuration index", "SCI (cfusa sci)"}, - {NULL, NULL, NULL} + {"SAS-01", "System overview and SW functions", "Document", "README.md"}, + {"SAS-02", "Software level (DAL)", "Document", ".fusa.json"}, + {"SAS-03", "SW development environment", "Tool qualification records", "qualify-report.json"}, + {"SAS-04", "SW development process summary", "Process evidence", ""}, + {"SAS-05", "SW verification process summary", "Test evidence", "cfusa-self-check.json"}, + {"SAS-06", "SW configuration management process summary", "CM records", "sci.json"}, + {"SAS-07", "SW quality assurance process summary", "QA records", ""}, + {"SAS-08", "Compliance statement for each SW life cycle data item", "Traceability matrix", ""}, + {"SAS-09", "Problem reports status", "PR log", ""}, + {"SAS-10", "Changes and their classification", "Change log", "CHANGELOG.md"}, + {"SAS-11", "Deviations from plans/standards", "Deviation records", ""}, + {"SAS-12", "Unresolved anomalies with justification", "Anomaly log", ""}, + {"SAS-13", "SW verification results", "Test reports", "cfusa-self-check.json"}, + {"SAS-14", "Structural coverage results", "Coverage report", "coverage.info"}, + {"SAS-15", "Additional considerations (partitioning, etc.)", "Analysis report", ""}, + {"SAS-16", "Summary of test environment qualification", "Tool qual record", "qualify-report.json"}, + {"SAS-17", "PSAC compliance", "PSAC cross-reference", ""}, + {"SAS-18", "PHAC data (if applicable)", "PHAC document", ""}, + {"SAS-19", "COTS components used", "COTS qualification data", ""}, + {"SAS-20", "SW configuration index", "SCI (cfusa sci)", "sci.json"}, + {NULL, NULL, NULL, NULL} }; +static int item_present(const char *dir, const sas_item_t *it) +{ + if (!it->evidence_file[0]) return 0; + char p[512]; cfusa_path_join(p, sizeof(p), dir, it->evidence_file); + return cfusa_file_exists(p); +} + +static void render_sas_markdown(FILE *f, const char *dir, const cfusa_config_t *cfg, + const char *dal, const char *ts, const char *approver, + int present_count, int total) +{ + fprintf(f,"# Software Accomplishment Summary (SAS)\n\n" + "**Project:** %s v%s | **DAL:** %s | **Generated:** %s | **Standard:** DO-178C §11.20\n\n" + "| ID | Description | Evidence | Present |\n|---|---|---|---|\n", + cfg->project, cfg->version, dal, ts); + for (int i=0;SAS_ITEMS[i].id;i++) { + int present = item_present(dir, &SAS_ITEMS[i]); + fprintf(f,"| %s | %s | %s | %s |\n", + SAS_ITEMS[i].id, SAS_ITEMS[i].description, + SAS_ITEMS[i].evidence_file[0] ? SAS_ITEMS[i].evidence_file : "(none)", + present ? "yes" : "no"); + } + fprintf(f,"\n---\n_%d/%d present_ \n_Prepared by: %s_\n", present_count, total, approver); +} + +static size_t sas_canonical_content(const char *dir, char *buf, size_t bufsz) +{ + size_t off = 0; + off += (size_t)snprintf(buf + off, bufsz - off, "{\"checklist\":["); + for (int i = 0; SAS_ITEMS[i].id; i++) { + int present = item_present(dir, &SAS_ITEMS[i]); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + "%s{\"clause\":\"11.20\",\"evidence\":\"%s\",\"item\":\"%s\",\"present\":%s}", + i ? "," : "", SAS_ITEMS[i].evidence_file, SAS_ITEMS[i].description, + present ? "true" : "false"); + } + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, "]}"); + return off; +} + int cmd_sas(int argc, char **argv) { const char *dir = "."; @@ -46,40 +94,111 @@ int cmd_sas(int argc, char **argv) const char *fmt_s = "md"; const char *dal = "DAL-B"; const char *prepared_by = NULL; + const char *attest = NULL; + int strict = 0, require_attestation = 0; static const struct option long_opts[] = { - {"dir", required_argument, NULL, 'd'}, - {"output", required_argument, NULL, 'o'}, - {"format", required_argument, NULL, 'f'}, - {"dal", required_argument, NULL, 'D'}, - {"prepared-by", required_argument, NULL, 'P'}, - {"help", no_argument, NULL, 'h'}, + {"dir", required_argument, NULL, 'd'}, + {"output", required_argument, NULL, 'o'}, + {"format", required_argument, NULL, 'f'}, + {"dal", required_argument, NULL, 'D'}, + {"prepared-by", required_argument, NULL, 'P'}, + {"strict", no_argument, NULL, 'S'}, + {"require-attestation", no_argument, NULL, 'A'}, + {"attest", required_argument, NULL, 'T'}, + {"help", no_argument, NULL, 'h'}, {NULL,0,NULL,0} }; int c; optind = 1; - while ((c = getopt_long(argc, argv, "d:o:f:D:P:h", long_opts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "d:o:f:D:P:SAT:h", long_opts, NULL)) != -1) { switch (c) { case 'd': dir = optarg; break; case 'o': output = optarg; break; case 'f': fmt_s = optarg; break; case 'D': dal = optarg; break; case 'P': prepared_by = optarg; break; + case 'S': strict = 1; break; + case 'A': require_attestation = 1; break; + case 'T': attest = optarg; break; case 'h': printf("Usage: cfusa sas [--dir ] [--output sas.md]\n" " [--format md|text|json] [--dal DAL-A|B|C|D]\n" - " [--prepared-by ]\n\n" - "Generates a Software Accomplishment Summary skeleton (DO-178C §11.20).\n" - "Use --output - to write to stdout.\n"); + " [--prepared-by ]\n" + " [--strict] [--require-attestation] [--attest ]\n\n" + "Generates a Software Accomplishment Summary (DO-178C §11.20).\n" + "Use --output - to write to stdout.\n" + "A tool MUST also write sas.md (the human-readable companion); this command\n" + "does that whenever --format md/text is selected, and on request via --output.\n"); return 0; default: return 2; } } + if (strict) require_attestation = 1; cfusa_config_t cfg; cfusa_config_load(dir, &cfg); + char ts[32]; cfusa_timestamp_now(ts); + const char *approver = prepared_by ? prepared_by : "(unspecified)"; + + /* ---- quality bar + attestation ---- */ + char canonical[8192]; + size_t clen = sas_canonical_content(dir, canonical, sizeof(canonical)); + if (clen >= sizeof(canonical)) clen = sizeof(canonical) - 1; + char fresh_hash[80]; + cfusa_qb_content_hash(canonical, clen, fresh_hash); + + char existing_path[512]; + cfusa_path_join(existing_path, sizeof(existing_path), dir, "sas.json"); + size_t existing_len = 0; + char *existing_json = cfusa_read_file(existing_path, &existing_len); + cfusa_attestation_t attestation; + if (existing_json) cfusa_qb_attestation_read(existing_json, existing_len, &attestation); + else memset(&attestation, 0, sizeof(attestation)); + free(existing_json); + + if (attest) { + attestation.present = 1; + strncpy(attestation.status, "reviewed", sizeof(attestation.status) - 1); + strncpy(attestation.implementation_author, "auto", sizeof(attestation.implementation_author) - 1); + strncpy(attestation.independent_reviewer, attest, sizeof(attestation.independent_reviewer) - 1); + strncpy(attestation.reviewed_at, ts, sizeof(attestation.reviewed_at) - 1); + strncpy(attestation.content_hash, fresh_hash, sizeof(attestation.content_hash) - 1); + } + + const char *item_texts[64]; + int nitems = 0; + for (int i = 0; SAS_ITEMS[i].id; i++) item_texts[nitems++] = SAS_ITEMS[i].description; + int rule_a_hits = 0; + for (int i = 0; i < nitems; i++) if (cfusa_qb_is_stub_text(item_texts[i])) rule_a_hits++; + int rule_a_disposed = rule_a_hits > 0 && cfusa_qb_rule_disposed(dir, CFUSA_QB_RULE_A); + if (rule_a_hits > 0) + fprintf(stderr, "cfusa sas: %s: %d checklist item(s) with placeholder-looking text%s\n", + CFUSA_QB_RULE_A, rule_a_hits, rule_a_disposed ? " (disposed)" : ""); + int rule_b = cfusa_qb_rule_b_flagged(item_texts, nitems); + int reviewed = 0; + if (rule_b) { + reviewed = cfusa_qb_attestation_valid(&attestation, fresh_hash); + fprintf(stderr, "cfusa sas: %s: checklist item text shows low distinct-value ratio%s\n", + CFUSA_QB_RULE_B, reviewed ? " (suppressed by a valid attestation)" : ""); + } + int attestation_valid = cfusa_qb_attestation_valid(&attestation, fresh_hash); + int qb_gate = (rule_a_hits > 0 && !rule_a_disposed) ? 1 + : (require_attestation && rule_b && !reviewed) ? 1 : 0; + + int total = 0, present_count = 0; + for (int i = 0; SAS_ITEMS[i].id; i++) { + total++; + if (item_present(dir, &SAS_ITEMS[i])) present_count++; + } + + /* "--output without --format" is textually ambiguous here (unlike + * qualify's --output-implies-json convention, sas's default format is + * md, and md is also this tool's MUST-have human-readable companion — + * see §9.3), so --format is honored independently of --output. */ + /* "--output -" → stdout; otherwise resolve path relative to --dir */ FILE *f; int to_stdout = (output && output[0] == '-' && output[1] == '\0'); @@ -89,13 +208,10 @@ int cmd_sas(int argc, char **argv) } else { if (output[0] == '/') strncpy(out_path, output, sizeof(out_path) - 1); else cfusa_path_join(out_path, sizeof(out_path), dir, output); - f = fopen(out_path, "w"); + f = cfusa_fopen_write(out_path); if (!f) { perror(out_path); return 3; } } - char ts[32]; cfusa_timestamp_now(ts); - const char *approver = prepared_by ? prepared_by : "[name / date]"; - if (!strcmp(fmt_s,"json")) { fprintf(f, "{\n" @@ -109,40 +225,70 @@ int cmd_sas(int argc, char **argv) " \"version\": \"%s\",\n" " \"dal\": \"%s\",\n" " \"preparedBy\": \"%s\",\n" - " \"items\": [\n", + " \"checklist\": [\n", ts, cfg.project, cfg.version, dal, prepared_by ? prepared_by : ""); - for (int i=0; SAS_ITEMS[i].id; i++) - fprintf(f," {\"id\": \"%s\", \"description\": \"%s\"," - " \"evidence_type\": \"%s\", \"status\": \"pending\"}%s\n", - SAS_ITEMS[i].id, SAS_ITEMS[i].description, - SAS_ITEMS[i].evidence_type, + for (int i=0; SAS_ITEMS[i].id; i++) { + int present = item_present(dir, &SAS_ITEMS[i]); + fprintf(f," {\"item\": \"%s\", \"clause\": \"11.20\", \"present\": %s, " + "\"evidence\": \"%s\"}%s\n", + SAS_ITEMS[i].description, present ? "true" : "false", + SAS_ITEMS[i].evidence_file, SAS_ITEMS[i+1].id ? "," : ""); - fprintf(f," ]\n}\n"); + } + fprintf(f," ],\n \"summary\": {\"total\": %d, \"present\": %d}", total, present_count); + if (attestation_valid) { + fprintf(f, + ",\n \"attestation\": {\n" + " \"status\": \"reviewed\",\n" + " \"implementationAuthor\": \"%s\",\n" + " \"independentReviewer\": \"%s\",\n" + " \"reviewedAt\": \"%s\",\n" + " \"contentHash\": \"%s\"\n" + " }\n", + attestation.implementation_author, attestation.independent_reviewer, + attestation.reviewed_at, attestation.content_hash); + } else { + fprintf(f, "\n"); + } + fprintf(f, "}\n"); } else if (!strcmp(fmt_s,"text")) { fprintf(f,"Software Accomplishment Summary (SAS)\n" "Project: %s v%s DAL: %s Generated: %s\nStandard: DO-178C §11.20\n" "Prepared by: %s\n\n", cfg.project, cfg.version, dal, ts, approver); - for (int i=0;SAS_ITEMS[i].id;i++) - fprintf(f,"%-8s [ ] PENDING %-50s Evidence: %s\n", - SAS_ITEMS[i].id, SAS_ITEMS[i].description, - SAS_ITEMS[i].evidence_type); + for (int i=0;SAS_ITEMS[i].id;i++) { + int present = item_present(dir, &SAS_ITEMS[i]); + fprintf(f,"%-8s [%s] %-50s Evidence: %s\n", + SAS_ITEMS[i].id, present ? "x" : " ", SAS_ITEMS[i].description, + SAS_ITEMS[i].evidence_file[0] ? SAS_ITEMS[i].evidence_file : "(none)"); + } + fprintf(f, "\n%d/%d present\n", present_count, total); } else { - /* Markdown default */ - fprintf(f,"# Software Accomplishment Summary (SAS)\n\n" - "**Project:** %s v%s | **DAL:** %s | **Generated:** %s | **Standard:** DO-178C §11.20\n\n" - "| ID | Description | Evidence Type | Status |\n|---|---|---|---|\n", - cfg.project, cfg.version, dal, ts); - for (int i=0;SAS_ITEMS[i].id;i++) - fprintf(f,"| %s | %s | %s | [ ] Pending |\n", - SAS_ITEMS[i].id, SAS_ITEMS[i].description, - SAS_ITEMS[i].evidence_type); - fprintf(f,"\n---\n_Approved by: %s_\n", approver); + /* Markdown default — this is c-FuSa's MUST-have human-readable + * companion to sas.json (x-FuSa spec §9.3). */ + render_sas_markdown(f, dir, &cfg, dal, ts, approver, present_count, total); } if (!to_stdout) { fclose(f); printf("SAS written to %s\n", out_path); + + /* x-FuSa spec §9.3: "A tool MUST also write the human-readable + * sas.md companion — sas.json is not a replacement for it." When + * this invocation wrote something other than sas.md itself, make + * sure the companion still gets produced alongside it. */ + int wrote_sas_md = (strcmp(out_path + (strlen(out_path) >= 7 ? strlen(out_path) - 7 : 0), "/sas.md") == 0) || + (strcmp(out_path, "sas.md") == 0); + if (!wrote_sas_md && strcmp(fmt_s, "md") != 0) { + char companion_path[512]; + cfusa_path_join(companion_path, sizeof(companion_path), dir, "sas.md"); + FILE *cf = cfusa_fopen_write(companion_path); + if (cf) { + render_sas_markdown(cf, dir, &cfg, dal, ts, approver, present_count, total); + fclose(cf); + printf("SAS companion written to %s\n", companion_path); + } + } } - return 0; + return qb_gate; } diff --git a/cmd/cfusa/cmd_sci.c b/cmd/cfusa/cmd_sci.c index 7b4c1b1..dcf1f0a 100644 --- a/cmd/cfusa/cmd_sci.c +++ b/cmd/cfusa/cmd_sci.c @@ -5,13 +5,19 @@ #include "cfusa/utils.h" #include "cfusa/version.h" -//cfusa:req REQ-CLI-SCI001 REQ-SCI001 REQ-SCI002 +//cfusa:req REQ-CLI-SCI001 REQ-SCI001 REQ-SCI002 REQ-SCI003 -/* Software Configuration Index — lists all source files with SHA-256 checksums */ +/* Software Configuration Index — lists all source files with SHA-256 + * checksums (DO-178C §11.16), x-FuSa spec §9.3. + * + * `artifacts[].hash` is a field *named* "hash" (its algorithm is allowed to + * vary per x-FuSa spec §2.7), so it MUST carry the "sha256:" prefix, unlike + * a field literally named "sha256" (which would carry bare hex). */ typedef struct { FILE *out; const char *fmt; /* "text" or "md" or "json" */ + const char *version; int count; int first; } sci_ctx_t; @@ -23,13 +29,13 @@ static int sci_file(const char *path, void *vctx) cfusa_sha256_file(path, hex); if (!strcmp(ctx->fmt,"json")) { - fprintf(ctx->out, "%s\n {\"file\": \"%s\", \"sha256\": \"%s\"}", - ctx->first ? "" : ",", path, hex); + fprintf(ctx->out, "%s\n {\"file\": \"%s\", \"hash\": \"sha256:%s\", \"version\": \"%s\"}", + ctx->first ? "" : ",", path, hex, ctx->version); ctx->first = 0; } else if (!strcmp(ctx->fmt,"md")) { - fprintf(ctx->out, "| %s | `%s` |\n", path, hex); + fprintf(ctx->out, "| %s | `sha256:%s` |\n", path, hex); } else { - fprintf(ctx->out, "%-60s %s\n", path, hex); + fprintf(ctx->out, "%-60s sha256:%s\n", path, hex); } ctx->count++; return 0; @@ -70,7 +76,7 @@ int cmd_sci(int argc, char **argv) cfusa_config_load(dir, &cfg); FILE *out = stdout; - if (output) { out = fopen(output,"w"); if (!out){perror(output);return 1;} } + if (output) { out = cfusa_fopen_write(output); if (!out){perror(output);return 1;} } char ts[32]; cfusa_timestamp_now(ts); @@ -85,7 +91,7 @@ int cmd_sci(int argc, char **argv) " \"generatedAt\": \"%s\",\n" " \"project\": \"%s\",\n" " \"version\": \"%s\",\n" - " \"files\": [", + " \"artifacts\": [", ts, cfg.project, cfg.version); } else if (!strcmp(fmt_s,"md")) { fprintf(out, "# Software Configuration Index\n\n" @@ -103,12 +109,12 @@ int cmd_sci(int argc, char **argv) "----------------------------------------------------------------"); } - sci_ctx_t ctx = {out, fmt_s, 0, 1}; + sci_ctx_t ctx = {out, fmt_s, cfg.version, 0, 1}; static const char * const exts[] = {".c",".h"}; cfusa_walk_sources(dir, exts, 2, sci_file, &ctx); if (!strcmp(fmt_s,"json")) - fprintf(out, "\n ],\n \"total_files\": %d\n}\n", ctx.count); + fprintf(out, "\n ],\n \"totalFiles\": %d\n}\n", ctx.count); else if (!strcmp(fmt_s,"text")) fprintf(out, "\nTotal files: %d\n", ctx.count); else diff --git a/cmd/cfusa/cmd_tara.c b/cmd/cfusa/cmd_tara.c index 213b6ac..3d6f456 100644 --- a/cmd/cfusa/cmd_tara.c +++ b/cmd/cfusa/cmd_tara.c @@ -1,84 +1,330 @@ +/* + * cfusa tara — Threat Analysis and Risk Assessment (ISO/SAE 21434:2021 + * Clause 15), x-FuSa spec §9.2. + * + * Scans C source for functions that look like they handle + * external/untrusted data (network, file, credential, or raw-memory + * input) — a keyword-based asset-discovery heuristic, documented as such + * via `summary.assetInventoryMethod` rather than claimed as a formal asset + * inventory. Each match becomes one asset + one threat scenario, with an + * SFOP (Safety/Financial/Operational/Privacy) impact object per ISO 21434 + * Clause 15.7, rather than one generic severity. Threat/asset text is + * templated from the actual function/file found, so it varies per entry + * (x-FuSa spec §1.6.1 rule B) — never a fixed placeholder string. + */ #include +#include #include #include #include "cfusa/config.h" +#include "cfusa/qualitybar.h" #include "cfusa/utils.h" #include "cfusa/version.h" -//cfusa:req REQ-CLI-TARA001 REQ-TARA001 REQ-TARA002 REQ-TARA003 - -/* Generates a Threat Analysis & Risk Assessment skeleton (ISO 21434 Clause 9) */ - -static const char *THREAT_TEMPLATE_MD = - "# Threat Analysis and Risk Assessment (TARA)\n" - "## ISO 21434 Clause 9 — %s v%s\n" - "Generated: %s\n\n" - "---\n\n" - "## 1. Asset Identification\n\n" - "| Asset | Description | Security Property |\n" - "|---|---|---|\n" - "| ASSET-001 | [describe asset] | Confidentiality / Integrity / Availability |\n\n" - "## 2. Threat Scenarios\n\n" - "| ID | Asset | Threat | Attack Vector | Attacker Profile |\n" - "|---|---|---|---|---|\n" - "| TS-001 | ASSET-001 | [describe threat] | [local/remote/physical] | [profile] |\n\n" - "## 3. Impact Assessment\n\n" - "| Threat | Safety Impact | Financial Impact | Operational Impact | Privacy Impact |\n" - "|---|---|---|---|---|\n" - "| TS-001 | [none/low/med/high/severe] | [pct revenue] | [operational days] | [# subjects] |\n\n" - "## 4. Attack Feasibility\n\n" - "| Threat | Elapsed Time | Expertise | Knowledge | Equipment | Windows |\n" - "|---|---|---|---|---|---|\n" - "| TS-001 | [1day/1wk/1mo/3mo/>6mo] | [layman/proficient/expert/multiple] " - "| [public/restricted/confidential/critical] | [std/specialised/bespoke/multiple]" - " | [unlimited/easy/moderate/difficult] |\n\n" - "## 5. Risk Determination\n\n" - "| Threat | Impact | Feasibility | Risk Value | Risk Level |\n" - "|---|---|---|---|---|\n" - "| TS-001 | [1-4] | [1-4] | [Impact x Feasibility] | [LOW/MEDIUM/HIGH/CRITICAL] |\n\n" - "## 6. Risk Treatment\n\n" - "| Threat | Treatment | Cybersecurity Goal | Requirement Ref |\n" - "|---|---|---|\n" - "| TS-001 | [avoid/reduce/share/accept] | [goal] | [SRS-xxx] |\n\n" - "---\n" - "_Document owner: [name]_ \n" - "_Review date: [date]_ \n" - "_Standard: ISO 21434:2021 Clause 9_\n"; - -static void write_tara_json(FILE *f, const char *project, - const char *version, const char *ts) +//cfusa:req REQ-CLI-TARA001 REQ-TARA001 REQ-TARA002 REQ-TARA003 REQ-TARA006 + +#define MAX_THREATS 512 + +typedef struct { + const char *category; /* "network" | "file" | "auth" | "memory" */ + const char *attack_vector; /* "network" | "local" | "physical" */ + const char *feasibility; /* high|medium|low|very-low */ + const char *safety, *financial, *operational, *privacy; /* SFOP: high|medium|low */ + const char *mitigations[3]; +} category_profile_t; + +static const category_profile_t PROFILE_NETWORK = { + "network", "network", "medium", "medium", "low", "medium", "medium", + {"Validate and bound-check all network input before use", + "Add fuzz/negative testing for this entry point", NULL} +}; +static const category_profile_t PROFILE_FILE = { + "file", "local", "medium", "low", "low", "medium", "low", + {"Validate file contents against an expected schema before use", + "Reject unexpected file sizes/paths", NULL} +}; +static const category_profile_t PROFILE_AUTH = { + "auth", "local", "medium", "low", "medium", "medium", "high", + {"Store credentials/keys only in vetted secret storage", + "Add independent review of authentication/authorization logic", NULL} +}; +static const category_profile_t PROFILE_MEMORY = { + "memory", "local", "medium", "high", "low", "medium", "low", + {"Use bounds-checked copy/allocation APIs", + "Add static analysis (cfusa analyze/lint) to the CI gate for this file", NULL} +}; + +typedef struct { + char name[128]; + char file[256]; + int line; + const category_profile_t *profile; +} asset_entry_t; + +static asset_entry_t g_assets[MAX_THREATS]; +static int g_asset_count = 0; +static int g_total_found = 0; + +static const category_profile_t *classify(const char *name) +{ + static const char * const net_kw[] = {"recv","socket","connect","listen","accept","http","tcp","udp","fetch", NULL}; + static const char * const file_kw[] = {"fopen","fread","load","import","parse","decode","deserialize", NULL}; + static const char * const auth_kw[] = {"auth","login","token","credential","password","secret", NULL}; + static const char * const mem_kw[] = {"alloc","copy","strcpy","memcpy","buffer","realloc", NULL}; + + for (int i = 0; net_kw[i]; i++) if (strstr(name, net_kw[i])) return &PROFILE_NETWORK; + for (int i = 0; auth_kw[i]; i++) if (strstr(name, auth_kw[i])) return &PROFILE_AUTH; + for (int i = 0; file_kw[i]; i++) if (strstr(name, file_kw[i])) return &PROFILE_FILE; + for (int i = 0; mem_kw[i]; i++) if (strstr(name, mem_kw[i])) return &PROFILE_MEMORY; + return NULL; +} + +/* ---- feasibility x max(SFOP) -> risk (documented heuristic, not a claim + * of the full ISO 21434 risk-value table — see summary.assetInventoryMethod) ---- */ + +static int feasibility_rank(const char *f) +{ + if (!strcmp(f, "high")) return 4; + if (!strcmp(f, "medium")) return 3; + if (!strcmp(f, "low")) return 2; + return 1; /* very-low */ +} +static int impact_rank(const char *v) +{ + if (!strcmp(v, "high")) return 3; + if (!strcmp(v, "medium")) return 2; + return 1; /* low */ +} +static const char *max_sfop(const category_profile_t *p) +{ + const char *best = p->safety; int br = impact_rank(best); + const char *cand[3] = {p->financial, p->operational, p->privacy}; + for (int i = 0; i < 3; i++) { + int r = impact_rank(cand[i]); + if (r > br) { br = r; best = cand[i]; } + } + return best; +} +static const char *derive_risk(const category_profile_t *p) +{ + int score = feasibility_rank(p->feasibility) * impact_rank(max_sfop(p)); + if (score <= 2) return "low"; + if (score <= 6) return "medium"; + if (score <= 9) return "high"; + return "critical"; +} +static const char *derive_treatment(const char *risk) +{ + return strcmp(risk, "low") == 0 ? "accept" : "mitigate"; +} + +/* ---- qualitative-field rendering (varies per entry — rule B) ---- */ + +static void render_asset(char *out, size_t sz, const asset_entry_t *a) +{ + snprintf(out, sz, "Data handled by %s (%s)", a->name, cfusa_basename(a->file)); +} +static void render_threat(char *out, size_t sz, const asset_entry_t *a) +{ + snprintf(out, sz, + "An attacker supplies malformed/untrusted input to %s, potentially causing " + "incorrect behaviour, a crash, or information disclosure", a->name); +} + +static void asset_line(const char *path, int lineno, const char *line, void *vctx) +{ + (void)vctx; + const char *p = line; + while (*p == ' ' || *p == '\t') p++; + if (!*p || *p == '/' || *p == '#' || *p == '*' || *p == '}') return; + static const char * const skip_kw[] = { + "if ","for ","while ","switch ","return ","else ","case ", + "typedef ","struct ","enum ","union ","static ","extern ","inline ",NULL + }; + for (int i = 0; skip_kw[i]; i++) + if (strncmp(p, skip_kw[i], strlen(skip_kw[i])) == 0) return; + if (!strstr(line,"(") || !strstr(line,")")) return; + const char *end = line + strlen(line); + while (end > line && (end[-1]==' '||end[-1]=='\t'||end[-1]=='\n'||end[-1]=='\r')) end--; + if (end > line && end[-1] == ';') return; + + char *paren = strchr((char*)p, '('); + if (!paren) return; + char before[128] = ""; + size_t bl = (size_t)(paren - p); + if (bl == 0 || bl >= 128) return; + strncpy(before, p, bl); before[bl] = '\0'; + char *sp = strrchr(before, ' '); + char *fn_name = sp ? sp + 1 : before; + while (*fn_name == '*') fn_name++; + if (!*fn_name || strlen(fn_name) < 2) return; + + const category_profile_t *prof = classify(fn_name); + if (!prof) return; /* not asset-relevant by this heuristic */ + + g_total_found++; + if (g_asset_count >= MAX_THREATS) return; + + strncpy(g_assets[g_asset_count].name, fn_name, 127); + strncpy(g_assets[g_asset_count].file, path, 255); + g_assets[g_asset_count].line = lineno; + g_assets[g_asset_count].profile = prof; + g_asset_count++; +} + +/* Mirrors cmd_trace.c's is_test_file() / cmd_fmea.c's fmea_is_test_file(): + * a TARA is over the project's own attack surface, not its test + * scaffolding (a test helper calling e.g. strcpy() is not an asset). */ +static int tara_is_test_file(const char *path) +{ + const char *b = strrchr(path, '/'); + b = b ? b + 1 : path; + if (strncmp(b, "test_", 5) == 0) return 1; + size_t n = strlen(b); + return n > 7 && strcmp(b + n - 7, "_test.c") == 0; +} + +static int asset_file(const char *path, void *v) { + if (tara_is_test_file(path)) return 0; + cfusa_scan_lines(path, asset_line, v); + return 0; +} + +/* ---- canonical content hash (x-FuSa spec §1.6.2) ---- */ + +static char g_canonical_buf[262144]; + +static size_t tara_canonical_content(char *buf, size_t bufsz) +{ + size_t off = 0; + char esc_asset[256], esc_threat[320]; + off += (size_t)snprintf(buf + off, bufsz - off, "{\"threats\":["); + for (int i = 0; i < g_asset_count; i++) { + const asset_entry_t *a = &g_assets[i]; + const category_profile_t *p = a->profile; + char asset[256], threat[320]; + render_asset(asset, sizeof(asset), a); + render_threat(threat, sizeof(threat), a); + cfusa_str_escape_json(asset, esc_asset, sizeof(esc_asset)); + cfusa_str_escape_json(threat, esc_threat, sizeof(esc_threat)); + const char *risk = derive_risk(p); + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, + "%s{\"asset\":\"%s\",\"attackFeasibility\":\"%s\",\"attackVector\":\"%s\"," + "\"id\":\"TARA-%03d\",\"impact\":{\"financial\":\"%s\",\"operational\":\"%s\"," + "\"privacy\":\"%s\",\"safety\":\"%s\"},\"risk\":\"%s\",\"threat\":\"%s\"," + "\"treatment\":\"%s\"}", + i ? "," : "", esc_asset, p->feasibility, p->attack_vector, i + 1, + p->financial, p->operational, p->privacy, p->safety, risk, esc_threat, + derive_treatment(risk)); + } + off += (size_t)snprintf(buf + off, off < bufsz ? bufsz - off : 0, "]}"); + return off; +} + +/* ---- quality-bar scan + attestation ---- */ + +static const char *g_qb_threats[MAX_THREATS]; +static char g_qb_threat_bufs[MAX_THREATS][320]; + +static int run_quality_bar(const char *dir, const char *fresh_hash, + cfusa_attestation_t *existing, int require_attestation) +{ + for (int i = 0; i < g_asset_count; i++) { + render_threat(g_qb_threat_bufs[i], sizeof(g_qb_threat_bufs[i]), &g_assets[i]); + g_qb_threats[i] = g_qb_threat_bufs[i]; + } + + int rule_a_hits = 0; + for (int i = 0; i < g_asset_count; i++) + if (cfusa_qb_is_stub_text(g_qb_threats[i])) rule_a_hits++; + int rule_a_disposed = rule_a_hits > 0 && cfusa_qb_rule_disposed(dir, CFUSA_QB_RULE_A); + if (rule_a_hits > 0) + fprintf(stderr, "cfusa tara: %s: %d entr%s with placeholder-looking text%s\n", + CFUSA_QB_RULE_A, rule_a_hits, rule_a_hits == 1 ? "y" : "ies", + rule_a_disposed ? " (disposed)" : ""); + + int rule_b = cfusa_qb_rule_b_flagged(g_qb_threats, g_asset_count); + int reviewed = 0; + if (rule_b) { + reviewed = cfusa_qb_attestation_valid(existing, fresh_hash); + fprintf(stderr, "cfusa tara: %s: threat text shows low distinct-value ratio across " + ">=10 entries%s\n", CFUSA_QB_RULE_B, + reviewed ? " (suppressed by a valid attestation)" : ""); + } + + if (rule_a_hits > 0 && !rule_a_disposed) return 1; + if (require_attestation && rule_b && !reviewed) return 1; + return 0; +} + +/* ---- rendering ---- */ + +static void write_threat_json(FILE *f, const asset_entry_t *a, int idx, int last) +{ + const category_profile_t *p = a->profile; + char asset[256], threat[320]; + render_asset(asset, sizeof(asset), a); + render_threat(threat, sizeof(threat), a); + char esc_asset[300], esc_threat[380]; + cfusa_str_escape_json(asset, esc_asset, sizeof(esc_asset)); + cfusa_str_escape_json(threat, esc_threat, sizeof(esc_threat)); + const char *risk = derive_risk(p); fprintf(f, - "{\n" - " \"schemaVersion\": \"" CFUSA_SCHEMA_VERSION "\",\n" - " \"kind\": \"tara\",\n" - " \"tool\": \"c-FuSa\",\n" - " \"toolVersion\": \"" CFUSA_VERSION_STRING "\",\n" - " \"language\": \"c\",\n" - " \"generatedAt\": \"%s\",\n" - " \"project\": \"%s\",\n" - " \"version\": \"%s\",\n" - " \"standard\": \"ISO 21434:2021 Clause 9\",\n" - " \"assets\": [\n" - " {\"id\":\"ASSET-001\",\"description\":\"[describe asset]\"," - "\"property\":\"CIA\"}\n" - " ],\n" - " \"threats\": [\n" " {\n" - " \"id\": \"TS-001\",\n" - " \"asset\": \"ASSET-001\",\n" - " \"threat\": \"[describe threat]\",\n" - " \"attack_vector\": \"[local/remote/physical]\",\n" - " \"impact\": \"[none/low/med/high/severe]\",\n" - " \"feasibility\": \"[1-4]\",\n" - " \"risk_level\": \"[LOW/MEDIUM/HIGH/CRITICAL]\",\n" - " \"treatment\": \"[avoid/reduce/share/accept]\",\n" - " \"cybersecurity_goal\": \"[goal]\",\n" - " \"requirement_ref\": \"[SRS-xxx]\"\n" - " }\n" - " ]\n" - "}\n", - ts, project, version); + " \"id\": \"TARA-%03d\",\n" + " \"asset\": \"%s\",\n" + " \"threat\": \"%s\",\n" + " \"attackVector\": \"%s\",\n" + " \"attackFeasibility\": \"%s\",\n" + " \"impact\": {\"safety\": \"%s\", \"financial\": \"%s\", " + "\"operational\": \"%s\", \"privacy\": \"%s\"},\n" + " \"risk\": \"%s\",\n" + " \"treatment\": \"%s\",\n" + " \"mitigations\": [", + idx + 1, esc_asset, esc_threat, p->attack_vector, p->feasibility, + p->safety, p->financial, p->operational, p->privacy, risk, derive_treatment(risk)); + for (int i = 0; p->mitigations[i]; i++) + fprintf(f, "%s\"%s\"", i ? ", " : "", p->mitigations[i]); + fprintf(f, "],\n" + " \"location\": {\"file\": \"%s\", \"line\": %d}\n" + " }%s\n", + cfusa_basename(a->file), a->line, last ? "" : ","); +} + +static void render_markdown(FILE *f, const char *project, const char *version, const char *ts, + int coverage_pct) +{ + fprintf(f, + "# Threat Analysis and Risk Assessment (TARA)\n" + "## ISO/SAE 21434:2021 Clause 15 — %s v%s\n" + "Generated: %s\n\n" + "Assets and threats below were discovered by a keyword-based scan of " + "public functions handling network, file, credential, or raw-memory " + "input (see `assetInventoryMethod` in `tara.json`) — not a formal " + "asset inventory.\n\n" + "---\n\n" + "| ID | Asset | Threat | Attack Vector | Feasibility | Safety | Financial | " + "Operational | Privacy | Risk | Treatment |\n" + "|---|---|---|---|---|---|---|---|---|---|---|\n", + project, version, ts); + for (int i = 0; i < g_asset_count; i++) { + const asset_entry_t *a = &g_assets[i]; + const category_profile_t *p = a->profile; + char asset[256], threat[320]; + render_asset(asset, sizeof(asset), a); + render_threat(threat, sizeof(threat), a); + const char *risk = derive_risk(p); + fprintf(f, "| TARA-%03d | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s |\n", + i + 1, asset, threat, p->attack_vector, p->feasibility, + p->safety, p->financial, p->operational, p->privacy, risk, + derive_treatment(risk)); + } + if (g_asset_count == 0) + fprintf(f, "\n_No network/file/auth/memory-input functions were found by this " + "heuristic scan — threats table is honestly empty, not a template row._\n"); + fprintf(f, "\n---\n_Total assets analysed: %d (%d%% of %d discovered by the scan)_\n", + g_asset_count, coverage_pct, g_total_found); } int cmd_tara(int argc, char **argv) @@ -86,34 +332,48 @@ int cmd_tara(int argc, char **argv) const char *dir = "."; const char *output = NULL; const char *output_dir= NULL; - const char *fmt_s = NULL; /* NULL = both tara.json + TARA.md */ + const char *fmt_s = NULL; /* NULL = both tara.json + tara.md */ + const char *attest = NULL; + int strict = 0, require_attestation = 0, min_coverage = 0; static const struct option long_opts[] = { - {"dir", required_argument, NULL, 'd'}, - {"output", required_argument, NULL, 'o'}, - {"output-dir", required_argument, NULL, 'D'}, - {"format", required_argument, NULL, 'f'}, - {"help", no_argument, NULL, 'h'}, + {"dir", required_argument, NULL, 'd'}, + {"output", required_argument, NULL, 'o'}, + {"output-dir", required_argument, NULL, 'D'}, + {"format", required_argument, NULL, 'f'}, + {"strict", no_argument, NULL, 'S'}, + {"require-attestation", no_argument, NULL, 'A'}, + {"attest", required_argument, NULL, 'T'}, + {"min-coverage", required_argument, NULL, 'm'}, + {"help", no_argument, NULL, 'h'}, {NULL,0,NULL,0} }; int c; optind = 1; - while ((c = getopt_long(argc, argv, "d:o:D:f:h", long_opts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "d:o:D:f:SAT:m:h", long_opts, NULL)) != -1) { switch (c) { case 'd': dir = optarg; break; case 'o': output = optarg; break; case 'D': output_dir = optarg; break; case 'f': fmt_s = optarg; break; + case 'S': strict = 1; break; + case 'A': require_attestation = 1; break; + case 'T': attest = optarg; break; + case 'm': min_coverage = atoi(optarg); break; case 'h': printf("Usage: cfusa tara [--dir ] [--output tara.md]\n" - " [--output-dir ] [--format md|json]\n\n" - "Generates an ISO 21434 Clause 9 TARA document skeleton.\n" + " [--output-dir ] [--format md|json]\n" + " [--strict] [--require-attestation] [--attest ]\n" + " [--min-coverage N]\n\n" + "Generates an ISO/SAE 21434 Clause 15 TARA from a keyword-based scan of\n" + "network/file/auth/memory-input functions.\n" "Default: writes both tara.json and tara.md.\n"); return 0; default: return 2; } } + if (strict) require_attestation = 1; cfusa_config_t cfg; cfusa_config_load(dir, &cfg); @@ -121,23 +381,95 @@ int cmd_tara(int argc, char **argv) char ts[32]; cfusa_timestamp_now(ts); + g_asset_count = 0; + g_total_found = 0; + static const char * const exts[] = {".c"}; + cfusa_walk_sources(dir, exts, 1, asset_file, NULL); + + int coverage_pct = (g_total_found == 0) ? 100 : (g_asset_count * 100 / g_total_found); + const char *base = output_dir ? output_dir : dir; + char existing_path[512]; + cfusa_path_join(existing_path, sizeof(existing_path), base, "tara.json"); + size_t existing_len = 0; + char *existing_json = cfusa_read_file(existing_path, &existing_len); + cfusa_attestation_t attestation; + if (existing_json) cfusa_qb_attestation_read(existing_json, existing_len, &attestation); + else memset(&attestation, 0, sizeof(attestation)); + free(existing_json); + + size_t clen = tara_canonical_content(g_canonical_buf, sizeof(g_canonical_buf)); + if (clen >= sizeof(g_canonical_buf)) clen = sizeof(g_canonical_buf) - 1; + char fresh_hash[80]; + cfusa_qb_content_hash(g_canonical_buf, clen, fresh_hash); + + if (attest) { + attestation.present = 1; + strncpy(attestation.status, "reviewed", sizeof(attestation.status) - 1); + strncpy(attestation.implementation_author, "auto", sizeof(attestation.implementation_author) - 1); + strncpy(attestation.independent_reviewer, attest, sizeof(attestation.independent_reviewer) - 1); + strncpy(attestation.reviewed_at, ts, sizeof(attestation.reviewed_at) - 1); + strncpy(attestation.content_hash, fresh_hash, sizeof(attestation.content_hash) - 1); + } + + int qb_gate = run_quality_bar(dir, fresh_hash, &attestation, require_attestation); + int attestation_valid = cfusa_qb_attestation_valid(&attestation, fresh_hash); + + int cov_gate = 0; + if (min_coverage > 0 && coverage_pct < min_coverage) { + fprintf(stderr, "cfusa tara: --min-coverage gate failed: %d%% < required %d%%\n", + coverage_pct, min_coverage); + cov_gate = 1; + } + +#define WRITE_JSON(fp) do { \ + fprintf((fp), "{\n" \ + " \"schemaVersion\": \"" CFUSA_SCHEMA_VERSION "\",\n" \ + " \"kind\": \"tara-report\",\n" \ + " \"tool\": \"c-FuSa\",\n" \ + " \"toolVersion\": \"" CFUSA_VERSION_STRING "\",\n" \ + " \"language\": \"c\",\n" \ + " \"generatedAt\": \"%s\",\n" \ + " \"project\": \"%s\",\n" \ + " \"version\": \"%s\",\n" \ + " \"standard\": \"ISO/SAE 21434:2021 Clause 15\",\n" \ + " \"threats\": [\n", \ + ts, cfg.project, cfg.version); \ + for (int i = 0; i < g_asset_count; i++) \ + write_threat_json((fp), &g_assets[i], i, i == g_asset_count - 1); \ + fprintf((fp), " ],\n" \ + " \"summary\": {\n" \ + " \"assetsAnalyzed\": %d, \"assetsInProject\": %d, \"coveragePct\": %d,\n" \ + " \"assetInventoryMethod\": \"Keyword-based scan of public C function names " \ + "against a network/file/auth/memory-input vocabulary; not a formal asset " \ + "inventory.\"\n" \ + " }", \ + g_asset_count, g_total_found, coverage_pct); \ + if (attestation_valid) { \ + fprintf((fp), ",\n \"attestation\": {\n" \ + " \"status\": \"reviewed\",\n" \ + " \"implementationAuthor\": \"%s\",\n" \ + " \"independentReviewer\": \"%s\",\n" \ + " \"reviewedAt\": \"%s\",\n" \ + " \"contentHash\": \"%s\"\n" \ + " }\n", \ + attestation.implementation_author, attestation.independent_reviewer, \ + attestation.reviewed_at, attestation.content_hash); \ + } else { \ + fprintf((fp), "\n"); \ + } \ + fprintf((fp), "}\n"); \ +} while (0) /* Specific output file requested */ if (output) { - FILE *f = fopen(output, "w"); + FILE *f = cfusa_fopen_write(output); if (!f) { perror(output); return 3; } - if (fmt_s && !strcmp(fmt_s, "json")) { - write_tara_json(f, cfg.project, cfg.version, ts); - } else { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wformat-nonliteral" - fprintf(f, THREAT_TEMPLATE_MD, cfg.project, cfg.version, ts); -#pragma clang diagnostic pop - } + if (fmt_s && !strcmp(fmt_s, "json")) WRITE_JSON(f); + else render_markdown(f, cfg.project, cfg.version, ts, coverage_pct); fclose(f); printf("TARA written to %s\n", output); - return 0; + return qb_gate || cov_gate; } /* Single format */ @@ -145,40 +477,33 @@ int cmd_tara(int argc, char **argv) char out_path[512]; const char *fname = !strcmp(fmt_s,"json") ? "tara.json" : "tara.md"; cfusa_path_join(out_path, sizeof(out_path), base, fname); - FILE *f = fopen(out_path, "w"); + FILE *f = cfusa_fopen_write(out_path); if (!f) { perror(out_path); return 3; } - if (!strcmp(fmt_s, "json")) { - write_tara_json(f, cfg.project, cfg.version, ts); - } else { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wformat-nonliteral" - fprintf(f, THREAT_TEMPLATE_MD, cfg.project, cfg.version, ts); -#pragma clang diagnostic pop - } + if (!strcmp(fmt_s, "json")) WRITE_JSON(f); + else render_markdown(f, cfg.project, cfg.version, ts, coverage_pct); fclose(f); printf("TARA written to %s\n", out_path); - return 0; + return qb_gate || cov_gate; } - /* Default: write both tara.json and TARA.md */ + /* Default: write both tara.json and tara.md */ char json_path[512], md_path[512]; cfusa_path_join(json_path, sizeof(json_path), base, "tara.json"); cfusa_path_join(md_path, sizeof(md_path), base, "tara.md"); - FILE *jf = fopen(json_path, "w"); + FILE *jf = cfusa_fopen_write(json_path); if (!jf) { perror(json_path); return 3; } - write_tara_json(jf, cfg.project, cfg.version, ts); + WRITE_JSON(jf); fclose(jf); - printf("TARA skeleton written to %s\n", json_path); + printf("TARA written to %s\n", json_path); - FILE *mf = fopen(md_path, "w"); + FILE *mf = cfusa_fopen_write(md_path); if (!mf) { perror(md_path); return 3; } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wformat-nonliteral" - fprintf(mf, THREAT_TEMPLATE_MD, cfg.project, cfg.version, ts); -#pragma clang diagnostic pop + render_markdown(mf, cfg.project, cfg.version, ts, coverage_pct); fclose(mf); - printf("TARA skeleton written to %s\n", md_path); - printf("Complete per ISO 21434:2021 Clause 9.\n"); - return 0; + printf("TARA written to %s\n", md_path); + printf("Assets: %d analysed, %d%% coverage of %d discovered\n", + g_asset_count, coverage_pct, g_total_found); + return qb_gate || cov_gate; +#undef WRITE_JSON } diff --git a/fmea.csv b/fmea.csv index 48648c3..47c35e5 100644 --- a/fmea.csv +++ b/fmea.csv @@ -1,244 +1,371 @@ -ID,Function,File,Line,Failure Mode,Effect,Cause,Severity,O,D,RPN,Action -FM-001,"cmd_pr","cmd_pr.c",133,,,,"Low",1,1,3, -FM-002,"cmd_version","cmd_version.c",4,,,,"Low",1,1,3, -FM-003,"cmd_qualify","cmd_qualify.c",60,,,,"Low",1,1,3, -FM-004,"cmd_misra","cmd_misra.c",56,,,,"Low",1,1,3, -FM-005,"cmd_iso26262","cmd_iso26262.c",59,,,,"Low",1,1,3, -FM-006,"printf","cmd_iso26262.c",124,,,,"Low",1,1,3, -FM-007,"cfusa_scan_lines","cmd_req.c",123,,,,"Low",1,1,3, -FM-008,"snprintf","cmd_req.c",202,,,,"Low",1,1,3, -FM-009,"printf","cmd_req.c",252,,,,"Low",1,1,3, -FM-010,"cmd_req","cmd_req.c",256,,,,"Low",1,1,3, -FM-011,"cmd_release","cmd_release.c",91,,,,"Low",1,1,3, -FM-012,"snprintf","cmd_release.c",130,,,,"Low",1,1,3, -FM-013,"cmd_check","cmd_check.c",9,,,,"Medium",1,1,5, -FM-014,"cmd_template","cmd_template.c",83,,,,"Low",1,1,3, -FM-015,"cmd_tara","cmd_tara.c",77,,,,"Low",1,1,3, -FM-016,"cfusa_scan_lines","cmd_trace.c",130,,,,"Low",1,1,3, -FM-017,"cmd_trace","cmd_trace.c",149,,,,"Low",1,1,3, -FM-018,"printf","cmd_trace.c",212,,,,"Low",1,1,3, -FM-019,"printf","cmd_trace.c",224,,,,"Low",1,1,3, -FM-020,"snprintf","cmd_trace.c",288,,,,"Low",1,1,3, -FM-021,"snprintf","cmd_trace.c",292,,,,"Low",1,1,3, -FM-022,"cfusa_basename","cmd_trace.c",308,,,,"Low",1,1,3, -FM-023,"snprintf","cmd_trace.c",330,,,,"Low",1,1,3, -FM-024,"snprintf","cmd_trace.c",334,,,,"Low",1,1,3, -FM-025,"fprintf","cmd_trace.c",354,,,,"Low",1,1,3, -FM-026,"for","cmd_analyze.c",24,,,,"Low",1,1,3, -FM-027,"if","cmd_analyze.c",65,,,,"Low",1,1,3, -FM-028,"!strstr","cmd_analyze.c",66,,,,"Low",1,1,3, -FM-029,"strstr","cmd_analyze.c",99,,,,"Low",1,1,3, -FM-030,"strstr","cmd_analyze.c",100,,,,"Low",1,1,3, -FM-031,"!strstr","cmd_analyze.c",101,,,,"Low",1,1,3, -FM-032,"if","cmd_analyze.c",131,,,,"Low",1,1,3, -FM-033,"!strstr","cmd_analyze.c",132,,,,"Low",1,1,3, -FM-034,"if","cmd_analyze.c",162,,,,"Low",1,1,3, -FM-035,""assert","cmd_analyze.c",166,,,,"Low",1,1,3, -FM-036,"if","cmd_analyze.c",193,,,,"Low",1,1,3, -FM-037,"strstr","cmd_analyze.c",194,,,,"Low",1,1,3, -FM-038,"strstr","cmd_analyze.c",195,,,,"Low",1,1,3, -FM-039,"for","cmd_analyze.c",231,,,,"Low",1,1,3, -FM-040,""assert","cmd_analyze.c",277,,,,"Low",1,1,3, -FM-041,"cfusa_analyze_register_rules","cmd_analyze.c",285,,,,"Low",1,1,3, -FM-042,"cmd_analyze","cmd_analyze.c",291,,,,"Low",1,1,3, -FM-043,"cmd_report","cmd_report.c",9,,,,"Low",1,1,3, -FM-044,"cmd_init","cmd_init.c",8,,,,"Medium",1,1,5, -FM-045,"fprintf","cmd_init.c",46,,,,"Low",1,1,3, -FM-046,"cfusa_scan_lines","cmd_fmea.c",90,,,,"Low",1,1,3, -FM-047,"cmd_fmea","cmd_fmea.c",92,,,,"Low",1,1,3, -FM-048,"cfusa_path_join","cmd_fmea.c",139,,,,"Low",1,1,3, -FM-049,"printf","cmd_fmea.c",142,,,,"Low",1,1,3, -FM-050,"cfusa_basename","cmd_fmea.c",188,,,,"Low",1,1,3, -FM-051,"cfusa_basename","cmd_fmea.c",238,,,,"Low",1,1,3, -FM-052,"cfusa_basename","cmd_fmea.c",277,,,,"Low",1,1,3, -FM-053,"strtol","cmd_fix.c",48,,,,"Low",1,1,3, -FM-054,"fgets","cmd_fix.c",55,,,,"Low",1,1,3, -FM-055,"strncpy","cmd_fix.c",56,,,,"Low",1,1,3, -FM-056,"snprintf","cmd_fix.c",57,,,,"Low",1,1,3, -FM-057,"malloc","cmd_fix.c",61,,,,"Low",1,1,3, -FM-058,"assert","cmd_fix.c",71,,,,"Low",1,1,3, -FM-059,"strncpy","cmd_fix.c",78,,,,"Low",1,1,3, -FM-060,"dst[sizeof","cmd_fix.c",79,,,,"Low",1,1,3, -FM-061,"printf","cmd_fix.c",83,,,,"Low",1,1,3, -FM-062,"printf","cmd_fix.c",84,,,,"Low",1,1,3, -FM-063,"execve","cmd_fix.c",88,,,,"Low",1,1,3, -FM-064,"sizeof","cmd_fix.c",95,,,,"Low",1,1,3, -FM-065,"malloc","cmd_fix.c",97,,,,"Low",1,1,3, -FM-066,"free","cmd_fix.c",101,,,,"Low",1,1,3, -FM-067,"cmd_fix","cmd_fix.c",123,,,,"Low",1,1,3, -FM-068,"printf","cmd_fix.c",168,,,,"Low",1,1,3, -FM-069,"printf","cmd_fix.c",188,,,,"Low",1,1,3, -FM-070,"cmd_help","main.c",50,,,,"Low",1,1,3, -FM-071,"main","main.c",64,,,,"Low",1,1,3, -FM-072,"cmd_boundary","cmd_boundary.c",70,,,,"Low",1,1,3, -FM-073,"cmd_impact","cmd_impact.c",101,,,,"Low",1,1,3, -FM-074,"printf","cmd_impact.c",189,,,,"Low",1,1,3, -FM-075,"cmd_sci","cmd_sci.c",35,,,,"Low",1,1,3, -FM-076,"cmd_iec61508","cmd_iec61508.c",61,,,,"Low",1,1,3, -FM-077,"printf","cmd_iec61508.c",127,,,,"Low",1,1,3, -FM-078,"cmd_badge","cmd_badge.c",8,,,,"Low",1,1,3, -FM-079,"fill=\"url","cmd_badge.c",77,,,,"Low",1,1,3, -FM-080,"cmd_sign","cmd_sign.c",7,,,,"Low",1,1,3, -FM-081,"cfusa_hmac_sha256","cmd_sign.c",76,,,,"Low",1,1,3, -FM-082,""gets","cmd_vuln.c",23,,,,"Low",1,1,3, -FM-083,"fgets","cmd_vuln.c",24,,,,"Low",1,1,3, -FM-084,""sprintf","cmd_vuln.c",26,,,,"Low",1,1,3, -FM-085,"snprintf","cmd_vuln.c",27,,,,"Low",1,1,3, -FM-086,""strcpy","cmd_vuln.c",29,,,,"Low",1,1,3, -FM-087,"strlcpy","cmd_vuln.c",30,,,,"Low",1,1,3, -FM-088,""strcat","cmd_vuln.c",32,,,,"Low",1,1,3, -FM-089,"strlcat","cmd_vuln.c",33,,,,"Low",1,1,3, -FM-090,"scanf","cmd_vuln.c",36,,,,"Low",1,1,3, -FM-091,""tmpnam","cmd_vuln.c",38,,,,"Low",1,1,3, -FM-092,"mkstemp","cmd_vuln.c",39,,,,"Low",1,1,3, -FM-093,""system","cmd_vuln.c",41,,,,"Low",1,1,3, -FM-094,"system","cmd_vuln.c",42,,,,"Low",1,1,3, -FM-095,""rand","cmd_vuln.c",44,,,,"Low",1,1,3, -FM-096,""mktemp","cmd_vuln.c",47,,,,"Low",1,1,3, -FM-097,"mkstemp","cmd_vuln.c",48,,,,"Low",1,1,3, -FM-098,""popen","cmd_vuln.c",50,,,,"Low",1,1,3, -FM-099,"execv","cmd_vuln.c",51,,,,"Low",1,1,3, -FM-100,"cfusa_scan_lines","cmd_vuln.c",104,,,,"Low",1,1,3, -FM-101,"cmd_vuln","cmd_vuln.c",106,,,,"Low",1,1,3, -FM-102,"cmd_audit_pack","cmd_audit_pack.c",14,,,,"Low",1,1,3, -FM-103,"cmd_hooks","cmd_hooks.c",19,,,,"Low",1,1,3, -FM-104,"cmd_disposition","cmd_disposition.c",167,,,,"Low",1,1,3, -FM-105,"cmd_coverage","cmd_coverage.c",61,,,,"Low",1,1,3, -FM-106,"fprintf","cmd_coverage.c",150,,,,"Low",1,1,3, -FM-107,"fprintf","cmd_coverage.c",152,,,,"Low",1,1,3, -FM-108,"fprintf","cmd_coverage.c",154,,,,"Low",1,1,3, -FM-109,"cmd_diff","cmd_diff.c",63,,,,"Low",1,1,3, -FM-110,"cmd_hara","cmd_hara.c",195,,,,"Low",1,1,3, -FM-111,"cmd_do178","cmd_do178.c",100,,,,"Low",1,1,3, -FM-112,"cmd_verify","cmd_verify.c",13,,,,"Low",1,1,3, -FM-113,"cmd_sas","cmd_sas.c",39,,,,"Low",1,1,3, -FM-114,"fprintf","cmd_sas.c",93,,,,"Low",1,1,3, -FM-115,"fprintf","cmd_sas.c",102,,,,"Low",1,1,3, -FM-116,"for","cmd_cyber.c",18,,,,"Low",1,1,3, -FM-117,"if","cmd_cyber.c",21,,,,"Low",1,1,3, -FM-118,"||","cmd_cyber.c",22,,,,"Low",1,1,3, -FM-119,"for","cmd_cyber.c",49,,,,"Low",1,1,3, -FM-120,"if","cmd_cyber.c",53,,,,"Low",1,1,3, -FM-121,"if","cmd_cyber.c",61,,,,"Low",1,1,3, -FM-122,"if","cmd_cyber.c",69,,,,"Low",1,1,3, -FM-123,"strncmp","cmd_cyber.c",70,,,,"Low",1,1,3, -FM-124,"for","cmd_cyber.c",93,,,,"Low",1,1,3, -FM-125,"if","cmd_cyber.c",100,,,,"Low",1,1,3, -FM-126,"if","cmd_cyber.c",150,,,,"Low",1,1,3, -FM-127,"strstr","cmd_cyber.c",151,,,,"Low",1,1,3, -FM-128,"if","cmd_cyber.c",173,,,,"Low",1,1,3, -FM-129,"free","cmd_cyber.c",176,,,,"Low",1,1,3, -FM-130,"if","cmd_cyber.c",197,,,,"Low",1,1,3, -FM-131,"if","cmd_cyber.c",215,,,,"Low",1,1,3, -FM-132,"cfusa_match_outside_string","cmd_cyber.c",216,,,,"Low",1,1,3, -FM-133,"mkstemp","cmd_cyber.c",219,,,,"Low",1,1,3, -FM-134,"for","cmd_cyber.c",237,,,,"Low",1,1,3, -FM-135,"if","cmd_cyber.c",238,,,,"Low",1,1,3, -FM-136,"for","cmd_cyber.c",260,,,,"Low",1,1,3, -FM-137,"if","cmd_cyber.c",264,,,,"Low",1,1,3, -FM-138,"cfusa_cyber_register_rules","cmd_cyber.c",300,,,,"Low",1,1,3, -FM-139,"for","cmd_cyber.c",302,,,,"Low",1,1,3, -FM-140,"cmd_cyber","cmd_cyber.c",306,,,,"Low",1,1,3, -FM-141,"cmd_safety_case","cmd_safety_case.c",12,,,,"High",1,1,9, -FM-142,"cmd_metrics","cmd_metrics.c",95,,,,"Low",1,1,3, -FM-143,"E=$","cmd_metrics.c",136,,,,"Low",1,1,3, -FM-144,"W=$","cmd_metrics.c",137,,,,"Low",1,1,3, -FM-145,"!strstr","cmd_lint.c",191,,,,"Low",1,1,3, -FM-146,"if","cmd_lint.c",196,,,,"Low",1,1,3, -FM-147,"while","cmd_lint.c",200,,,,"Low",1,1,3, -FM-148,"if","cmd_lint.c",211,,,,"Low",1,1,3, -FM-149,"!strstr","cmd_lint.c",307,,,,"Low",1,1,3, -FM-150,"cfusa_lint_register_rules","cmd_lint.c",447,,,,"Low",1,1,3, -FM-151,"cmd_lint","cmd_lint.c",455,,,,"Low",1,1,3, -FM-152,"setUp","test_engine.c",40,,,,"Low",1,1,3, -FM-153,"tearDown","test_engine.c",41,,,,"Low",1,1,3, -FM-154,"test_register_and_count","test_engine.c",43,,,,"Low",1,1,3, -FM-155,"test_run_all_calls_rules","test_engine.c",52,,,,"Low",1,1,3, -FM-156,"test_run_category_filters","test_engine.c",70,,,,"Low",1,1,3, -FM-157,"cfusa_engine_register","test_engine.c",72,,,,"Low",1,1,3, -FM-158,"cfusa_engine_register","test_engine.c",73,,,,"Low",1,1,3, -FM-159,"test_reset_clears_rules","test_engine.c",87,,,,"Low",1,1,3, -FM-160,"test_report_score_perfect","test_engine.c",95,,,,"Low",1,1,3, -FM-161,"test_report_score_with_errors","test_engine.c",103,,,,"High",1,1,9, -FM-162,"main","test_engine.c",112,,,,"Low",1,1,3, -FM-163,"setUp","test_config.c",5,,,,"Low",1,1,3, -FM-164,"tearDown","test_config.c",6,,,,"Low",1,1,3, -FM-165,"test_config_defaults","test_config.c",8,,,,"High",1,1,9, -FM-166,"test_config_defaults_extensions","test_config.c",22,,,,"High",1,1,9, -FM-167,"test_config_save_and_load","test_config.c",36,,,,"Medium",1,1,5, -FM-168,"test_config_is_excluded","test_config.c",58,,,,"Medium",1,1,5, -FM-169,"test_config_missing_file_uses_defaults","test_config.c",68,,,,"High",1,1,9, -FM-170,"main","test_config.c",76,,,,"Low",1,1,3, -FM-171,"setUp","test_utils.c",5,,,,"Low",1,1,3, -FM-172,"tearDown","test_utils.c",6,,,,"Low",1,1,3, -FM-173,"test_sha256_empty","test_utils.c",10,,,,"Low",1,1,3, -FM-174,"test_sha256_abc","test_utils.c",21,,,,"Low",1,1,3, -FM-175,"test_sha256_length","test_utils.c",31,,,,"Low",1,1,3, -FM-176,"test_hmac_sha256_known","test_utils.c",40,,,,"Low",1,1,3, -FM-177,"test_str_contains_found","test_utils.c",55,,,,"Low",1,1,3, -FM-178,"test_str_contains_not_found","test_utils.c",60,,,,"Low",1,1,3, -FM-179,"test_str_starts_with","test_utils.c",65,,,,"Low",1,1,3, -FM-180,"test_basename","test_utils.c",71,,,,"Low",1,1,3, -FM-181,"test_extension","test_utils.c",78,,,,"Low",1,1,3, -FM-182,"test_str_trim","test_utils.c",84,,,,"Low",1,1,3, -FM-183,"test_str_escape_json","test_utils.c",92,,,,"Low",1,1,3, -FM-184,"test_path_join","test_utils.c",99,,,,"Low",1,1,3, -FM-185,"test_path_join_trailing_slash","test_utils.c",106,,,,"Low",1,1,3, -FM-186,"main","test_utils.c",113,,,,"Low",1,1,3, -FM-187,"setUp","test_report.c",8,,,,"Low",1,1,3, -FM-188,"tearDown","test_report.c",9,,,,"Low",1,1,3, -FM-189,"test_report_init","test_report.c",11,,,,"Medium",1,1,5, -FM-190,"test_report_add_error","test_report.c",23,,,,"High",1,1,9, -FM-191,"test_report_add_warning","test_report.c",38,,,,"Low",1,1,3, -FM-192,"test_report_score_100","test_report.c",50,,,,"Low",1,1,3, -FM-193,"test_report_score_decreases_with_errors","test_report.c",58,,,,"High",1,1,9, -FM-194,"test_report_severity_str","test_report.c",69,,,,"Low",1,1,3, -FM-195,"test_format_parse","test_report.c",76,,,,"Low",1,1,3, -FM-196,"test_report_json_output","test_report.c",86,,,,"Low",1,1,3, -FM-197,"test_report_sarif_output","test_report.c",110,,,,"Low",1,1,3, -FM-198,"main","test_report.c",131,,,,"Low",1,1,3, -FM-199,"cfusa_report_init","report.c",10,,,,"Medium",1,1,5, -FM-200,"cfusa_report_free","report.c",23,,,,"Low",1,1,3, -FM-201,"cfusa_severity_str","report.c",69,,,,"Low",1,1,3, -FM-202,"cfusa_format_parse","report.c",79,,,,"Low",1,1,3, -FM-203,"cfusa_report_score","report.c",90,,,,"Low",1,1,3, -FM-204,"cfusa_report_score","report.c",106,,,,"Low",1,1,3, -FM-205,"cfusa_severity_str","report.c",112,,,,"Low",1,1,3, -FM-206,"cfusa_report_score","report.c",137,,,,"Low",1,1,3, -FM-207,"cfusa_severity_str","report.c",151,,,,"Low",1,1,3, -FM-208,"cfusa_report_score","report.c",213,,,,"Low",1,1,3, -FM-209,"cfusa_severity_str","report.c",228,,,,"Low",1,1,3, -FM-210,"cfusa_severity_str","report.c",229,,,,"Low",1,1,3, -FM-211,"cfusa_report_score","report.c",255,,,,"Low",1,1,3, -FM-212,"cfusa_severity_str","report.c",269,,,,"Low",1,1,3, -FM-213,"cfusa_report_print","report.c",276,,,,"Low",1,1,3, -FM-214,"cfusa_engine_reset","engine.c",8,,,,"Low",1,1,3, -FM-215,"cfusa_engine_register","engine.c",13,,,,"Low",1,1,3, -FM-216,"cfusa_engine_rule_count","engine.c",22,,,,"Low",1,1,3, -FM-217,"cfusa_engine_list_rules","engine.c",27,,,,"Low",1,1,3, -FM-218,"strcmp","utils.c",43,,,,"Low",1,1,3, -FM-219,"cfusa_read_file","utils.c",57,,,,"Low",1,1,3, -FM-220,"cfusa_file_exists","utils.c",75,,,,"Low",1,1,3, -FM-221,"cfusa_dir_exists","utils.c",81,,,,"Low",1,1,3, -FM-222,"cfusa_mkdir_p","utils.c",87,,,,"Low",1,1,3, -FM-223,"cfusa_scan_lines","utils.c",103,,,,"Low",1,1,3, -FM-224,"cfusa_basename","utils.c",121,,,,"Low",1,1,3, -FM-225,"cfusa_extension","utils.c",127,,,,"Low",1,1,3, -FM-226,"cfusa_str_contains","utils.c",134,,,,"Low",1,1,3, -FM-227,"cfusa_str_starts_with","utils.c",139,,,,"Low",1,1,3, -FM-228,"cfusa_str_trim","utils.c",144,,,,"Low",1,1,3, -FM-229,"cfusa_str_escape_json","utils.c",155,,,,"Low",1,1,3, -FM-230,"cfusa_path_join","utils.c",175,,,,"Low",1,1,3, -FM-231,"cfusa_sha256_buf","utils.c",297,,,,"Low",1,1,3, -FM-232,"cfusa_sha256_file","utils.c",309,,,,"Low",1,1,3, -FM-233,"cfusa_sha256_buf","utils.c",338,,,,"Low",1,1,3, -FM-234,"cfusa_timestamp_now","utils.c",369,,,,"Low",1,1,3, -FM-235,"cfusa_count_c_files","utils.c",385,,,,"Low",1,1,3, -FM-236,"cfusa_count_lines_in_file","utils.c",393,,,,"Low",1,1,3, -FM-237,"cfusa_match_outside_string","utils.c",405,,,,"Low",1,1,3, -FM-238,"cfusa_config_defaults","config.c",7,,,,"High",1,1,9, -FM-239,"cfusa_config_load","config.c",91,,,,"Medium",1,1,5, -FM-240,"extract_str_array_n","config.c",108,,,,"Low",1,1,3, -FM-241,"extract_str_array_n","config.c",111,,,,"Low",1,1,3, -FM-242,"cfusa_config_save","config.c",119,,,,"Medium",1,1,5, -FM-243,"cfusa_config_is_excluded","config.c",153,,,,"Medium",1,1,5, +ID,Function,File,Line,Failure Mode,Effect,Cause,Severity,O,D,ActionPriority +FM-001,"cmd_pr","cmd_pr.c",146,"cmd_pr (general function) does not perform its intended action","Failure of cmd_pr could propagate undetected to callers in cmd_pr.c","Logic error or untested edge case in cmd_pr",3,2,3,"low" +FM-002,"cmd_version","cmd_version.c",7,"cmd_version (general function) does not perform its intended action","Failure of cmd_version could propagate undetected to callers in cmd_version.c","Logic error or untested edge case in cmd_version",3,2,3,"low" +FM-003,"cmd_help","cmd_dispatch.c",66,"cmd_help (general function) does not perform its intended action","Failure of cmd_help could propagate undetected to callers in cmd_dispatch.c","Logic error or untested edge case in cmd_help",3,2,3,"low" +FM-004,"snprintf","cmd_coupling.c",56,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_coupling.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-005,"snprintf","cmd_coupling.c",65,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_coupling.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-006,"cmd_coupling","cmd_coupling.c",121,"cmd_coupling (general function) does not perform its intended action","Failure of cmd_coupling could propagate undetected to callers in cmd_coupling.c","Logic error or untested edge case in cmd_coupling",3,2,3,"low" +FM-007,"printf","cmd_coupling.c",177,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_coupling.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-008,"fn","cmd_qualify.c",347,"fn (general function) does not perform its intended action","Failure of fn could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in fn",3,2,3,"low" +FM-009,"fn","cmd_qualify.c",375,"fn (general function) does not perform its intended action","Failure of fn could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in fn",3,2,3,"low" +FM-010,"fn","cmd_qualify.c",398,"fn (general function) does not perform its intended action","Failure of fn could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in fn",3,2,3,"low" +FM-011,"fn","cmd_qualify.c",408,"fn (general function) does not perform its intended action","Failure of fn could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in fn",3,2,3,"low" +FM-012,"""strcpy","cmd_qualify.c",427,"""strcpy (general function) does not perform its intended action","Failure of ""strcpy could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in ""strcpy",3,2,3,"low" +FM-013,"""snprintf","cmd_qualify.c",428,"""snprintf (general function) does not perform its intended action","Failure of ""snprintf could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in ""snprintf",3,2,3,"low" +FM-014,"""MD5_Init","cmd_qualify.c",429,"""MD5_Init (general function) does not perform its intended action","Failure of ""MD5_Init could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in ""MD5_Init",3,2,3,"low" +FM-015,"""SHA256_Init","cmd_qualify.c",430,"""SHA256_Init (general function) does not perform its intended action","Failure of ""SHA256_Init could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in ""SHA256_Init",3,2,3,"low" +FM-016,"cmd_qualify","cmd_qualify.c",472,"cmd_qualify (general function) does not perform its intended action","Failure of cmd_qualify could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in cmd_qualify",3,2,3,"low" +FM-017,"qualification_badge","cmd_qualify.c",579,"qualification_badge (general function) does not perform its intended action","Failure of qualification_badge could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in qualification_badge",3,2,3,"low" +FM-018,"independence_status","cmd_qualify.c",580,"independence_status (general function) does not perform its intended action","Failure of independence_status could propagate undetected to callers in cmd_qualify.c","Logic error or untested edge case in independence_status",3,2,3,"low" +FM-019,"cmd_misra","cmd_misra.c",60,"cmd_misra (general function) does not perform its intended action","Failure of cmd_misra could propagate undetected to callers in cmd_misra.c","Logic error or untested edge case in cmd_misra",3,2,3,"low" +FM-020,"!path_exists","cmd_safety_rules.c",119,"!path_exists (general function) does not perform its intended action","Failure of !path_exists could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in !path_exists",3,2,3,"low" +FM-021,"strcmp","cmd_safety_rules.c",278,"strcmp (general function) does not perform its intended action","Failure of strcmp could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in strcmp",3,2,3,"low" +FM-022,"!path_exists","cmd_safety_rules.c",391,"!path_exists (general function) does not perform its intended action","Failure of !path_exists could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in !path_exists",3,2,3,"low" +FM-023,"sscanf","cmd_safety_rules.c",422,"sscanf (general function) does not perform its intended action","Failure of sscanf could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in sscanf",3,2,3,"low" +FM-024,"failure","cmd_safety_rules.c",483,"failure (general function) does not perform its intended action","Failure of failure could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in failure",3,2,3,"low" +FM-025,"!strchr","cmd_safety_rules.c",506,"!strchr (general function) does not perform its intended action","Failure of !strchr could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in !strchr",3,2,3,"low" +FM-026,"!strstr","cmd_safety_rules.c",507,"!strstr (general function) does not perform its intended action","Failure of !strstr could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in !strstr",3,2,3,"low" +FM-027,"strchr","cmd_safety_rules.c",544,"strchr (general function) does not perform its intended action","Failure of strchr could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in strchr",3,2,3,"low" +FM-028,"sscanf","cmd_safety_rules.c",614,"sscanf (general function) does not perform its intended action","Failure of sscanf could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in sscanf",3,2,3,"low" +FM-029,"strstr","cmd_safety_rules.c",724,"strstr (general function) does not perform its intended action","Failure of strstr could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in strstr",3,2,3,"low" +FM-030,"!path_exists","cmd_safety_rules.c",804,"!path_exists (general function) does not perform its intended action","Failure of !path_exists could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in !path_exists",3,2,3,"low" +FM-031,"!path_exists","cmd_safety_rules.c",818,"!path_exists (general function) does not perform its intended action","Failure of !path_exists could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in !path_exists",3,2,3,"low" +FM-032,"!path_exists","cmd_safety_rules.c",831,"!path_exists (general function) does not perform its intended action","Failure of !path_exists could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in !path_exists",3,2,3,"low" +FM-033,"""V","cmd_safety_rules.c",915,"""V (general function) does not perform its intended action","Failure of ""V could propagate undetected to callers in cmd_safety_rules.c","Logic error or untested edge case in ""V",3,2,3,"low" +FM-034,"cfusa_safety_register_rules","cmd_safety_rules.c",919,"cfusa_safety_register_rules (safety-critical function) does not perform its intended action","Failure of cfusa_safety_register_rules could propagate undetected to callers in cmd_safety_rules.c","Unhandled fault or invalid input condition within cfusa_safety_register_rules",9,4,6,"high" +FM-035,"cfusa_safety_rule_count","cmd_safety_rules.c",927,"cfusa_safety_rule_count (safety-critical function) does not perform its intended action","Failure of cfusa_safety_rule_count could propagate undetected to callers in cmd_safety_rules.c","Unhandled fault or invalid input condition within cfusa_safety_rule_count",9,4,6,"high" +FM-036,"cmd_iso26262","cmd_iso26262.c",84,"cmd_iso26262 (general function) does not perform its intended action","Failure of cmd_iso26262 could propagate undetected to callers in cmd_iso26262.c","Logic error or untested edge case in cmd_iso26262",3,2,3,"low" +FM-037,"fprintf","cmd_iso26262.c",183,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_iso26262.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-038,"fprintf","cmd_iso26262.c",206,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_iso26262.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-039,"cfusa_scan_lines","cmd_req.c",135,"cfusa_scan_lines (general function) does not perform its intended action","Failure of cfusa_scan_lines could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in cfusa_scan_lines",3,2,3,"low" +FM-040,"xml_escape","cmd_req.c",172,"xml_escape (general function) does not perform its intended action","Failure of xml_escape could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in xml_escape",3,2,3,"low" +FM-041,"xml_escape","cmd_req.c",176,"xml_escape (general function) does not perform its intended action","Failure of xml_escape could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in xml_escape",3,2,3,"low" +FM-042,"xml_escape","cmd_req.c",180,"xml_escape (general function) does not perform its intended action","Failure of xml_escape could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in xml_escape",3,2,3,"low" +FM-043,"fprintf","cmd_req.c",193,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-044,"fprintf","cmd_req.c",209,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-045,"fprintf","cmd_req.c",225,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-046,"snprintf","cmd_req.c",257,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-047,"!strcmp","cmd_req.c",520,"!strcmp (general function) does not perform its intended action","Failure of !strcmp could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in !strcmp",3,2,3,"low" +FM-048,"import_reqif","cmd_req.c",646,"import_reqif (general function) does not perform its intended action","Failure of import_reqif could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in import_reqif",3,2,3,"low" +FM-049,"import_polarion_xml","cmd_req.c",652,"import_polarion_xml (general function) does not perform its intended action","Failure of import_polarion_xml could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in import_polarion_xml",3,2,3,"low" +FM-050,"import_reqif","cmd_req.c",655,"import_reqif (general function) does not perform its intended action","Failure of import_reqif could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in import_reqif",3,2,3,"low" +FM-051,"import_codebeamer_xml","cmd_req.c",660,"import_codebeamer_xml (general function) does not perform its intended action","Failure of import_codebeamer_xml could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in import_codebeamer_xml",3,2,3,"low" +FM-052,"import_jama_xml","cmd_req.c",671,"import_jama_xml (general function) does not perform its intended action","Failure of import_jama_xml could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in import_jama_xml",3,2,3,"low" +FM-053,"sizeof","cmd_req.c",695,"sizeof (general function) does not perform its intended action","Failure of sizeof could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in sizeof",3,2,3,"low" +FM-054,"append_entry","cmd_req.c",713,"append_entry (general function) does not perform its intended action","Failure of append_entry could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in append_entry",3,2,3,"low" +FM-055,"printf","cmd_req.c",755,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-056,"cmd_req","cmd_req.c",760,"cmd_req (general function) does not perform its intended action","Failure of cmd_req could propagate undetected to callers in cmd_req.c","Logic error or untested edge case in cmd_req",3,2,3,"low" +FM-057,"cmd_release","cmd_release.c",100,"cmd_release (general function) does not perform its intended action","Failure of cmd_release could propagate undetected to callers in cmd_release.c","Logic error or untested edge case in cmd_release",3,2,3,"low" +FM-058,"snprintf","cmd_release.c",174,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_release.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-059,"cmd_check","cmd_check.c",14,"cmd_check (monitoring/control function) does not perform its intended action","Failure of cmd_check could propagate undetected to callers in cmd_check.c","Configuration or state inconsistency affecting cmd_check",5,3,4,"medium" +FM-060,"cfusa_template_generate_all","cmd_template.c",84,"cfusa_template_generate_all (general function) does not perform its intended action","Failure of cfusa_template_generate_all could propagate undetected to callers in cmd_template.c","Logic error or untested edge case in cfusa_template_generate_all",3,2,3,"low" +FM-061,"cmd_template","cmd_template.c",106,"cmd_template (general function) does not perform its intended action","Failure of cmd_template could propagate undetected to callers in cmd_template.c","Logic error or untested edge case in cmd_template",3,2,3,"low" +FM-062,"fprintf","cmd_tara.c",326,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_tara.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-063,"cmd_tara","cmd_tara.c",330,"cmd_tara (general function) does not perform its intended action","Failure of cmd_tara could propagate undetected to callers in cmd_tara.c","Logic error or untested edge case in cmd_tara",3,2,3,"low" +FM-064,"fprintf","cmd_tara.c",426,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_tara.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-065,"write_threat_json","cmd_tara.c",439,"write_threat_json (general function) does not perform its intended action","Failure of write_threat_json could propagate undetected to callers in cmd_tara.c","Logic error or untested edge case in write_threat_json",3,2,3,"low" +FM-066,"fprintf","cmd_tara.c",440,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_tara.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-067,"fprintf","cmd_tara.c",449,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_tara.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-068,"fprintf","cmd_tara.c",459,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_tara.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-069,"fprintf","cmd_tara.c",461,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_tara.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-070,"cfusa_scan_lines","cmd_trace.c",184,"cfusa_scan_lines (general function) does not perform its intended action","Failure of cfusa_scan_lines could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in cfusa_scan_lines",3,2,3,"low" +FM-071,"cmd_trace","cmd_trace.c",336,"cmd_trace (general function) does not perform its intended action","Failure of cmd_trace could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in cmd_trace",3,2,3,"low" +FM-072,"compute_hlr_llr","cmd_trace.c",436,"compute_hlr_llr (general function) does not perform its intended action","Failure of compute_hlr_llr could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in compute_hlr_llr",3,2,3,"low" +FM-073,"printf","cmd_trace.c",453,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-074,"LLR","cmd_trace.c",460,"LLR (general function) does not perform its intended action","Failure of LLR could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in LLR",3,2,3,"low" +FM-075,"printf","cmd_trace.c",478,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-076,"printf","cmd_trace.c",497,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-077,"printf","cmd_trace.c",530,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-078,"printf","cmd_trace.c",558,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-079,"snprintf","cmd_trace.c",696,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-080,"snprintf","cmd_trace.c",700,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-081,"cfusa_basename","cmd_trace.c",716,"cfusa_basename (general function) does not perform its intended action","Failure of cfusa_basename could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in cfusa_basename",3,2,3,"low" +FM-082,"snprintf","cmd_trace.c",763,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-083,"snprintf","cmd_trace.c",767,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-084,"fprintf","cmd_trace.c",790,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_trace.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-085,"for","cmd_analyze.c",25,"for (general function) does not perform its intended action","Failure of for could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in for",3,2,3,"low" +FM-086,"if","cmd_analyze.c",67,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in if",3,2,3,"low" +FM-087,"!strstr","cmd_analyze.c",68,"!strstr (general function) does not perform its intended action","Failure of !strstr could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in !strstr",3,2,3,"low" +FM-088,"strstr","cmd_analyze.c",102,"strstr (general function) does not perform its intended action","Failure of strstr could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in strstr",3,2,3,"low" +FM-089,"strstr","cmd_analyze.c",103,"strstr (general function) does not perform its intended action","Failure of strstr could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in strstr",3,2,3,"low" +FM-090,"!strstr","cmd_analyze.c",104,"!strstr (general function) does not perform its intended action","Failure of !strstr could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in !strstr",3,2,3,"low" +FM-091,"if","cmd_analyze.c",135,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in if",3,2,3,"low" +FM-092,"!strstr","cmd_analyze.c",136,"!strstr (general function) does not perform its intended action","Failure of !strstr could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in !strstr",3,2,3,"low" +FM-093,"if","cmd_analyze.c",167,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in if",3,2,3,"low" +FM-094,"""assert","cmd_analyze.c",171,"""assert (general function) does not perform its intended action","Failure of ""assert could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in ""assert",3,2,3,"low" +FM-095,"if","cmd_analyze.c",199,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in if",3,2,3,"low" +FM-096,"strstr","cmd_analyze.c",200,"strstr (general function) does not perform its intended action","Failure of strstr could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in strstr",3,2,3,"low" +FM-097,"strstr","cmd_analyze.c",201,"strstr (general function) does not perform its intended action","Failure of strstr could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in strstr",3,2,3,"low" +FM-098,"for","cmd_analyze.c",238,"for (general function) does not perform its intended action","Failure of for could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in for",3,2,3,"low" +FM-099,"""assert","cmd_analyze.c",284,"""assert (general function) does not perform its intended action","Failure of ""assert could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in ""assert",3,2,3,"low" +FM-100,"cfusa_analyze_register_rules","cmd_analyze.c",292,"cfusa_analyze_register_rules (general function) does not perform its intended action","Failure of cfusa_analyze_register_rules could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in cfusa_analyze_register_rules",3,2,3,"low" +FM-101,"cmd_analyze","cmd_analyze.c",298,"cmd_analyze (general function) does not perform its intended action","Failure of cmd_analyze could propagate undetected to callers in cmd_analyze.c","Logic error or untested edge case in cmd_analyze",3,2,3,"low" +FM-102,"cmd_report","cmd_report.c",14,"cmd_report (general function) does not perform its intended action","Failure of cmd_report could propagate undetected to callers in cmd_report.c","Logic error or untested edge case in cmd_report",3,2,3,"low" +FM-103,"cmd_init","cmd_init.c",15,"cmd_init (monitoring/control function) does not perform its intended action","Failure of cmd_init could propagate undetected to callers in cmd_init.c","Configuration or state inconsistency affecting cmd_init",5,3,4,"medium" +FM-104,"fprintf","cmd_init.c",99,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_init.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-105,"fprintf","cmd_init.c",116,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_init.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-106,"cmd_iec62443","cmd_iec62443.c",85,"cmd_iec62443 (general function) does not perform its intended action","Failure of cmd_iec62443 could propagate undetected to callers in cmd_iec62443.c","Logic error or untested edge case in cmd_iec62443",3,2,3,"low" +FM-107,"fprintf","cmd_iec62443.c",223,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_iec62443.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-108,"cfusa_basename","cmd_fmea.c",187,"cfusa_basename (general function) does not perform its intended action","Failure of cfusa_basename could propagate undetected to callers in cmd_fmea.c","Logic error or untested edge case in cfusa_basename",3,2,3,"low" +FM-109,"cfusa_basename","cmd_fmea.c",267,"cfusa_basename (general function) does not perform its intended action","Failure of cfusa_basename could propagate undetected to callers in cmd_fmea.c","Logic error or untested edge case in cfusa_basename",3,2,3,"low" +FM-110,"cmd_fmea","cmd_fmea.c",274,"cmd_fmea (general function) does not perform its intended action","Failure of cmd_fmea could propagate undetected to callers in cmd_fmea.c","Logic error or untested edge case in cmd_fmea",3,2,3,"low" +FM-111,"fprintf","cmd_fmea.c",383,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_fmea.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-112,"fprintf","cmd_fmea.c",393,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_fmea.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-113,"cfusa_path_join","cmd_fmea.c",399,"cfusa_path_join (general function) does not perform its intended action","Failure of cfusa_path_join could propagate undetected to callers in cmd_fmea.c","Logic error or untested edge case in cfusa_path_join",3,2,3,"low" +FM-114,"printf","cmd_fmea.c",402,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_fmea.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-115,"cfusa_basename","cmd_fmea.c",442,"cfusa_basename (general function) does not perform its intended action","Failure of cfusa_basename could propagate undetected to callers in cmd_fmea.c","Logic error or untested edge case in cfusa_basename",3,2,3,"low" +FM-116,"cfusa_basename","cmd_fmea.c",506,"cfusa_basename (general function) does not perform its intended action","Failure of cfusa_basename could propagate undetected to callers in cmd_fmea.c","Logic error or untested edge case in cfusa_basename",3,2,3,"low" +FM-117,"cfusa_basename","cmd_fmea.c",534,"cfusa_basename (general function) does not perform its intended action","Failure of cfusa_basename could propagate undetected to callers in cmd_fmea.c","Logic error or untested edge case in cfusa_basename",3,2,3,"low" +FM-118,"strtol","cmd_fix.c",50,"strtol (general function) does not perform its intended action","Failure of strtol could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in strtol",3,2,3,"low" +FM-119,"fgets","cmd_fix.c",57,"fgets (general function) does not perform its intended action","Failure of fgets could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in fgets",3,2,3,"low" +FM-120,"strncpy","cmd_fix.c",58,"strncpy (general function) does not perform its intended action","Failure of strncpy could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in strncpy",3,2,3,"low" +FM-121,"snprintf","cmd_fix.c",59,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-122,"malloc","cmd_fix.c",63,"malloc (general function) does not perform its intended action","Failure of malloc could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in malloc",3,2,3,"low" +FM-123,"assert","cmd_fix.c",73,"assert (general function) does not perform its intended action","Failure of assert could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in assert",3,2,3,"low" +FM-124,"strncpy","cmd_fix.c",80,"strncpy (general function) does not perform its intended action","Failure of strncpy could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in strncpy",3,2,3,"low" +FM-125,"dst[sizeof","cmd_fix.c",81,"dst[sizeof (general function) does not perform its intended action","Failure of dst[sizeof could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in dst[sizeof",3,2,3,"low" +FM-126,"printf","cmd_fix.c",85,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-127,"printf","cmd_fix.c",86,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-128,"execve","cmd_fix.c",90,"execve (general function) does not perform its intended action","Failure of execve could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in execve",3,2,3,"low" +FM-129,"sizeof","cmd_fix.c",97,"sizeof (general function) does not perform its intended action","Failure of sizeof could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in sizeof",3,2,3,"low" +FM-130,"malloc","cmd_fix.c",99,"malloc (general function) does not perform its intended action","Failure of malloc could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in malloc",3,2,3,"low" +FM-131,"free","cmd_fix.c",103,"free (general function) does not perform its intended action","Failure of free could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in free",3,2,3,"low" +FM-132,"cmd_fix","cmd_fix.c",125,"cmd_fix (general function) does not perform its intended action","Failure of cmd_fix could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in cmd_fix",3,2,3,"low" +FM-133,"printf","cmd_fix.c",175,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-134,"printf","cmd_fix.c",195,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_fix.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-135,"main","main.c",14,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in main.c","Logic error or untested edge case in main",3,2,3,"low" +FM-136,"cmd_boundary","cmd_boundary.c",72,"cmd_boundary (general function) does not perform its intended action","Failure of cmd_boundary could propagate undetected to callers in cmd_boundary.c","Logic error or untested edge case in cmd_boundary",3,2,3,"low" +FM-137,"cmd_impact","cmd_impact.c",106,"cmd_impact (general function) does not perform its intended action","Failure of cmd_impact could propagate undetected to callers in cmd_impact.c","Logic error or untested edge case in cmd_impact",3,2,3,"low" +FM-138,"printf","cmd_impact.c",194,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_impact.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-139,"cmd_sci","cmd_sci.c",44,"cmd_sci (general function) does not perform its intended action","Failure of cmd_sci could propagate undetected to callers in cmd_sci.c","Logic error or untested edge case in cmd_sci",3,2,3,"low" +FM-140,"cmd_iec61508","cmd_iec61508.c",78,"cmd_iec61508 (general function) does not perform its intended action","Failure of cmd_iec61508 could propagate undetected to callers in cmd_iec61508.c","Logic error or untested edge case in cmd_iec61508",3,2,3,"low" +FM-141,"fprintf","cmd_iec61508.c",204,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_iec61508.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-142,"cmd_badge","cmd_badge.c",9,"cmd_badge (general function) does not perform its intended action","Failure of cmd_badge could propagate undetected to callers in cmd_badge.c","Logic error or untested edge case in cmd_badge",3,2,3,"low" +FM-143,"fill=\""url","cmd_badge.c",87,"fill=\""url (general function) does not perform its intended action","Failure of fill=\""url could propagate undetected to callers in cmd_badge.c","Logic error or untested edge case in fill=\""url",3,2,3,"low" +FM-144,"cmd_unece","cmd_unece.c",57,"cmd_unece (general function) does not perform its intended action","Failure of cmd_unece could propagate undetected to callers in cmd_unece.c","Logic error or untested edge case in cmd_unece",3,2,3,"low" +FM-145,"cmd_sign","cmd_sign.c",43,"cmd_sign (general function) does not perform its intended action","Failure of cmd_sign could propagate undetected to callers in cmd_sign.c","Logic error or untested edge case in cmd_sign",3,2,3,"low" +FM-146,"cfusa_hmac_sha256","cmd_sign.c",120,"cfusa_hmac_sha256 (general function) does not perform its intended action","Failure of cfusa_hmac_sha256 could propagate undetected to callers in cmd_sign.c","Logic error or untested edge case in cfusa_hmac_sha256",3,2,3,"low" +FM-147,"cmd_iso21434","cmd_iso21434.c",77,"cmd_iso21434 (general function) does not perform its intended action","Failure of cmd_iso21434 could propagate undetected to callers in cmd_iso21434.c","Logic error or untested edge case in cmd_iso21434",3,2,3,"low" +FM-148,"fprintf","cmd_iso21434.c",212,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_iso21434.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-149,"""gets","cmd_vuln.c",26,"""gets (general function) does not perform its intended action","Failure of ""gets could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in ""gets",3,2,3,"low" +FM-150,"fgets","cmd_vuln.c",27,"fgets (general function) does not perform its intended action","Failure of fgets could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in fgets",3,2,3,"low" +FM-151,"""sprintf","cmd_vuln.c",29,"""sprintf (general function) does not perform its intended action","Failure of ""sprintf could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in ""sprintf",3,2,3,"low" +FM-152,"snprintf","cmd_vuln.c",30,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-153,"""strcpy","cmd_vuln.c",32,"""strcpy (general function) does not perform its intended action","Failure of ""strcpy could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in ""strcpy",3,2,3,"low" +FM-154,"strlcpy","cmd_vuln.c",33,"strlcpy (general function) does not perform its intended action","Failure of strlcpy could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in strlcpy",3,2,3,"low" +FM-155,"""strcat","cmd_vuln.c",35,"""strcat (general function) does not perform its intended action","Failure of ""strcat could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in ""strcat",3,2,3,"low" +FM-156,"strlcat","cmd_vuln.c",36,"strlcat (general function) does not perform its intended action","Failure of strlcat could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in strlcat",3,2,3,"low" +FM-157,"scanf","cmd_vuln.c",39,"scanf (general function) does not perform its intended action","Failure of scanf could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in scanf",3,2,3,"low" +FM-158,"""tmpnam","cmd_vuln.c",41,"""tmpnam (general function) does not perform its intended action","Failure of ""tmpnam could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in ""tmpnam",3,2,3,"low" +FM-159,"mkstemp","cmd_vuln.c",42,"mkstemp (general function) does not perform its intended action","Failure of mkstemp could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in mkstemp",3,2,3,"low" +FM-160,"""system","cmd_vuln.c",44,"""system (general function) does not perform its intended action","Failure of ""system could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in ""system",3,2,3,"low" +FM-161,"system","cmd_vuln.c",45,"system (general function) does not perform its intended action","Failure of system could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in system",3,2,3,"low" +FM-162,"""rand","cmd_vuln.c",47,"""rand (general function) does not perform its intended action","Failure of ""rand could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in ""rand",3,2,3,"low" +FM-163,"""mktemp","cmd_vuln.c",50,"""mktemp (general function) does not perform its intended action","Failure of ""mktemp could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in ""mktemp",3,2,3,"low" +FM-164,"mkstemp","cmd_vuln.c",51,"mkstemp (general function) does not perform its intended action","Failure of mkstemp could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in mkstemp",3,2,3,"low" +FM-165,"""popen","cmd_vuln.c",53,"""popen (general function) does not perform its intended action","Failure of ""popen could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in ""popen",3,2,3,"low" +FM-166,"execv","cmd_vuln.c",54,"execv (general function) does not perform its intended action","Failure of execv could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in execv",3,2,3,"low" +FM-167,"cfusa_scan_lines","cmd_vuln.c",107,"cfusa_scan_lines (general function) does not perform its intended action","Failure of cfusa_scan_lines could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in cfusa_scan_lines",3,2,3,"low" +FM-168,"cmd_vuln","cmd_vuln.c",109,"cmd_vuln (general function) does not perform its intended action","Failure of cmd_vuln could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in cmd_vuln",3,2,3,"low" +FM-169,"printf","cmd_vuln.c",181,"printf (general function) does not perform its intended action","Failure of printf could propagate undetected to callers in cmd_vuln.c","Logic error or untested edge case in printf",3,2,3,"low" +FM-170,"strstr","cmd_comp.c",102,"strstr (general function) does not perform its intended action","Failure of strstr could propagate undetected to callers in cmd_comp.c","Logic error or untested edge case in strstr",3,2,3,"low" +FM-171,"fprintf","cmd_comp.c",184,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_comp.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-172,"cmd_comp","cmd_comp.c",222,"cmd_comp (general function) does not perform its intended action","Failure of cmd_comp could propagate undetected to callers in cmd_comp.c","Logic error or untested edge case in cmd_comp",3,2,3,"low" +FM-173,"cmd_audit_pack","cmd_audit_pack.c",21,"cmd_audit_pack (general function) does not perform its intended action","Failure of cmd_audit_pack could propagate undetected to callers in cmd_audit_pack.c","Logic error or untested edge case in cmd_audit_pack",3,2,3,"low" +FM-174,"snprintf","cmd_audit_pack.c",149,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_audit_pack.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-175,"snprintf","cmd_audit_pack.c",162,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_audit_pack.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-176,"snprintf","cmd_audit_pack.c",187,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_audit_pack.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-177,"cmd_hooks","cmd_hooks.c",20,"cmd_hooks (general function) does not perform its intended action","Failure of cmd_hooks could propagate undetected to callers in cmd_hooks.c","Logic error or untested edge case in cmd_hooks",3,2,3,"low" +FM-178,"cmd_disposition","cmd_disposition.c",184,"cmd_disposition (general function) does not perform its intended action","Failure of cmd_disposition could propagate undetected to callers in cmd_disposition.c","Logic error or untested edge case in cmd_disposition",3,2,3,"low" +FM-179,"strcmp","cmd_disposition.c",261,"strcmp (general function) does not perform its intended action","Failure of strcmp could propagate undetected to callers in cmd_disposition.c","Logic error or untested edge case in strcmp",3,2,3,"low" +FM-180,"snprintf","cmd_coverage.c",42,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_coverage.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-181,"snprintf","cmd_coverage.c",81,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_coverage.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-182,"snprintf","cmd_coverage.c",93,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_coverage.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-183,"cmd_coverage","cmd_coverage.c",174,"cmd_coverage (general function) does not perform its intended action","Failure of cmd_coverage could propagate undetected to callers in cmd_coverage.c","Logic error or untested edge case in cmd_coverage",3,2,3,"low" +FM-184,"strcmp","cmd_coverage.c",258,"strcmp (general function) does not perform its intended action","Failure of strcmp could propagate undetected to callers in cmd_coverage.c","Logic error or untested edge case in strcmp",3,2,3,"low" +FM-185,"fprintf","cmd_coverage.c",408,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_coverage.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-186,"fprintf","cmd_coverage.c",411,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_coverage.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-187,"fprintf","cmd_coverage.c",413,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_coverage.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-188,"fprintf","cmd_coverage.c",425,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_coverage.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-189,"cmd_diff","cmd_diff.c",66,"cmd_diff (general function) does not perform its intended action","Failure of cmd_diff could propagate undetected to callers in cmd_diff.c","Logic error or untested edge case in cmd_diff",3,2,3,"low" +FM-190,"fprintf","cmd_hara.c",622,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_hara.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-191,"parse_sec_code","cmd_hara.c",650,"parse_sec_code (general function) does not perform its intended action","Failure of parse_sec_code could propagate undetected to callers in cmd_hara.c","Logic error or untested edge case in parse_sec_code",3,2,3,"low" +FM-192,"cmd_hara","cmd_hara.c",770,"cmd_hara (general function) does not perform its intended action","Failure of cmd_hara could propagate undetected to callers in cmd_hara.c","Logic error or untested edge case in cmd_hara",3,2,3,"low" +FM-193,"cmd_slsa","cmd_slsa.c",71,"cmd_slsa (general function) does not perform its intended action","Failure of cmd_slsa could propagate undetected to callers in cmd_slsa.c","Logic error or untested edge case in cmd_slsa",3,2,3,"low" +FM-194,"slsa_file_exists","cmd_slsa.c",123,"slsa_file_exists (general function) does not perform its intended action","Failure of slsa_file_exists could propagate undetected to callers in cmd_slsa.c","Logic error or untested edge case in slsa_file_exists",3,2,3,"low" +FM-195,"cmd_do178","cmd_do178.c",113,"cmd_do178 (general function) does not perform its intended action","Failure of cmd_do178 could propagate undetected to callers in cmd_do178.c","Logic error or untested edge case in cmd_do178",3,2,3,"low" +FM-196,"cmd_verify","cmd_verify.c",14,"cmd_verify (general function) does not perform its intended action","Failure of cmd_verify could propagate undetected to callers in cmd_verify.c","Logic error or untested edge case in cmd_verify",3,2,3,"low" +FM-197,"fprintf","cmd_sas.c",61,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_sas.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-198,"cmd_sas","cmd_sas.c",90,"cmd_sas (general function) does not perform its intended action","Failure of cmd_sas could propagate undetected to callers in cmd_sas.c","Logic error or untested edge case in cmd_sas",3,2,3,"low" +FM-199,"fprintf","cmd_sas.c",178,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_sas.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-200,"fprintf","cmd_sas.c",255,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_sas.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-201,"for","cmd_cyber.c",19,"for (general function) does not perform its intended action","Failure of for could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in for",3,2,3,"low" +FM-202,"if","cmd_cyber.c",22,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-203,"||","cmd_cyber.c",23,"|| (general function) does not perform its intended action","Failure of || could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in ||",3,2,3,"low" +FM-204,"for","cmd_cyber.c",51,"for (general function) does not perform its intended action","Failure of for could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in for",3,2,3,"low" +FM-205,"if","cmd_cyber.c",55,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-206,"if","cmd_cyber.c",63,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-207,"if","cmd_cyber.c",71,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-208,"strncmp","cmd_cyber.c",72,"strncmp (general function) does not perform its intended action","Failure of strncmp could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in strncmp",3,2,3,"low" +FM-209,"for","cmd_cyber.c",96,"for (general function) does not perform its intended action","Failure of for could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in for",3,2,3,"low" +FM-210,"if","cmd_cyber.c",103,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-211,"if","cmd_cyber.c",155,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-212,"strstr","cmd_cyber.c",156,"strstr (general function) does not perform its intended action","Failure of strstr could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in strstr",3,2,3,"low" +FM-213,"if","cmd_cyber.c",179,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-214,"free","cmd_cyber.c",182,"free (general function) does not perform its intended action","Failure of free could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in free",3,2,3,"low" +FM-215,"if","cmd_cyber.c",204,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-216,"if","cmd_cyber.c",223,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-217,"cfusa_match_outside_string","cmd_cyber.c",224,"cfusa_match_outside_string (general function) does not perform its intended action","Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in cfusa_match_outside_string",3,2,3,"low" +FM-218,"mkstemp","cmd_cyber.c",227,"mkstemp (general function) does not perform its intended action","Failure of mkstemp could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in mkstemp",3,2,3,"low" +FM-219,"for","cmd_cyber.c",246,"for (general function) does not perform its intended action","Failure of for could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in for",3,2,3,"low" +FM-220,"if","cmd_cyber.c",247,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-221,"for","cmd_cyber.c",270,"for (general function) does not perform its intended action","Failure of for could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in for",3,2,3,"low" +FM-222,"if","cmd_cyber.c",274,"if (general function) does not perform its intended action","Failure of if could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in if",3,2,3,"low" +FM-223,"cfusa_match_outside_string","cmd_cyber.c",329,"cfusa_match_outside_string (general function) does not perform its intended action","Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in cfusa_match_outside_string",3,2,3,"low" +FM-224,"cfusa_match_outside_string","cmd_cyber.c",349,"cfusa_match_outside_string (general function) does not perform its intended action","Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in cfusa_match_outside_string",3,2,3,"low" +FM-225,"cfusa_match_outside_string","cmd_cyber.c",350,"cfusa_match_outside_string (general function) does not perform its intended action","Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in cfusa_match_outside_string",3,2,3,"low" +FM-226,"realpath","cmd_cyber.c",352,"realpath (general function) does not perform its intended action","Failure of realpath could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in realpath",3,2,3,"low" +FM-227,"TLS_method","cmd_cyber.c",378,"TLS_method (general function) does not perform its intended action","Failure of TLS_method could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in TLS_method",3,2,3,"low" +FM-228,"cfusa_match_outside_string","cmd_cyber.c",445,"cfusa_match_outside_string (general function) does not perform its intended action","Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in cfusa_match_outside_string",3,2,3,"low" +FM-229,"cfusa_match_outside_string","cmd_cyber.c",479,"cfusa_match_outside_string (general function) does not perform its intended action","Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in cfusa_match_outside_string",3,2,3,"low" +FM-230,"access","cmd_cyber.c",503,"access (general function) does not perform its intended action","Failure of access could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in access",3,2,3,"low" +FM-231,"cfusa_cyber_register_rules","cmd_cyber.c",564,"cfusa_cyber_register_rules (general function) does not perform its intended action","Failure of cfusa_cyber_register_rules could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in cfusa_cyber_register_rules",3,2,3,"low" +FM-232,"for","cmd_cyber.c",566,"for (general function) does not perform its intended action","Failure of for could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in for",3,2,3,"low" +FM-233,"cmd_cyber","cmd_cyber.c",570,"cmd_cyber (general function) does not perform its intended action","Failure of cmd_cyber could propagate undetected to callers in cmd_cyber.c","Logic error or untested edge case in cmd_cyber",3,2,3,"low" +FM-234,"cmd_safety_case","cmd_safety_case.c",35,"cmd_safety_case (safety-critical function) does not perform its intended action","Failure of cmd_safety_case could propagate undetected to callers in cmd_safety_case.c","Unhandled fault or invalid input condition within cmd_safety_case",9,4,6,"high" +FM-235,"snprintf","cmd_safety_case.c",106,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_safety_case.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-236,"snprintf","cmd_safety_case.c",110,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_safety_case.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-237,"snprintf","cmd_safety_case.c",113,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_safety_case.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-238,"snprintf","cmd_safety_case.c",116,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_safety_case.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-239,"snprintf","cmd_safety_case.c",119,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in cmd_safety_case.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-240,"fprintf","cmd_safety_case.c",223,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_safety_case.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-241,"fprintf","cmd_safety_case.c",317,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_safety_case.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-242,"cmd_metrics","cmd_metrics.c",288,"cmd_metrics (general function) does not perform its intended action","Failure of cmd_metrics could propagate undetected to callers in cmd_metrics.c","Logic error or untested edge case in cmd_metrics",3,2,3,"low" +FM-243,"cmd_capabilities","cmd_capabilities.c",15,"cmd_capabilities (general function) does not perform its intended action","Failure of cmd_capabilities could propagate undetected to callers in cmd_capabilities.c","Logic error or untested edge case in cmd_capabilities",3,2,3,"low" +FM-244,"fprintf","cmd_capabilities.c",86,"fprintf (general function) does not perform its intended action","Failure of fprintf could propagate undetected to callers in cmd_capabilities.c","Logic error or untested edge case in fprintf",3,2,3,"low" +FM-245,"strstr","cmd_lint.c",42,"strstr (general function) does not perform its intended action","Failure of strstr could propagate undetected to callers in cmd_lint.c","Logic error or untested edge case in strstr",3,2,3,"low" +FM-246,"fgets","cmd_lint.c",186,"fgets (general function) does not perform its intended action","Failure of fgets could propagate undetected to callers in cmd_lint.c","Logic error or untested edge case in fgets",3,2,3,"low" +FM-247,"strstr","cmd_lint.c",220,"strstr (general function) does not perform its intended action","Failure of strstr could propagate undetected to callers in cmd_lint.c","Logic error or untested edge case in strstr",3,2,3,"low" +FM-248,"!strstr","cmd_lint.c",222,"!strstr (general function) does not perform its intended action","Failure of !strstr could propagate undetected to callers in cmd_lint.c","Logic error or untested edge case in !strstr",3,2,3,"low" +FM-249,"!strstr","cmd_lint.c",384,"!strstr (general function) does not perform its intended action","Failure of !strstr could propagate undetected to callers in cmd_lint.c","Logic error or untested edge case in !strstr",3,2,3,"low" +FM-250,"cfusa_lint_register_rules","cmd_lint.c",527,"cfusa_lint_register_rules (general function) does not perform its intended action","Failure of cfusa_lint_register_rules could propagate undetected to callers in cmd_lint.c","Logic error or untested edge case in cfusa_lint_register_rules",3,2,3,"low" +FM-251,"cmd_lint","cmd_lint.c",535,"cmd_lint (general function) does not perform its intended action","Failure of cmd_lint could propagate undetected to callers in cmd_lint.c","Logic error or untested edge case in cmd_lint",3,2,3,"low" +FM-252,"defined","CMakeCCompilerId.c",891,"defined (general function) does not perform its intended action","Failure of defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in defined",3,2,3,"low" +FM-253,"!defined","CMakeCCompilerId.c",892,"!defined (general function) does not perform its intended action","Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in !defined",3,2,3,"low" +FM-254,"main","CMakeCCompilerId.c",902,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-255,"main","CMakeCCompilerId.c",907,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-256,"defined","CMakeCCompilerId.c",891,"defined (general function) does not perform its intended action","Failure of defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in defined",3,2,3,"low" +FM-257,"!defined","CMakeCCompilerId.c",892,"!defined (general function) does not perform its intended action","Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in !defined",3,2,3,"low" +FM-258,"main","CMakeCCompilerId.c",902,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-259,"main","CMakeCCompilerId.c",907,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-260,"defined","CMakeCCompilerId.c",891,"defined (general function) does not perform its intended action","Failure of defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in defined",3,2,3,"low" +FM-261,"!defined","CMakeCCompilerId.c",892,"!defined (general function) does not perform its intended action","Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in !defined",3,2,3,"low" +FM-262,"main","CMakeCCompilerId.c",902,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-263,"main","CMakeCCompilerId.c",907,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-264,"defined","CMakeCCompilerId.c",891,"defined (general function) does not perform its intended action","Failure of defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in defined",3,2,3,"low" +FM-265,"!defined","CMakeCCompilerId.c",892,"!defined (general function) does not perform its intended action","Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in !defined",3,2,3,"low" +FM-266,"main","CMakeCCompilerId.c",902,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-267,"main","CMakeCCompilerId.c",907,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-268,"defined","CMakeCCompilerId.c",891,"defined (general function) does not perform its intended action","Failure of defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in defined",3,2,3,"low" +FM-269,"!defined","CMakeCCompilerId.c",892,"!defined (general function) does not perform its intended action","Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in !defined",3,2,3,"low" +FM-270,"main","CMakeCCompilerId.c",902,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-271,"main","CMakeCCompilerId.c",907,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-272,"defined","CMakeCCompilerId.c",891,"defined (general function) does not perform its intended action","Failure of defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in defined",3,2,3,"low" +FM-273,"!defined","CMakeCCompilerId.c",892,"!defined (general function) does not perform its intended action","Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in !defined",3,2,3,"low" +FM-274,"main","CMakeCCompilerId.c",902,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-275,"main","CMakeCCompilerId.c",907,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-276,"defined","CMakeCCompilerId.c",891,"defined (general function) does not perform its intended action","Failure of defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in defined",3,2,3,"low" +FM-277,"!defined","CMakeCCompilerId.c",892,"!defined (general function) does not perform its intended action","Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in !defined",3,2,3,"low" +FM-278,"main","CMakeCCompilerId.c",902,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-279,"main","CMakeCCompilerId.c",907,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-280,"defined","CMakeCCompilerId.c",891,"defined (general function) does not perform its intended action","Failure of defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in defined",3,2,3,"low" +FM-281,"!defined","CMakeCCompilerId.c",892,"!defined (general function) does not perform its intended action","Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in !defined",3,2,3,"low" +FM-282,"main","CMakeCCompilerId.c",902,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-283,"main","CMakeCCompilerId.c",907,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-284,"defined","CMakeCCompilerId.c",891,"defined (general function) does not perform its intended action","Failure of defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in defined",3,2,3,"low" +FM-285,"!defined","CMakeCCompilerId.c",892,"!defined (general function) does not perform its intended action","Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in !defined",3,2,3,"low" +FM-286,"main","CMakeCCompilerId.c",902,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-287,"main","CMakeCCompilerId.c",907,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-288,"defined","CMakeCCompilerId.c",891,"defined (general function) does not perform its intended action","Failure of defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in defined",3,2,3,"low" +FM-289,"!defined","CMakeCCompilerId.c",892,"!defined (general function) does not perform its intended action","Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in !defined",3,2,3,"low" +FM-290,"main","CMakeCCompilerId.c",902,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-291,"main","CMakeCCompilerId.c",907,"main (general function) does not perform its intended action","Failure of main could propagate undetected to callers in CMakeCCompilerId.c","Logic error or untested edge case in main",3,2,3,"low" +FM-292,"cfusa_watchdog_kick","cfusa_runtime.c",26,"cfusa_watchdog_kick (safety-critical function) does not perform its intended action","Failure of cfusa_watchdog_kick could propagate undetected to callers in cfusa_runtime.c","Unhandled fault or invalid input condition within cfusa_watchdog_kick",9,4,6,"high" +FM-293,"cfusa_watchdog_check","cfusa_runtime.c",33,"cfusa_watchdog_check (safety-critical function) does not perform its intended action","Failure of cfusa_watchdog_check could propagate undetected to callers in cfusa_runtime.c","Unhandled fault or invalid input condition within cfusa_watchdog_check",9,4,6,"high" +FM-294,"cfusa_watchdog_stop","cfusa_runtime.c",43,"cfusa_watchdog_stop (safety-critical function) does not perform its intended action","Failure of cfusa_watchdog_stop could propagate undetected to callers in cfusa_runtime.c","Unhandled fault or invalid input condition within cfusa_watchdog_stop",9,4,6,"high" +FM-295,"cfusa_watchdog_fired","cfusa_runtime.c",48,"cfusa_watchdog_fired (safety-critical function) does not perform its intended action","Failure of cfusa_watchdog_fired could propagate undetected to callers in cfusa_runtime.c","Unhandled fault or invalid input condition within cfusa_watchdog_fired",9,4,6,"high" +FM-296,"cfusa_heartbeat_beat","cfusa_runtime.c",67,"cfusa_heartbeat_beat (general function) does not perform its intended action","Failure of cfusa_heartbeat_beat could propagate undetected to callers in cfusa_runtime.c","Logic error or untested edge case in cfusa_heartbeat_beat",3,2,3,"low" +FM-297,"cfusa_heartbeat_check","cfusa_runtime.c",74,"cfusa_heartbeat_check (monitoring/control function) does not perform its intended action","Failure of cfusa_heartbeat_check could propagate undetected to callers in cfusa_runtime.c","Configuration or state inconsistency affecting cfusa_heartbeat_check",5,3,4,"medium" +FM-298,"cfusa_heartbeat_stop","cfusa_runtime.c",85,"cfusa_heartbeat_stop (general function) does not perform its intended action","Failure of cfusa_heartbeat_stop could propagate undetected to callers in cfusa_runtime.c","Logic error or untested edge case in cfusa_heartbeat_stop",3,2,3,"low" +FM-299,"cfusa_heartbeat_missed","cfusa_runtime.c",90,"cfusa_heartbeat_missed (general function) does not perform its intended action","Failure of cfusa_heartbeat_missed could propagate undetected to callers in cfusa_runtime.c","Logic error or untested edge case in cfusa_heartbeat_missed",3,2,3,"low" +FM-300,"cfusa_state_get","cfusa_runtime.c",107,"cfusa_state_get (general function) does not perform its intended action","Failure of cfusa_state_get could propagate undetected to callers in cfusa_runtime.c","Logic error or untested edge case in cfusa_state_get",3,2,3,"low" +FM-301,"cfusa_state_transition","cfusa_runtime.c",112,"cfusa_state_transition (general function) does not perform its intended action","Failure of cfusa_state_transition could propagate undetected to callers in cfusa_runtime.c","Logic error or untested edge case in cfusa_state_transition",3,2,3,"low" +FM-302,"cfusa_state_name","cfusa_runtime.c",123,"cfusa_state_name (general function) does not perform its intended action","Failure of cfusa_state_name could propagate undetected to callers in cfusa_runtime.c","Logic error or untested edge case in cfusa_state_name",3,2,3,"low" +FM-303,"cfusa_diag_init","cfusa_runtime.c",137,"cfusa_diag_init (monitoring/control function) does not perform its intended action","Failure of cfusa_diag_init could propagate undetected to callers in cfusa_runtime.c","Configuration or state inconsistency affecting cfusa_diag_init",5,3,4,"medium" +FM-304,"cfusa_diag_count","cfusa_runtime.c",160,"cfusa_diag_count (general function) does not perform its intended action","Failure of cfusa_diag_count could propagate undetected to callers in cfusa_runtime.c","Logic error or untested edge case in cfusa_diag_count",3,2,3,"low" +FM-305,"cfusa_diag_get","cfusa_runtime.c",165,"cfusa_diag_get (general function) does not perform its intended action","Failure of cfusa_diag_get could propagate undetected to callers in cfusa_runtime.c","Logic error or untested edge case in cfusa_diag_get",3,2,3,"low" +FM-306,"cfusa_diag_clear","cfusa_runtime.c",174,"cfusa_diag_clear (general function) does not perform its intended action","Failure of cfusa_diag_clear could propagate undetected to callers in cfusa_runtime.c","Logic error or untested edge case in cfusa_diag_clear",3,2,3,"low" +FM-307,"cfusa_diag_level_name","cfusa_runtime.c",179,"cfusa_diag_level_name (general function) does not perform its intended action","Failure of cfusa_diag_level_name could propagate undetected to callers in cfusa_runtime.c","Logic error or untested edge case in cfusa_diag_level_name",3,2,3,"low" +FM-308,"cfusa_fault_record","cfusa_runtime.c",223,"cfusa_fault_record (safety-critical function) does not perform its intended action","Failure of cfusa_fault_record could propagate undetected to callers in cfusa_runtime.c","Unhandled fault or invalid input condition within cfusa_fault_record",9,4,6,"high" +FM-309,"cfusa_fault_reset","cfusa_runtime.c",233,"cfusa_fault_reset (safety-critical function) does not perform its intended action","Failure of cfusa_fault_reset could propagate undetected to callers in cfusa_runtime.c","Unhandled fault or invalid input condition within cfusa_fault_reset",9,4,6,"high" +FM-310,"cfusa_fault_count","cfusa_runtime.c",240,"cfusa_fault_count (safety-critical function) does not perform its intended action","Failure of cfusa_fault_count could propagate undetected to callers in cfusa_runtime.c","Unhandled fault or invalid input condition within cfusa_fault_count",9,4,6,"high" +FM-311,"cfusa_report_init","report.c",14,"cfusa_report_init (monitoring/control function) does not perform its intended action","Failure of cfusa_report_init could propagate undetected to callers in report.c","Configuration or state inconsistency affecting cfusa_report_init",5,3,4,"medium" +FM-312,"cfusa_report_free","report.c",27,"cfusa_report_free (general function) does not perform its intended action","Failure of cfusa_report_free could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_report_free",3,2,3,"low" +FM-313,"snprintf","report.c",117,"snprintf (general function) does not perform its intended action","Failure of snprintf could propagate undetected to callers in report.c","Logic error or untested edge case in snprintf",3,2,3,"low" +FM-314,"cfusa_severity_str","report.c",127,"cfusa_severity_str (general function) does not perform its intended action","Failure of cfusa_severity_str could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_severity_str",3,2,3,"low" +FM-315,"cfusa_format_parse","report.c",137,"cfusa_format_parse (general function) does not perform its intended action","Failure of cfusa_format_parse could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_format_parse",3,2,3,"low" +FM-316,"cfusa_report_score","report.c",148,"cfusa_report_score (general function) does not perform its intended action","Failure of cfusa_report_score could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_report_score",3,2,3,"low" +FM-317,"cfusa_report_score","report.c",256,"cfusa_report_score (general function) does not perform its intended action","Failure of cfusa_report_score could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_report_score",3,2,3,"low" +FM-318,"cfusa_severity_str","report.c",262,"cfusa_severity_str (general function) does not perform its intended action","Failure of cfusa_severity_str could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_severity_str",3,2,3,"low" +FM-319,"cfusa_report_score","report.c",307,"cfusa_report_score (general function) does not perform its intended action","Failure of cfusa_report_score could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_report_score",3,2,3,"low" +FM-320,"cfusa_severity_str","report.c",344,"cfusa_severity_str (general function) does not perform its intended action","Failure of cfusa_severity_str could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_severity_str",3,2,3,"low" +FM-321,"cfusa_severity_str","report.c",360,"cfusa_severity_str (general function) does not perform its intended action","Failure of cfusa_severity_str could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_severity_str",3,2,3,"low" +FM-322,"cfusa_severity_str","report.c",375,"cfusa_severity_str (general function) does not perform its intended action","Failure of cfusa_severity_str could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_severity_str",3,2,3,"low" +FM-323,"cfusa_report_score","report.c",508,"cfusa_report_score (general function) does not perform its intended action","Failure of cfusa_report_score could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_report_score",3,2,3,"low" +FM-324,"cfusa_severity_str","report.c",523,"cfusa_severity_str (general function) does not perform its intended action","Failure of cfusa_severity_str could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_severity_str",3,2,3,"low" +FM-325,"cfusa_severity_str","report.c",524,"cfusa_severity_str (general function) does not perform its intended action","Failure of cfusa_severity_str could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_severity_str",3,2,3,"low" +FM-326,"cfusa_report_score","report.c",550,"cfusa_report_score (general function) does not perform its intended action","Failure of cfusa_report_score could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_report_score",3,2,3,"low" +FM-327,"cfusa_severity_str","report.c",564,"cfusa_severity_str (general function) does not perform its intended action","Failure of cfusa_severity_str could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_severity_str",3,2,3,"low" +FM-328,"cfusa_report_print","report.c",571,"cfusa_report_print (general function) does not perform its intended action","Failure of cfusa_report_print could propagate undetected to callers in report.c","Logic error or untested edge case in cfusa_report_print",3,2,3,"low" +FM-329,"cfusa_qb_is_stub_text","qualitybar.c",44,"cfusa_qb_is_stub_text (general function) does not perform its intended action","Failure of cfusa_qb_is_stub_text could propagate undetected to callers in qualitybar.c","Logic error or untested edge case in cfusa_qb_is_stub_text",3,2,3,"low" +FM-330,"cfusa_qb_rule_b_flagged","qualitybar.c",59,"cfusa_qb_rule_b_flagged (general function) does not perform its intended action","Failure of cfusa_qb_rule_b_flagged could propagate undetected to callers in qualitybar.c","Logic error or untested edge case in cfusa_qb_rule_b_flagged",3,2,3,"low" +FM-331,"cfusa_qb_attestation_read","qualitybar.c",100,"cfusa_qb_attestation_read (general function) does not perform its intended action","Failure of cfusa_qb_attestation_read could propagate undetected to callers in qualitybar.c","Logic error or untested edge case in cfusa_qb_attestation_read",3,2,3,"low" +FM-332,"cfusa_qb_attestation_valid","qualitybar.c",161,"cfusa_qb_attestation_valid (general function) does not perform its intended action","Failure of cfusa_qb_attestation_valid could propagate undetected to callers in qualitybar.c","Logic error or untested edge case in cfusa_qb_attestation_valid",3,2,3,"low" +FM-333,"cfusa_qb_rule_disposed","qualitybar.c",180,"cfusa_qb_rule_disposed (general function) does not perform its intended action","Failure of cfusa_qb_rule_disposed could propagate undetected to callers in qualitybar.c","Logic error or untested edge case in cfusa_qb_rule_disposed",3,2,3,"low" +FM-334,"cfusa_qb_content_hash","qualitybar.c",206,"cfusa_qb_content_hash (general function) does not perform its intended action","Failure of cfusa_qb_content_hash could propagate undetected to callers in qualitybar.c","Logic error or untested edge case in cfusa_qb_content_hash",3,2,3,"low" +FM-335,"cfusa_engine_reset","engine.c",9,"cfusa_engine_reset (general function) does not perform its intended action","Failure of cfusa_engine_reset could propagate undetected to callers in engine.c","Logic error or untested edge case in cfusa_engine_reset",3,2,3,"low" +FM-336,"cfusa_engine_register","engine.c",14,"cfusa_engine_register (general function) does not perform its intended action","Failure of cfusa_engine_register could propagate undetected to callers in engine.c","Logic error or untested edge case in cfusa_engine_register",3,2,3,"low" +FM-337,"cfusa_engine_rule_count","engine.c",23,"cfusa_engine_rule_count (general function) does not perform its intended action","Failure of cfusa_engine_rule_count could propagate undetected to callers in engine.c","Logic error or untested edge case in cfusa_engine_rule_count",3,2,3,"low" +FM-338,"cfusa_engine_get_rule","engine.c",28,"cfusa_engine_get_rule (general function) does not perform its intended action","Failure of cfusa_engine_get_rule could propagate undetected to callers in engine.c","Logic error or untested edge case in cfusa_engine_get_rule",3,2,3,"low" +FM-339,"cfusa_engine_list_rules","engine.c",34,"cfusa_engine_list_rules (general function) does not perform its intended action","Failure of cfusa_engine_list_rules could propagate undetected to callers in engine.c","Logic error or untested edge case in cfusa_engine_list_rules",3,2,3,"low" +FM-340,"!cfusa_config_is_rule_disabled","engine.c",65,"!cfusa_config_is_rule_disabled (monitoring/control function) does not perform its intended action","Failure of !cfusa_config_is_rule_disabled could propagate undetected to callers in engine.c","Configuration or state inconsistency affecting !cfusa_config_is_rule_disabled",5,3,4,"medium" +FM-341,"strcmp","utils.c",46,"strcmp (general function) does not perform its intended action","Failure of strcmp could propagate undetected to callers in utils.c","Logic error or untested edge case in strcmp",3,2,3,"low" +FM-342,"cfusa_read_file","utils.c",60,"cfusa_read_file (general function) does not perform its intended action","Failure of cfusa_read_file could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_read_file",3,2,3,"low" +FM-343,"cfusa_fopen_write","utils.c",78,"cfusa_fopen_write (general function) does not perform its intended action","Failure of cfusa_fopen_write could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_fopen_write",3,2,3,"low" +FM-344,"cfusa_file_exists","utils.c",87,"cfusa_file_exists (general function) does not perform its intended action","Failure of cfusa_file_exists could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_file_exists",3,2,3,"low" +FM-345,"cfusa_dir_exists","utils.c",93,"cfusa_dir_exists (general function) does not perform its intended action","Failure of cfusa_dir_exists could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_dir_exists",3,2,3,"low" +FM-346,"cfusa_mkdir_p","utils.c",99,"cfusa_mkdir_p (general function) does not perform its intended action","Failure of cfusa_mkdir_p could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_mkdir_p",3,2,3,"low" +FM-347,"cfusa_scan_lines","utils.c",115,"cfusa_scan_lines (general function) does not perform its intended action","Failure of cfusa_scan_lines could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_scan_lines",3,2,3,"low" +FM-348,"cfusa_basename","utils.c",134,"cfusa_basename (general function) does not perform its intended action","Failure of cfusa_basename could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_basename",3,2,3,"low" +FM-349,"cfusa_extension","utils.c",140,"cfusa_extension (general function) does not perform its intended action","Failure of cfusa_extension could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_extension",3,2,3,"low" +FM-350,"cfusa_str_contains","utils.c",147,"cfusa_str_contains (general function) does not perform its intended action","Failure of cfusa_str_contains could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_str_contains",3,2,3,"low" +FM-351,"cfusa_str_starts_with","utils.c",152,"cfusa_str_starts_with (general function) does not perform its intended action","Failure of cfusa_str_starts_with could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_str_starts_with",3,2,3,"low" +FM-352,"cfusa_str_trim","utils.c",157,"cfusa_str_trim (general function) does not perform its intended action","Failure of cfusa_str_trim could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_str_trim",3,2,3,"low" +FM-353,"cfusa_str_escape_json","utils.c",168,"cfusa_str_escape_json (general function) does not perform its intended action","Failure of cfusa_str_escape_json could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_str_escape_json",3,2,3,"low" +FM-354,"cfusa_path_join","utils.c",188,"cfusa_path_join (general function) does not perform its intended action","Failure of cfusa_path_join could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_path_join",3,2,3,"low" +FM-355,"cfusa_sha256_buf","utils.c",311,"cfusa_sha256_buf (general function) does not perform its intended action","Failure of cfusa_sha256_buf could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_sha256_buf",3,2,3,"low" +FM-356,"cfusa_sha256_file","utils.c",323,"cfusa_sha256_file (general function) does not perform its intended action","Failure of cfusa_sha256_file could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_sha256_file",3,2,3,"low" +FM-357,"cfusa_sha256_buf","utils.c",352,"cfusa_sha256_buf (general function) does not perform its intended action","Failure of cfusa_sha256_buf could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_sha256_buf",3,2,3,"low" +FM-358,"cfusa_timestamp_now","utils.c",383,"cfusa_timestamp_now (general function) does not perform its intended action","Failure of cfusa_timestamp_now could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_timestamp_now",3,2,3,"low" +FM-359,"cfusa_count_c_files","utils.c",400,"cfusa_count_c_files (general function) does not perform its intended action","Failure of cfusa_count_c_files could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_count_c_files",3,2,3,"low" +FM-360,"cfusa_count_lines_in_file","utils.c",408,"cfusa_count_lines_in_file (general function) does not perform its intended action","Failure of cfusa_count_lines_in_file could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_count_lines_in_file",3,2,3,"low" +FM-361,"cfusa_match_outside_string","utils.c",421,"cfusa_match_outside_string (general function) does not perform its intended action","Failure of cfusa_match_outside_string could propagate undetected to callers in utils.c","Logic error or untested edge case in cfusa_match_outside_string",3,2,3,"low" +FM-362,"cfusa_config_defaults","config.c",8,"cfusa_config_defaults (safety-critical function) does not perform its intended action","Failure of cfusa_config_defaults could propagate undetected to callers in config.c","Unhandled fault or invalid input condition within cfusa_config_defaults",9,4,6,"high" +FM-363,"cfusa_config_load","config.c",92,"cfusa_config_load (monitoring/control function) does not perform its intended action","Failure of cfusa_config_load could propagate undetected to callers in config.c","Configuration or state inconsistency affecting cfusa_config_load",5,3,4,"medium" +FM-364,"extract_str_array_n","config.c",150,"extract_str_array_n (general function) does not perform its intended action","Failure of extract_str_array_n could propagate undetected to callers in config.c","Logic error or untested edge case in extract_str_array_n",3,2,3,"low" +FM-365,"extract_str_array_n","config.c",160,"extract_str_array_n (general function) does not perform its intended action","Failure of extract_str_array_n could propagate undetected to callers in config.c","Logic error or untested edge case in extract_str_array_n",3,2,3,"low" +FM-366,"extract_str_array_n","config.c",170,"extract_str_array_n (general function) does not perform its intended action","Failure of extract_str_array_n could propagate undetected to callers in config.c","Logic error or untested edge case in extract_str_array_n",3,2,3,"low" +FM-367,"extract_str_array_n","config.c",177,"extract_str_array_n (general function) does not perform its intended action","Failure of extract_str_array_n could propagate undetected to callers in config.c","Logic error or untested edge case in extract_str_array_n",3,2,3,"low" +FM-368,"cfusa_config_is_rule_disabled","config.c",186,"cfusa_config_is_rule_disabled (monitoring/control function) does not perform its intended action","Failure of cfusa_config_is_rule_disabled could propagate undetected to callers in config.c","Configuration or state inconsistency affecting cfusa_config_is_rule_disabled",5,3,4,"medium" +FM-369,"cfusa_config_save","config.c",193,"cfusa_config_save (monitoring/control function) does not perform its intended action","Failure of cfusa_config_save could propagate undetected to callers in config.c","Configuration or state inconsistency affecting cfusa_config_save",5,3,4,"medium" +FM-370,"cfusa_config_is_excluded","config.c",225,"cfusa_config_is_excluded (monitoring/control function) does not perform its intended action","Failure of cfusa_config_is_excluded could propagate undetected to callers in config.c","Configuration or state inconsistency affecting cfusa_config_is_excluded",5,3,4,"medium" diff --git a/fmea.json b/fmea.json index 27749f0..22ae330 100644 --- a/fmea.json +++ b/fmea.json @@ -1,3172 +1,5568 @@ { - "schemaVersion": "1.9", - "kind": "fmea", + "schemaVersion": "1.14.0", + "kind": "fmea-report", "tool": "c-FuSa", - "toolVersion": "0.5.0", + "toolVersion": "0.5.46", "language": "c", - "generatedAt": "2026-06-11T00:00:00Z", + "generatedAt": "2026-07-28T19:47:38Z", "project": "c-FuSa", - "version": "0.5.0", - "standard": "IEC 60812 / ISO 26262-5 / IEC 61508", + "version": "0.5.1", + "standard": "IEC 60812:2018 / ISO 26262-5", + "ratingScale": "cfusa-heuristic-1-10", "entries": [ { "id": "FM-001", - "function": "cmd_pr", + "item": "cmd_pr", "file": "cmd_pr.c", - "line": 133, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "line": 146, + "failureMode": "cmd_pr (general function) does not perform its intended action", + "effect": "Failure of cmd_pr could propagate undetected to callers in cmd_pr.c", + "cause": "Logic error or untested edge case in cmd_pr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-002", - "function": "cmd_version", + "item": "cmd_version", "file": "cmd_version.c", - "line": 4, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "line": 7, + "failureMode": "cmd_version (general function) does not perform its intended action", + "effect": "Failure of cmd_version could propagate undetected to callers in cmd_version.c", + "cause": "Logic error or untested edge case in cmd_version", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-003", - "function": "cmd_qualify", - "file": "cmd_qualify.c", - "line": 60, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_help", + "file": "cmd_dispatch.c", + "line": 66, + "failureMode": "cmd_help (general function) does not perform its intended action", + "effect": "Failure of cmd_help could propagate undetected to callers in cmd_dispatch.c", + "cause": "Logic error or untested edge case in cmd_help", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-004", - "function": "cmd_misra", - "file": "cmd_misra.c", + "item": "snprintf", + "file": "cmd_coupling.c", "line": 56, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_coupling.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-005", - "function": "cmd_iso26262", - "file": "cmd_iso26262.c", - "line": 59, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_coupling.c", + "line": 65, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_coupling.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-006", - "function": "printf", - "file": "cmd_iso26262.c", - "line": 124, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_coupling", + "file": "cmd_coupling.c", + "line": 121, + "failureMode": "cmd_coupling (general function) does not perform its intended action", + "effect": "Failure of cmd_coupling could propagate undetected to callers in cmd_coupling.c", + "cause": "Logic error or untested edge case in cmd_coupling", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-007", - "function": "cfusa_scan_lines", - "file": "cmd_req.c", - "line": 123, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_coupling.c", + "line": 177, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_coupling.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-008", - "function": "snprintf", - "file": "cmd_req.c", - "line": 202, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fn", + "file": "cmd_qualify.c", + "line": 347, + "failureMode": "fn (general function) does not perform its intended action", + "effect": "Failure of fn could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in fn", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-009", - "function": "printf", - "file": "cmd_req.c", - "line": 252, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fn", + "file": "cmd_qualify.c", + "line": 375, + "failureMode": "fn (general function) does not perform its intended action", + "effect": "Failure of fn could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in fn", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-010", - "function": "cmd_req", - "file": "cmd_req.c", - "line": 256, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fn", + "file": "cmd_qualify.c", + "line": 398, + "failureMode": "fn (general function) does not perform its intended action", + "effect": "Failure of fn could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in fn", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-011", - "function": "cmd_release", - "file": "cmd_release.c", - "line": 91, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fn", + "file": "cmd_qualify.c", + "line": 408, + "failureMode": "fn (general function) does not perform its intended action", + "effect": "Failure of fn could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in fn", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-012", - "function": "snprintf", - "file": "cmd_release.c", - "line": 130, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"strcpy", + "file": "cmd_qualify.c", + "line": 427, + "failureMode": "\"strcpy (general function) does not perform its intended action", + "effect": "Failure of \"strcpy could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in \"strcpy", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-013", - "function": "cmd_check", - "file": "cmd_check.c", - "line": 9, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Medium", - "occurrence": 1, - "detection": 1, - "rpn": 5 + "item": "\"snprintf", + "file": "cmd_qualify.c", + "line": 428, + "failureMode": "\"snprintf (general function) does not perform its intended action", + "effect": "Failure of \"snprintf could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in \"snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-014", - "function": "cmd_template", - "file": "cmd_template.c", - "line": 83, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"MD5_Init", + "file": "cmd_qualify.c", + "line": 429, + "failureMode": "\"MD5_Init (general function) does not perform its intended action", + "effect": "Failure of \"MD5_Init could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in \"MD5_Init", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-015", - "function": "cmd_tara", - "file": "cmd_tara.c", - "line": 77, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"SHA256_Init", + "file": "cmd_qualify.c", + "line": 430, + "failureMode": "\"SHA256_Init (general function) does not perform its intended action", + "effect": "Failure of \"SHA256_Init could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in \"SHA256_Init", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-016", - "function": "cfusa_scan_lines", - "file": "cmd_trace.c", - "line": 130, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_qualify", + "file": "cmd_qualify.c", + "line": 472, + "failureMode": "cmd_qualify (general function) does not perform its intended action", + "effect": "Failure of cmd_qualify could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in cmd_qualify", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-017", - "function": "cmd_trace", - "file": "cmd_trace.c", - "line": 149, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "qualification_badge", + "file": "cmd_qualify.c", + "line": 579, + "failureMode": "qualification_badge (general function) does not perform its intended action", + "effect": "Failure of qualification_badge could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in qualification_badge", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-018", - "function": "printf", - "file": "cmd_trace.c", - "line": 212, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "independence_status", + "file": "cmd_qualify.c", + "line": 580, + "failureMode": "independence_status (general function) does not perform its intended action", + "effect": "Failure of independence_status could propagate undetected to callers in cmd_qualify.c", + "cause": "Logic error or untested edge case in independence_status", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-019", - "function": "printf", - "file": "cmd_trace.c", - "line": 224, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_misra", + "file": "cmd_misra.c", + "line": 60, + "failureMode": "cmd_misra (general function) does not perform its intended action", + "effect": "Failure of cmd_misra could propagate undetected to callers in cmd_misra.c", + "cause": "Logic error or untested edge case in cmd_misra", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-020", - "function": "snprintf", - "file": "cmd_trace.c", - "line": 288, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!path_exists", + "file": "cmd_safety_rules.c", + "line": 119, + "failureMode": "!path_exists (general function) does not perform its intended action", + "effect": "Failure of !path_exists could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in !path_exists", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-021", - "function": "snprintf", - "file": "cmd_trace.c", - "line": 292, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strcmp", + "file": "cmd_safety_rules.c", + "line": 278, + "failureMode": "strcmp (general function) does not perform its intended action", + "effect": "Failure of strcmp could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in strcmp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-022", - "function": "cfusa_basename", - "file": "cmd_trace.c", - "line": 308, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!path_exists", + "file": "cmd_safety_rules.c", + "line": 391, + "failureMode": "!path_exists (general function) does not perform its intended action", + "effect": "Failure of !path_exists could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in !path_exists", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-023", - "function": "snprintf", - "file": "cmd_trace.c", - "line": 330, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "sscanf", + "file": "cmd_safety_rules.c", + "line": 422, + "failureMode": "sscanf (general function) does not perform its intended action", + "effect": "Failure of sscanf could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in sscanf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-024", - "function": "snprintf", - "file": "cmd_trace.c", - "line": 334, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "failure", + "file": "cmd_safety_rules.c", + "line": 483, + "failureMode": "failure (general function) does not perform its intended action", + "effect": "Failure of failure could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in failure", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-025", - "function": "fprintf", - "file": "cmd_trace.c", - "line": 354, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!strchr", + "file": "cmd_safety_rules.c", + "line": 506, + "failureMode": "!strchr (general function) does not perform its intended action", + "effect": "Failure of !strchr could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in !strchr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-026", - "function": "for", - "file": "cmd_analyze.c", - "line": 24, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!strstr", + "file": "cmd_safety_rules.c", + "line": 507, + "failureMode": "!strstr (general function) does not perform its intended action", + "effect": "Failure of !strstr could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in !strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-027", - "function": "if", - "file": "cmd_analyze.c", - "line": 65, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strchr", + "file": "cmd_safety_rules.c", + "line": 544, + "failureMode": "strchr (general function) does not perform its intended action", + "effect": "Failure of strchr could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in strchr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-028", - "function": "!strstr", - "file": "cmd_analyze.c", - "line": 66, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "sscanf", + "file": "cmd_safety_rules.c", + "line": 614, + "failureMode": "sscanf (general function) does not perform its intended action", + "effect": "Failure of sscanf could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in sscanf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-029", - "function": "strstr", - "file": "cmd_analyze.c", - "line": 99, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strstr", + "file": "cmd_safety_rules.c", + "line": 724, + "failureMode": "strstr (general function) does not perform its intended action", + "effect": "Failure of strstr could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-030", - "function": "strstr", - "file": "cmd_analyze.c", - "line": 100, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!path_exists", + "file": "cmd_safety_rules.c", + "line": 804, + "failureMode": "!path_exists (general function) does not perform its intended action", + "effect": "Failure of !path_exists could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in !path_exists", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-031", - "function": "!strstr", - "file": "cmd_analyze.c", - "line": 101, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!path_exists", + "file": "cmd_safety_rules.c", + "line": 818, + "failureMode": "!path_exists (general function) does not perform its intended action", + "effect": "Failure of !path_exists could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in !path_exists", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-032", - "function": "if", - "file": "cmd_analyze.c", - "line": 131, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!path_exists", + "file": "cmd_safety_rules.c", + "line": 831, + "failureMode": "!path_exists (general function) does not perform its intended action", + "effect": "Failure of !path_exists could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in !path_exists", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-033", - "function": "!strstr", - "file": "cmd_analyze.c", - "line": 132, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"V", + "file": "cmd_safety_rules.c", + "line": 915, + "failureMode": "\"V (general function) does not perform its intended action", + "effect": "Failure of \"V could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Logic error or untested edge case in \"V", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-034", - "function": "if", - "file": "cmd_analyze.c", - "line": 162, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_safety_register_rules", + "file": "cmd_safety_rules.c", + "line": 919, + "failureMode": "cfusa_safety_register_rules (safety-critical function) does not perform its intended action", + "effect": "Failure of cfusa_safety_register_rules could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Unhandled fault or invalid input condition within cfusa_safety_register_rules", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-035", - "function": ""assert", - "file": "cmd_analyze.c", - "line": 166, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_safety_rule_count", + "file": "cmd_safety_rules.c", + "line": 927, + "failureMode": "cfusa_safety_rule_count (safety-critical function) does not perform its intended action", + "effect": "Failure of cfusa_safety_rule_count could propagate undetected to callers in cmd_safety_rules.c", + "cause": "Unhandled fault or invalid input condition within cfusa_safety_rule_count", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-036", - "function": "if", - "file": "cmd_analyze.c", - "line": 193, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_iso26262", + "file": "cmd_iso26262.c", + "line": 84, + "failureMode": "cmd_iso26262 (general function) does not perform its intended action", + "effect": "Failure of cmd_iso26262 could propagate undetected to callers in cmd_iso26262.c", + "cause": "Logic error or untested edge case in cmd_iso26262", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-037", - "function": "strstr", - "file": "cmd_analyze.c", - "line": 194, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_iso26262.c", + "line": 183, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_iso26262.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-038", - "function": "strstr", - "file": "cmd_analyze.c", - "line": 195, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_iso26262.c", + "line": 206, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_iso26262.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-039", - "function": "for", - "file": "cmd_analyze.c", - "line": 231, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_scan_lines", + "file": "cmd_req.c", + "line": 135, + "failureMode": "cfusa_scan_lines (general function) does not perform its intended action", + "effect": "Failure of cfusa_scan_lines could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in cfusa_scan_lines", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-040", - "function": ""assert", - "file": "cmd_analyze.c", - "line": 277, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "xml_escape", + "file": "cmd_req.c", + "line": 172, + "failureMode": "xml_escape (general function) does not perform its intended action", + "effect": "Failure of xml_escape could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in xml_escape", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-041", - "function": "cfusa_analyze_register_rules", - "file": "cmd_analyze.c", - "line": 285, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "xml_escape", + "file": "cmd_req.c", + "line": 176, + "failureMode": "xml_escape (general function) does not perform its intended action", + "effect": "Failure of xml_escape could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in xml_escape", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-042", - "function": "cmd_analyze", - "file": "cmd_analyze.c", - "line": 291, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "xml_escape", + "file": "cmd_req.c", + "line": 180, + "failureMode": "xml_escape (general function) does not perform its intended action", + "effect": "Failure of xml_escape could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in xml_escape", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-043", - "function": "cmd_report", - "file": "cmd_report.c", - "line": 9, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_req.c", + "line": 193, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-044", - "function": "cmd_init", - "file": "cmd_init.c", - "line": 8, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Medium", - "occurrence": 1, - "detection": 1, - "rpn": 5 + "item": "fprintf", + "file": "cmd_req.c", + "line": 209, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-045", - "function": "fprintf", - "file": "cmd_init.c", - "line": 46, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_req.c", + "line": 225, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-046", - "function": "cfusa_scan_lines", - "file": "cmd_fmea.c", - "line": 90, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_req.c", + "line": 257, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-047", - "function": "cmd_fmea", - "file": "cmd_fmea.c", - "line": 92, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!strcmp", + "file": "cmd_req.c", + "line": 520, + "failureMode": "!strcmp (general function) does not perform its intended action", + "effect": "Failure of !strcmp could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in !strcmp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-048", - "function": "cfusa_path_join", - "file": "cmd_fmea.c", - "line": 139, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "import_reqif", + "file": "cmd_req.c", + "line": 646, + "failureMode": "import_reqif (general function) does not perform its intended action", + "effect": "Failure of import_reqif could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in import_reqif", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-049", - "function": "printf", - "file": "cmd_fmea.c", - "line": 142, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "import_polarion_xml", + "file": "cmd_req.c", + "line": 652, + "failureMode": "import_polarion_xml (general function) does not perform its intended action", + "effect": "Failure of import_polarion_xml could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in import_polarion_xml", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-050", - "function": "cfusa_basename", - "file": "cmd_fmea.c", - "line": 188, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "import_reqif", + "file": "cmd_req.c", + "line": 655, + "failureMode": "import_reqif (general function) does not perform its intended action", + "effect": "Failure of import_reqif could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in import_reqif", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-051", - "function": "cfusa_basename", - "file": "cmd_fmea.c", - "line": 238, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "import_codebeamer_xml", + "file": "cmd_req.c", + "line": 660, + "failureMode": "import_codebeamer_xml (general function) does not perform its intended action", + "effect": "Failure of import_codebeamer_xml could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in import_codebeamer_xml", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-052", - "function": "cfusa_basename", - "file": "cmd_fmea.c", - "line": 277, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "import_jama_xml", + "file": "cmd_req.c", + "line": 671, + "failureMode": "import_jama_xml (general function) does not perform its intended action", + "effect": "Failure of import_jama_xml could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in import_jama_xml", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-053", - "function": "strtol", - "file": "cmd_fix.c", - "line": 48, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "sizeof", + "file": "cmd_req.c", + "line": 695, + "failureMode": "sizeof (general function) does not perform its intended action", + "effect": "Failure of sizeof could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in sizeof", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-054", - "function": "fgets", - "file": "cmd_fix.c", - "line": 55, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "append_entry", + "file": "cmd_req.c", + "line": 713, + "failureMode": "append_entry (general function) does not perform its intended action", + "effect": "Failure of append_entry could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in append_entry", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-055", - "function": "strncpy", - "file": "cmd_fix.c", - "line": 56, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_req.c", + "line": 755, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-056", - "function": "snprintf", - "file": "cmd_fix.c", - "line": 57, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_req", + "file": "cmd_req.c", + "line": 760, + "failureMode": "cmd_req (general function) does not perform its intended action", + "effect": "Failure of cmd_req could propagate undetected to callers in cmd_req.c", + "cause": "Logic error or untested edge case in cmd_req", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-057", - "function": "malloc", - "file": "cmd_fix.c", - "line": 61, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_release", + "file": "cmd_release.c", + "line": 100, + "failureMode": "cmd_release (general function) does not perform its intended action", + "effect": "Failure of cmd_release could propagate undetected to callers in cmd_release.c", + "cause": "Logic error or untested edge case in cmd_release", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-058", - "function": "assert", - "file": "cmd_fix.c", - "line": 71, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_release.c", + "line": 174, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_release.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-059", - "function": "strncpy", - "file": "cmd_fix.c", - "line": 78, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_check", + "file": "cmd_check.c", + "line": 14, + "failureMode": "cmd_check (monitoring/control function) does not perform its intended action", + "effect": "Failure of cmd_check could propagate undetected to callers in cmd_check.c", + "cause": "Configuration or state inconsistency affecting cmd_check", + "severity": 5, + "occurrence": 3, + "detection": 4, + "actionPriority": "medium", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-060", - "function": "dst[sizeof", - "file": "cmd_fix.c", - "line": 79, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_template_generate_all", + "file": "cmd_template.c", + "line": 84, + "failureMode": "cfusa_template_generate_all (general function) does not perform its intended action", + "effect": "Failure of cfusa_template_generate_all could propagate undetected to callers in cmd_template.c", + "cause": "Logic error or untested edge case in cfusa_template_generate_all", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-061", - "function": "printf", - "file": "cmd_fix.c", - "line": 83, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_template", + "file": "cmd_template.c", + "line": 106, + "failureMode": "cmd_template (general function) does not perform its intended action", + "effect": "Failure of cmd_template could propagate undetected to callers in cmd_template.c", + "cause": "Logic error or untested edge case in cmd_template", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-062", - "function": "printf", - "file": "cmd_fix.c", - "line": 84, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_tara.c", + "line": 326, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_tara.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-063", - "function": "execve", - "file": "cmd_fix.c", - "line": 88, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_tara", + "file": "cmd_tara.c", + "line": 330, + "failureMode": "cmd_tara (general function) does not perform its intended action", + "effect": "Failure of cmd_tara could propagate undetected to callers in cmd_tara.c", + "cause": "Logic error or untested edge case in cmd_tara", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-064", - "function": "sizeof", - "file": "cmd_fix.c", - "line": 95, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_tara.c", + "line": 426, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_tara.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-065", - "function": "malloc", - "file": "cmd_fix.c", - "line": 97, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "write_threat_json", + "file": "cmd_tara.c", + "line": 439, + "failureMode": "write_threat_json (general function) does not perform its intended action", + "effect": "Failure of write_threat_json could propagate undetected to callers in cmd_tara.c", + "cause": "Logic error or untested edge case in write_threat_json", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-066", - "function": "free", - "file": "cmd_fix.c", - "line": 101, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_tara.c", + "line": 440, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_tara.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-067", - "function": "cmd_fix", - "file": "cmd_fix.c", - "line": 123, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_tara.c", + "line": 449, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_tara.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-068", - "function": "printf", - "file": "cmd_fix.c", - "line": 168, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_tara.c", + "line": 459, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_tara.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-069", - "function": "printf", - "file": "cmd_fix.c", - "line": 188, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_tara.c", + "line": 461, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_tara.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-070", - "function": "cmd_help", - "file": "main.c", - "line": 50, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_scan_lines", + "file": "cmd_trace.c", + "line": 184, + "failureMode": "cfusa_scan_lines (general function) does not perform its intended action", + "effect": "Failure of cfusa_scan_lines could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in cfusa_scan_lines", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-071", - "function": "main", - "file": "main.c", - "line": 64, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_trace", + "file": "cmd_trace.c", + "line": 336, + "failureMode": "cmd_trace (general function) does not perform its intended action", + "effect": "Failure of cmd_trace could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in cmd_trace", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-072", - "function": "cmd_boundary", - "file": "cmd_boundary.c", - "line": 70, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "compute_hlr_llr", + "file": "cmd_trace.c", + "line": 436, + "failureMode": "compute_hlr_llr (general function) does not perform its intended action", + "effect": "Failure of compute_hlr_llr could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in compute_hlr_llr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-073", - "function": "cmd_impact", - "file": "cmd_impact.c", - "line": 101, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_trace.c", + "line": 453, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-074", - "function": "printf", - "file": "cmd_impact.c", - "line": 189, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "LLR", + "file": "cmd_trace.c", + "line": 460, + "failureMode": "LLR (general function) does not perform its intended action", + "effect": "Failure of LLR could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in LLR", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-075", - "function": "cmd_sci", - "file": "cmd_sci.c", - "line": 35, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_trace.c", + "line": 478, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-076", - "function": "cmd_iec61508", - "file": "cmd_iec61508.c", - "line": 61, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_trace.c", + "line": 497, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-077", - "function": "printf", - "file": "cmd_iec61508.c", - "line": 127, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_trace.c", + "line": 530, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-078", - "function": "cmd_badge", - "file": "cmd_badge.c", - "line": 8, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_trace.c", + "line": 558, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-079", - "function": "fill=\"url", - "file": "cmd_badge.c", - "line": 77, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_trace.c", + "line": 696, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-080", - "function": "cmd_sign", - "file": "cmd_sign.c", - "line": 7, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_trace.c", + "line": 700, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-081", - "function": "cfusa_hmac_sha256", - "file": "cmd_sign.c", - "line": 76, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_basename", + "file": "cmd_trace.c", + "line": 716, + "failureMode": "cfusa_basename (general function) does not perform its intended action", + "effect": "Failure of cfusa_basename could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in cfusa_basename", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-082", - "function": ""gets", - "file": "cmd_vuln.c", - "line": 23, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_trace.c", + "line": 763, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-083", - "function": "fgets", - "file": "cmd_vuln.c", - "line": 24, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_trace.c", + "line": 767, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-084", - "function": ""sprintf", - "file": "cmd_vuln.c", - "line": 26, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_trace.c", + "line": 790, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_trace.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-085", - "function": "snprintf", - "file": "cmd_vuln.c", - "line": 27, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "for", + "file": "cmd_analyze.c", + "line": 25, + "failureMode": "for (general function) does not perform its intended action", + "effect": "Failure of for could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in for", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-086", - "function": ""strcpy", - "file": "cmd_vuln.c", - "line": 29, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_analyze.c", + "line": 67, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-087", - "function": "strlcpy", - "file": "cmd_vuln.c", - "line": 30, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!strstr", + "file": "cmd_analyze.c", + "line": 68, + "failureMode": "!strstr (general function) does not perform its intended action", + "effect": "Failure of !strstr could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in !strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-088", - "function": ""strcat", - "file": "cmd_vuln.c", - "line": 32, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strstr", + "file": "cmd_analyze.c", + "line": 102, + "failureMode": "strstr (general function) does not perform its intended action", + "effect": "Failure of strstr could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-089", - "function": "strlcat", - "file": "cmd_vuln.c", - "line": 33, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strstr", + "file": "cmd_analyze.c", + "line": 103, + "failureMode": "strstr (general function) does not perform its intended action", + "effect": "Failure of strstr could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-090", - "function": "scanf", - "file": "cmd_vuln.c", - "line": 36, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!strstr", + "file": "cmd_analyze.c", + "line": 104, + "failureMode": "!strstr (general function) does not perform its intended action", + "effect": "Failure of !strstr could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in !strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-091", - "function": ""tmpnam", - "file": "cmd_vuln.c", - "line": 38, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_analyze.c", + "line": 135, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-092", - "function": "mkstemp", - "file": "cmd_vuln.c", - "line": 39, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "!strstr", + "file": "cmd_analyze.c", + "line": 136, + "failureMode": "!strstr (general function) does not perform its intended action", + "effect": "Failure of !strstr could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in !strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-093", - "function": ""system", - "file": "cmd_vuln.c", - "line": 41, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_analyze.c", + "line": 167, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-094", - "function": "system", - "file": "cmd_vuln.c", - "line": 42, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"assert", + "file": "cmd_analyze.c", + "line": 171, + "failureMode": "\"assert (general function) does not perform its intended action", + "effect": "Failure of \"assert could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in \"assert", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-095", - "function": ""rand", - "file": "cmd_vuln.c", - "line": 44, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_analyze.c", + "line": 199, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-096", - "function": ""mktemp", - "file": "cmd_vuln.c", - "line": 47, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strstr", + "file": "cmd_analyze.c", + "line": 200, + "failureMode": "strstr (general function) does not perform its intended action", + "effect": "Failure of strstr could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-097", - "function": "mkstemp", - "file": "cmd_vuln.c", - "line": 48, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strstr", + "file": "cmd_analyze.c", + "line": 201, + "failureMode": "strstr (general function) does not perform its intended action", + "effect": "Failure of strstr could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-098", - "function": ""popen", - "file": "cmd_vuln.c", - "line": 50, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "for", + "file": "cmd_analyze.c", + "line": 238, + "failureMode": "for (general function) does not perform its intended action", + "effect": "Failure of for could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in for", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-099", - "function": "execv", - "file": "cmd_vuln.c", - "line": 51, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"assert", + "file": "cmd_analyze.c", + "line": 284, + "failureMode": "\"assert (general function) does not perform its intended action", + "effect": "Failure of \"assert could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in \"assert", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-100", - "function": "cfusa_scan_lines", - "file": "cmd_vuln.c", - "line": 104, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_analyze_register_rules", + "file": "cmd_analyze.c", + "line": 292, + "failureMode": "cfusa_analyze_register_rules (general function) does not perform its intended action", + "effect": "Failure of cfusa_analyze_register_rules could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in cfusa_analyze_register_rules", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-101", - "function": "cmd_vuln", - "file": "cmd_vuln.c", - "line": 106, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_analyze", + "file": "cmd_analyze.c", + "line": 298, + "failureMode": "cmd_analyze (general function) does not perform its intended action", + "effect": "Failure of cmd_analyze could propagate undetected to callers in cmd_analyze.c", + "cause": "Logic error or untested edge case in cmd_analyze", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-102", - "function": "cmd_audit_pack", - "file": "cmd_audit_pack.c", + "item": "cmd_report", + "file": "cmd_report.c", "line": 14, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "failureMode": "cmd_report (general function) does not perform its intended action", + "effect": "Failure of cmd_report could propagate undetected to callers in cmd_report.c", + "cause": "Logic error or untested edge case in cmd_report", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-103", - "function": "cmd_hooks", - "file": "cmd_hooks.c", - "line": 19, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_init", + "file": "cmd_init.c", + "line": 15, + "failureMode": "cmd_init (monitoring/control function) does not perform its intended action", + "effect": "Failure of cmd_init could propagate undetected to callers in cmd_init.c", + "cause": "Configuration or state inconsistency affecting cmd_init", + "severity": 5, + "occurrence": 3, + "detection": 4, + "actionPriority": "medium", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-104", - "function": "cmd_disposition", - "file": "cmd_disposition.c", - "line": 167, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_init.c", + "line": 99, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_init.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-105", - "function": "cmd_coverage", - "file": "cmd_coverage.c", - "line": 61, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_init.c", + "line": 116, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_init.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-106", - "function": "fprintf", - "file": "cmd_coverage.c", - "line": 150, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_iec62443", + "file": "cmd_iec62443.c", + "line": 85, + "failureMode": "cmd_iec62443 (general function) does not perform its intended action", + "effect": "Failure of cmd_iec62443 could propagate undetected to callers in cmd_iec62443.c", + "cause": "Logic error or untested edge case in cmd_iec62443", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-107", - "function": "fprintf", - "file": "cmd_coverage.c", - "line": 152, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_iec62443.c", + "line": 223, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_iec62443.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-108", - "function": "fprintf", - "file": "cmd_coverage.c", - "line": 154, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_basename", + "file": "cmd_fmea.c", + "line": 187, + "failureMode": "cfusa_basename (general function) does not perform its intended action", + "effect": "Failure of cfusa_basename could propagate undetected to callers in cmd_fmea.c", + "cause": "Logic error or untested edge case in cfusa_basename", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-109", - "function": "cmd_diff", - "file": "cmd_diff.c", - "line": 63, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_basename", + "file": "cmd_fmea.c", + "line": 267, + "failureMode": "cfusa_basename (general function) does not perform its intended action", + "effect": "Failure of cfusa_basename could propagate undetected to callers in cmd_fmea.c", + "cause": "Logic error or untested edge case in cfusa_basename", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-110", - "function": "cmd_hara", - "file": "cmd_hara.c", - "line": 195, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_fmea", + "file": "cmd_fmea.c", + "line": 274, + "failureMode": "cmd_fmea (general function) does not perform its intended action", + "effect": "Failure of cmd_fmea could propagate undetected to callers in cmd_fmea.c", + "cause": "Logic error or untested edge case in cmd_fmea", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-111", - "function": "cmd_do178", - "file": "cmd_do178.c", - "line": 100, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_fmea.c", + "line": 383, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_fmea.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-112", - "function": "cmd_verify", - "file": "cmd_verify.c", - "line": 13, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_fmea.c", + "line": 393, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_fmea.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-113", - "function": "cmd_sas", - "file": "cmd_sas.c", - "line": 39, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_path_join", + "file": "cmd_fmea.c", + "line": 399, + "failureMode": "cfusa_path_join (general function) does not perform its intended action", + "effect": "Failure of cfusa_path_join could propagate undetected to callers in cmd_fmea.c", + "cause": "Logic error or untested edge case in cfusa_path_join", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-114", - "function": "fprintf", - "file": "cmd_sas.c", - "line": 93, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_fmea.c", + "line": 402, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_fmea.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-115", - "function": "fprintf", - "file": "cmd_sas.c", - "line": 102, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_basename", + "file": "cmd_fmea.c", + "line": 442, + "failureMode": "cfusa_basename (general function) does not perform its intended action", + "effect": "Failure of cfusa_basename could propagate undetected to callers in cmd_fmea.c", + "cause": "Logic error or untested edge case in cfusa_basename", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-116", - "function": "for", - "file": "cmd_cyber.c", - "line": 18, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_basename", + "file": "cmd_fmea.c", + "line": 506, + "failureMode": "cfusa_basename (general function) does not perform its intended action", + "effect": "Failure of cfusa_basename could propagate undetected to callers in cmd_fmea.c", + "cause": "Logic error or untested edge case in cfusa_basename", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-117", - "function": "if", - "file": "cmd_cyber.c", - "line": 21, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_basename", + "file": "cmd_fmea.c", + "line": 534, + "failureMode": "cfusa_basename (general function) does not perform its intended action", + "effect": "Failure of cfusa_basename could propagate undetected to callers in cmd_fmea.c", + "cause": "Logic error or untested edge case in cfusa_basename", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-118", - "function": "||", - "file": "cmd_cyber.c", - "line": 22, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strtol", + "file": "cmd_fix.c", + "line": 50, + "failureMode": "strtol (general function) does not perform its intended action", + "effect": "Failure of strtol could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in strtol", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-119", - "function": "for", - "file": "cmd_cyber.c", - "line": 49, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fgets", + "file": "cmd_fix.c", + "line": 57, + "failureMode": "fgets (general function) does not perform its intended action", + "effect": "Failure of fgets could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in fgets", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-120", - "function": "if", - "file": "cmd_cyber.c", - "line": 53, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strncpy", + "file": "cmd_fix.c", + "line": 58, + "failureMode": "strncpy (general function) does not perform its intended action", + "effect": "Failure of strncpy could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in strncpy", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-121", - "function": "if", - "file": "cmd_cyber.c", - "line": 61, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_fix.c", + "line": 59, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-122", - "function": "if", - "file": "cmd_cyber.c", - "line": 69, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "malloc", + "file": "cmd_fix.c", + "line": 63, + "failureMode": "malloc (general function) does not perform its intended action", + "effect": "Failure of malloc could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in malloc", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-123", - "function": "strncmp", - "file": "cmd_cyber.c", - "line": 70, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "assert", + "file": "cmd_fix.c", + "line": 73, + "failureMode": "assert (general function) does not perform its intended action", + "effect": "Failure of assert could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in assert", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-124", - "function": "for", - "file": "cmd_cyber.c", - "line": 93, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strncpy", + "file": "cmd_fix.c", + "line": 80, + "failureMode": "strncpy (general function) does not perform its intended action", + "effect": "Failure of strncpy could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in strncpy", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-125", - "function": "if", - "file": "cmd_cyber.c", - "line": 100, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "dst[sizeof", + "file": "cmd_fix.c", + "line": 81, + "failureMode": "dst[sizeof (general function) does not perform its intended action", + "effect": "Failure of dst[sizeof could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in dst[sizeof", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-126", - "function": "if", - "file": "cmd_cyber.c", - "line": 150, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_fix.c", + "line": 85, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-127", - "function": "strstr", - "file": "cmd_cyber.c", - "line": 151, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_fix.c", + "line": 86, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-128", - "function": "if", - "file": "cmd_cyber.c", - "line": 173, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "execve", + "file": "cmd_fix.c", + "line": 90, + "failureMode": "execve (general function) does not perform its intended action", + "effect": "Failure of execve could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in execve", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-129", - "function": "free", - "file": "cmd_cyber.c", - "line": 176, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "sizeof", + "file": "cmd_fix.c", + "line": 97, + "failureMode": "sizeof (general function) does not perform its intended action", + "effect": "Failure of sizeof could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in sizeof", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-130", - "function": "if", - "file": "cmd_cyber.c", - "line": 197, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "malloc", + "file": "cmd_fix.c", + "line": 99, + "failureMode": "malloc (general function) does not perform its intended action", + "effect": "Failure of malloc could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in malloc", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-131", - "function": "if", - "file": "cmd_cyber.c", - "line": 215, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "free", + "file": "cmd_fix.c", + "line": 103, + "failureMode": "free (general function) does not perform its intended action", + "effect": "Failure of free could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in free", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-132", - "function": "cfusa_match_outside_string", - "file": "cmd_cyber.c", - "line": 216, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_fix", + "file": "cmd_fix.c", + "line": 125, + "failureMode": "cmd_fix (general function) does not perform its intended action", + "effect": "Failure of cmd_fix could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in cmd_fix", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-133", - "function": "mkstemp", - "file": "cmd_cyber.c", - "line": 219, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_fix.c", + "line": 175, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-134", - "function": "for", - "file": "cmd_cyber.c", - "line": 237, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_fix.c", + "line": 195, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_fix.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-135", - "function": "if", - "file": "cmd_cyber.c", - "line": 238, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "main", + "file": "main.c", + "line": 14, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in main.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-136", - "function": "for", - "file": "cmd_cyber.c", - "line": 260, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_boundary", + "file": "cmd_boundary.c", + "line": 72, + "failureMode": "cmd_boundary (general function) does not perform its intended action", + "effect": "Failure of cmd_boundary could propagate undetected to callers in cmd_boundary.c", + "cause": "Logic error or untested edge case in cmd_boundary", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-137", - "function": "if", - "file": "cmd_cyber.c", - "line": 264, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_impact", + "file": "cmd_impact.c", + "line": 106, + "failureMode": "cmd_impact (general function) does not perform its intended action", + "effect": "Failure of cmd_impact could propagate undetected to callers in cmd_impact.c", + "cause": "Logic error or untested edge case in cmd_impact", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-138", - "function": "cfusa_cyber_register_rules", - "file": "cmd_cyber.c", - "line": 300, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "printf", + "file": "cmd_impact.c", + "line": 194, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_impact.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-139", - "function": "for", - "file": "cmd_cyber.c", - "line": 302, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_sci", + "file": "cmd_sci.c", + "line": 44, + "failureMode": "cmd_sci (general function) does not perform its intended action", + "effect": "Failure of cmd_sci could propagate undetected to callers in cmd_sci.c", + "cause": "Logic error or untested edge case in cmd_sci", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-140", - "function": "cmd_cyber", - "file": "cmd_cyber.c", - "line": 306, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_iec61508", + "file": "cmd_iec61508.c", + "line": 78, + "failureMode": "cmd_iec61508 (general function) does not perform its intended action", + "effect": "Failure of cmd_iec61508 could propagate undetected to callers in cmd_iec61508.c", + "cause": "Logic error or untested edge case in cmd_iec61508", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-141", - "function": "cmd_safety_case", - "file": "cmd_safety_case.c", - "line": 12, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "High", - "occurrence": 1, - "detection": 1, - "rpn": 9 + "item": "fprintf", + "file": "cmd_iec61508.c", + "line": 204, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_iec61508.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-142", - "function": "cmd_metrics", - "file": "cmd_metrics.c", - "line": 95, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_badge", + "file": "cmd_badge.c", + "line": 9, + "failureMode": "cmd_badge (general function) does not perform its intended action", + "effect": "Failure of cmd_badge could propagate undetected to callers in cmd_badge.c", + "cause": "Logic error or untested edge case in cmd_badge", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-143", - "function": "E=$", - "file": "cmd_metrics.c", - "line": 136, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fill=\\\"url", + "file": "cmd_badge.c", + "line": 87, + "failureMode": "fill=\\\"url (general function) does not perform its intended action", + "effect": "Failure of fill=\\\"url could propagate undetected to callers in cmd_badge.c", + "cause": "Logic error or untested edge case in fill=\\\"url", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-144", - "function": "W=$", - "file": "cmd_metrics.c", - "line": 137, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_unece", + "file": "cmd_unece.c", + "line": 57, + "failureMode": "cmd_unece (general function) does not perform its intended action", + "effect": "Failure of cmd_unece could propagate undetected to callers in cmd_unece.c", + "cause": "Logic error or untested edge case in cmd_unece", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-145", - "function": "!strstr", - "file": "cmd_lint.c", - "line": 191, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_sign", + "file": "cmd_sign.c", + "line": 43, + "failureMode": "cmd_sign (general function) does not perform its intended action", + "effect": "Failure of cmd_sign could propagate undetected to callers in cmd_sign.c", + "cause": "Logic error or untested edge case in cmd_sign", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-146", - "function": "if", - "file": "cmd_lint.c", - "line": 196, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_hmac_sha256", + "file": "cmd_sign.c", + "line": 120, + "failureMode": "cfusa_hmac_sha256 (general function) does not perform its intended action", + "effect": "Failure of cfusa_hmac_sha256 could propagate undetected to callers in cmd_sign.c", + "cause": "Logic error or untested edge case in cfusa_hmac_sha256", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-147", - "function": "while", - "file": "cmd_lint.c", - "line": 200, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_iso21434", + "file": "cmd_iso21434.c", + "line": 77, + "failureMode": "cmd_iso21434 (general function) does not perform its intended action", + "effect": "Failure of cmd_iso21434 could propagate undetected to callers in cmd_iso21434.c", + "cause": "Logic error or untested edge case in cmd_iso21434", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-148", - "function": "if", - "file": "cmd_lint.c", - "line": 211, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_iso21434.c", + "line": 212, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_iso21434.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-149", - "function": "!strstr", - "file": "cmd_lint.c", - "line": 307, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"gets", + "file": "cmd_vuln.c", + "line": 26, + "failureMode": "\"gets (general function) does not perform its intended action", + "effect": "Failure of \"gets could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in \"gets", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-150", - "function": "cfusa_lint_register_rules", - "file": "cmd_lint.c", - "line": 447, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fgets", + "file": "cmd_vuln.c", + "line": 27, + "failureMode": "fgets (general function) does not perform its intended action", + "effect": "Failure of fgets could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in fgets", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-151", - "function": "cmd_lint", - "file": "cmd_lint.c", - "line": 455, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"sprintf", + "file": "cmd_vuln.c", + "line": 29, + "failureMode": "\"sprintf (general function) does not perform its intended action", + "effect": "Failure of \"sprintf could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in \"sprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-152", - "function": "setUp", - "file": "test_engine.c", - "line": 40, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_vuln.c", + "line": 30, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-153", - "function": "tearDown", - "file": "test_engine.c", - "line": 41, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"strcpy", + "file": "cmd_vuln.c", + "line": 32, + "failureMode": "\"strcpy (general function) does not perform its intended action", + "effect": "Failure of \"strcpy could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in \"strcpy", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-154", - "function": "test_register_and_count", - "file": "test_engine.c", - "line": 43, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strlcpy", + "file": "cmd_vuln.c", + "line": 33, + "failureMode": "strlcpy (general function) does not perform its intended action", + "effect": "Failure of strlcpy could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in strlcpy", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-155", - "function": "test_run_all_calls_rules", - "file": "test_engine.c", - "line": 52, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"strcat", + "file": "cmd_vuln.c", + "line": 35, + "failureMode": "\"strcat (general function) does not perform its intended action", + "effect": "Failure of \"strcat could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in \"strcat", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-156", - "function": "test_run_category_filters", - "file": "test_engine.c", - "line": 70, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strlcat", + "file": "cmd_vuln.c", + "line": 36, + "failureMode": "strlcat (general function) does not perform its intended action", + "effect": "Failure of strlcat could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in strlcat", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-157", - "function": "cfusa_engine_register", - "file": "test_engine.c", - "line": 72, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "scanf", + "file": "cmd_vuln.c", + "line": 39, + "failureMode": "scanf (general function) does not perform its intended action", + "effect": "Failure of scanf could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in scanf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-158", - "function": "cfusa_engine_register", - "file": "test_engine.c", - "line": 73, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"tmpnam", + "file": "cmd_vuln.c", + "line": 41, + "failureMode": "\"tmpnam (general function) does not perform its intended action", + "effect": "Failure of \"tmpnam could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in \"tmpnam", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-159", - "function": "test_reset_clears_rules", - "file": "test_engine.c", - "line": 87, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "mkstemp", + "file": "cmd_vuln.c", + "line": 42, + "failureMode": "mkstemp (general function) does not perform its intended action", + "effect": "Failure of mkstemp could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in mkstemp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-160", - "function": "test_report_score_perfect", - "file": "test_engine.c", - "line": 95, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"system", + "file": "cmd_vuln.c", + "line": 44, + "failureMode": "\"system (general function) does not perform its intended action", + "effect": "Failure of \"system could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in \"system", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-161", - "function": "test_report_score_with_errors", - "file": "test_engine.c", - "line": 103, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "High", - "occurrence": 1, - "detection": 1, - "rpn": 9 + "item": "system", + "file": "cmd_vuln.c", + "line": 45, + "failureMode": "system (general function) does not perform its intended action", + "effect": "Failure of system could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in system", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-162", - "function": "main", - "file": "test_engine.c", - "line": 112, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"rand", + "file": "cmd_vuln.c", + "line": 47, + "failureMode": "\"rand (general function) does not perform its intended action", + "effect": "Failure of \"rand could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in \"rand", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-163", - "function": "setUp", - "file": "test_config.c", - "line": 5, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "\"mktemp", + "file": "cmd_vuln.c", + "line": 50, + "failureMode": "\"mktemp (general function) does not perform its intended action", + "effect": "Failure of \"mktemp could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in \"mktemp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-164", - "function": "tearDown", - "file": "test_config.c", - "line": 6, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "mkstemp", + "file": "cmd_vuln.c", + "line": 51, + "failureMode": "mkstemp (general function) does not perform its intended action", + "effect": "Failure of mkstemp could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in mkstemp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-165", - "function": "test_config_defaults", - "file": "test_config.c", - "line": 8, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "High", - "occurrence": 1, - "detection": 1, - "rpn": 9 + "item": "\"popen", + "file": "cmd_vuln.c", + "line": 53, + "failureMode": "\"popen (general function) does not perform its intended action", + "effect": "Failure of \"popen could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in \"popen", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-166", - "function": "test_config_defaults_extensions", - "file": "test_config.c", - "line": 22, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "High", - "occurrence": 1, - "detection": 1, - "rpn": 9 + "item": "execv", + "file": "cmd_vuln.c", + "line": 54, + "failureMode": "execv (general function) does not perform its intended action", + "effect": "Failure of execv could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in execv", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-167", - "function": "test_config_save_and_load", - "file": "test_config.c", - "line": 36, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Medium", - "occurrence": 1, - "detection": 1, - "rpn": 5 + "item": "cfusa_scan_lines", + "file": "cmd_vuln.c", + "line": 107, + "failureMode": "cfusa_scan_lines (general function) does not perform its intended action", + "effect": "Failure of cfusa_scan_lines could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in cfusa_scan_lines", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-168", - "function": "test_config_is_excluded", - "file": "test_config.c", - "line": 58, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Medium", - "occurrence": 1, - "detection": 1, - "rpn": 5 + "item": "cmd_vuln", + "file": "cmd_vuln.c", + "line": 109, + "failureMode": "cmd_vuln (general function) does not perform its intended action", + "effect": "Failure of cmd_vuln could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in cmd_vuln", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-169", - "function": "test_config_missing_file_uses_defaults", - "file": "test_config.c", - "line": 68, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "High", - "occurrence": 1, - "detection": 1, - "rpn": 9 + "item": "printf", + "file": "cmd_vuln.c", + "line": 181, + "failureMode": "printf (general function) does not perform its intended action", + "effect": "Failure of printf could propagate undetected to callers in cmd_vuln.c", + "cause": "Logic error or untested edge case in printf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-170", - "function": "main", - "file": "test_config.c", - "line": 76, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strstr", + "file": "cmd_comp.c", + "line": 102, + "failureMode": "strstr (general function) does not perform its intended action", + "effect": "Failure of strstr could propagate undetected to callers in cmd_comp.c", + "cause": "Logic error or untested edge case in strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-171", - "function": "setUp", - "file": "test_utils.c", - "line": 5, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_comp.c", + "line": 184, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_comp.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-172", - "function": "tearDown", - "file": "test_utils.c", - "line": 6, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_comp", + "file": "cmd_comp.c", + "line": 222, + "failureMode": "cmd_comp (general function) does not perform its intended action", + "effect": "Failure of cmd_comp could propagate undetected to callers in cmd_comp.c", + "cause": "Logic error or untested edge case in cmd_comp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-173", - "function": "test_sha256_empty", - "file": "test_utils.c", - "line": 10, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_audit_pack", + "file": "cmd_audit_pack.c", + "line": 21, + "failureMode": "cmd_audit_pack (general function) does not perform its intended action", + "effect": "Failure of cmd_audit_pack could propagate undetected to callers in cmd_audit_pack.c", + "cause": "Logic error or untested edge case in cmd_audit_pack", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-174", - "function": "test_sha256_abc", - "file": "test_utils.c", - "line": 21, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_audit_pack.c", + "line": 149, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_audit_pack.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-175", - "function": "test_sha256_length", - "file": "test_utils.c", - "line": 31, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_audit_pack.c", + "line": 162, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_audit_pack.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-176", - "function": "test_hmac_sha256_known", - "file": "test_utils.c", - "line": 40, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_audit_pack.c", + "line": 187, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_audit_pack.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-177", - "function": "test_str_contains_found", - "file": "test_utils.c", - "line": 55, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_hooks", + "file": "cmd_hooks.c", + "line": 20, + "failureMode": "cmd_hooks (general function) does not perform its intended action", + "effect": "Failure of cmd_hooks could propagate undetected to callers in cmd_hooks.c", + "cause": "Logic error or untested edge case in cmd_hooks", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-178", - "function": "test_str_contains_not_found", - "file": "test_utils.c", - "line": 60, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_disposition", + "file": "cmd_disposition.c", + "line": 184, + "failureMode": "cmd_disposition (general function) does not perform its intended action", + "effect": "Failure of cmd_disposition could propagate undetected to callers in cmd_disposition.c", + "cause": "Logic error or untested edge case in cmd_disposition", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-179", - "function": "test_str_starts_with", - "file": "test_utils.c", - "line": 65, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strcmp", + "file": "cmd_disposition.c", + "line": 261, + "failureMode": "strcmp (general function) does not perform its intended action", + "effect": "Failure of strcmp could propagate undetected to callers in cmd_disposition.c", + "cause": "Logic error or untested edge case in strcmp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-180", - "function": "test_basename", - "file": "test_utils.c", - "line": 71, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_coverage.c", + "line": 42, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_coverage.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-181", - "function": "test_extension", - "file": "test_utils.c", - "line": 78, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_coverage.c", + "line": 81, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_coverage.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-182", - "function": "test_str_trim", - "file": "test_utils.c", - "line": 84, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_coverage.c", + "line": 93, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_coverage.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-183", - "function": "test_str_escape_json", - "file": "test_utils.c", - "line": 92, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_coverage", + "file": "cmd_coverage.c", + "line": 174, + "failureMode": "cmd_coverage (general function) does not perform its intended action", + "effect": "Failure of cmd_coverage could propagate undetected to callers in cmd_coverage.c", + "cause": "Logic error or untested edge case in cmd_coverage", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-184", - "function": "test_path_join", - "file": "test_utils.c", - "line": 99, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strcmp", + "file": "cmd_coverage.c", + "line": 258, + "failureMode": "strcmp (general function) does not perform its intended action", + "effect": "Failure of strcmp could propagate undetected to callers in cmd_coverage.c", + "cause": "Logic error or untested edge case in strcmp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-185", - "function": "test_path_join_trailing_slash", - "file": "test_utils.c", - "line": 106, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_coverage.c", + "line": 408, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_coverage.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-186", - "function": "main", - "file": "test_utils.c", - "line": 113, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_coverage.c", + "line": 411, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_coverage.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-187", - "function": "setUp", - "file": "test_report.c", - "line": 8, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_coverage.c", + "line": 413, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_coverage.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-188", - "function": "tearDown", - "file": "test_report.c", - "line": 9, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_coverage.c", + "line": 425, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_coverage.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-189", - "function": "test_report_init", - "file": "test_report.c", - "line": 11, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Medium", - "occurrence": 1, - "detection": 1, - "rpn": 5 + "item": "cmd_diff", + "file": "cmd_diff.c", + "line": 66, + "failureMode": "cmd_diff (general function) does not perform its intended action", + "effect": "Failure of cmd_diff could propagate undetected to callers in cmd_diff.c", + "cause": "Logic error or untested edge case in cmd_diff", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-190", - "function": "test_report_add_error", - "file": "test_report.c", - "line": 23, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "High", - "occurrence": 1, - "detection": 1, - "rpn": 9 + "item": "fprintf", + "file": "cmd_hara.c", + "line": 622, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_hara.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-191", - "function": "test_report_add_warning", - "file": "test_report.c", - "line": 38, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "parse_sec_code", + "file": "cmd_hara.c", + "line": 650, + "failureMode": "parse_sec_code (general function) does not perform its intended action", + "effect": "Failure of parse_sec_code could propagate undetected to callers in cmd_hara.c", + "cause": "Logic error or untested edge case in parse_sec_code", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-192", - "function": "test_report_score_100", - "file": "test_report.c", - "line": 50, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_hara", + "file": "cmd_hara.c", + "line": 770, + "failureMode": "cmd_hara (general function) does not perform its intended action", + "effect": "Failure of cmd_hara could propagate undetected to callers in cmd_hara.c", + "cause": "Logic error or untested edge case in cmd_hara", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-193", - "function": "test_report_score_decreases_with_errors", - "file": "test_report.c", - "line": 58, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "High", - "occurrence": 1, - "detection": 1, - "rpn": 9 + "item": "cmd_slsa", + "file": "cmd_slsa.c", + "line": 71, + "failureMode": "cmd_slsa (general function) does not perform its intended action", + "effect": "Failure of cmd_slsa could propagate undetected to callers in cmd_slsa.c", + "cause": "Logic error or untested edge case in cmd_slsa", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-194", - "function": "test_report_severity_str", - "file": "test_report.c", - "line": 69, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "slsa_file_exists", + "file": "cmd_slsa.c", + "line": 123, + "failureMode": "slsa_file_exists (general function) does not perform its intended action", + "effect": "Failure of slsa_file_exists could propagate undetected to callers in cmd_slsa.c", + "cause": "Logic error or untested edge case in slsa_file_exists", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-195", - "function": "test_format_parse", - "file": "test_report.c", - "line": 76, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_do178", + "file": "cmd_do178.c", + "line": 113, + "failureMode": "cmd_do178 (general function) does not perform its intended action", + "effect": "Failure of cmd_do178 could propagate undetected to callers in cmd_do178.c", + "cause": "Logic error or untested edge case in cmd_do178", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-196", - "function": "test_report_json_output", - "file": "test_report.c", - "line": 86, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_verify", + "file": "cmd_verify.c", + "line": 14, + "failureMode": "cmd_verify (general function) does not perform its intended action", + "effect": "Failure of cmd_verify could propagate undetected to callers in cmd_verify.c", + "cause": "Logic error or untested edge case in cmd_verify", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-197", - "function": "test_report_sarif_output", - "file": "test_report.c", - "line": 110, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_sas.c", + "line": 61, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_sas.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-198", - "function": "main", - "file": "test_report.c", - "line": 131, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_sas", + "file": "cmd_sas.c", + "line": 90, + "failureMode": "cmd_sas (general function) does not perform its intended action", + "effect": "Failure of cmd_sas could propagate undetected to callers in cmd_sas.c", + "cause": "Logic error or untested edge case in cmd_sas", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-199", - "function": "cfusa_report_init", - "file": "report.c", - "line": 10, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Medium", - "occurrence": 1, - "detection": 1, - "rpn": 5 + "item": "fprintf", + "file": "cmd_sas.c", + "line": 178, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_sas.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-200", - "function": "cfusa_report_free", - "file": "report.c", - "line": 23, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_sas.c", + "line": 255, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_sas.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-201", - "function": "cfusa_severity_str", - "file": "report.c", - "line": 69, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "for", + "file": "cmd_cyber.c", + "line": 19, + "failureMode": "for (general function) does not perform its intended action", + "effect": "Failure of for could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in for", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-202", - "function": "cfusa_format_parse", - "file": "report.c", - "line": 79, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 22, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-203", - "function": "cfusa_report_score", - "file": "report.c", - "line": 90, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "||", + "file": "cmd_cyber.c", + "line": 23, + "failureMode": "|| (general function) does not perform its intended action", + "effect": "Failure of || could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in ||", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-204", - "function": "cfusa_report_score", - "file": "report.c", - "line": 106, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "for", + "file": "cmd_cyber.c", + "line": 51, + "failureMode": "for (general function) does not perform its intended action", + "effect": "Failure of for could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in for", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-205", - "function": "cfusa_severity_str", - "file": "report.c", - "line": 112, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 55, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-206", - "function": "cfusa_report_score", - "file": "report.c", - "line": 137, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 63, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-207", - "function": "cfusa_severity_str", - "file": "report.c", - "line": 151, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 71, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-208", - "function": "cfusa_report_score", - "file": "report.c", - "line": 213, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strncmp", + "file": "cmd_cyber.c", + "line": 72, + "failureMode": "strncmp (general function) does not perform its intended action", + "effect": "Failure of strncmp could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in strncmp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-209", - "function": "cfusa_severity_str", - "file": "report.c", - "line": 228, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "for", + "file": "cmd_cyber.c", + "line": 96, + "failureMode": "for (general function) does not perform its intended action", + "effect": "Failure of for could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in for", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-210", - "function": "cfusa_severity_str", - "file": "report.c", - "line": 229, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 103, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-211", - "function": "cfusa_report_score", - "file": "report.c", - "line": 255, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 155, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-212", - "function": "cfusa_severity_str", - "file": "report.c", - "line": 269, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "strstr", + "file": "cmd_cyber.c", + "line": 156, + "failureMode": "strstr (general function) does not perform its intended action", + "effect": "Failure of strstr could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-213", - "function": "cfusa_report_print", - "file": "report.c", - "line": 276, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 179, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-214", - "function": "cfusa_engine_reset", - "file": "engine.c", - "line": 8, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "free", + "file": "cmd_cyber.c", + "line": 182, + "failureMode": "free (general function) does not perform its intended action", + "effect": "Failure of free could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in free", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-215", - "function": "cfusa_engine_register", - "file": "engine.c", - "line": 13, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 204, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-216", - "function": "cfusa_engine_rule_count", - "file": "engine.c", - "line": 22, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 223, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-217", - "function": "cfusa_engine_list_rules", - "file": "engine.c", - "line": 27, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_match_outside_string", + "file": "cmd_cyber.c", + "line": 224, + "failureMode": "cfusa_match_outside_string (general function) does not perform its intended action", + "effect": "Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in cfusa_match_outside_string", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-218", - "function": "strcmp", - "file": "utils.c", - "line": 43, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "mkstemp", + "file": "cmd_cyber.c", + "line": 227, + "failureMode": "mkstemp (general function) does not perform its intended action", + "effect": "Failure of mkstemp could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in mkstemp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-219", - "function": "cfusa_read_file", - "file": "utils.c", - "line": 57, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "for", + "file": "cmd_cyber.c", + "line": 246, + "failureMode": "for (general function) does not perform its intended action", + "effect": "Failure of for could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in for", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-220", - "function": "cfusa_file_exists", - "file": "utils.c", - "line": 75, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 247, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-221", - "function": "cfusa_dir_exists", - "file": "utils.c", - "line": 81, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "for", + "file": "cmd_cyber.c", + "line": 270, + "failureMode": "for (general function) does not perform its intended action", + "effect": "Failure of for could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in for", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-222", - "function": "cfusa_mkdir_p", - "file": "utils.c", - "line": 87, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "if", + "file": "cmd_cyber.c", + "line": 274, + "failureMode": "if (general function) does not perform its intended action", + "effect": "Failure of if could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in if", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-223", - "function": "cfusa_scan_lines", - "file": "utils.c", - "line": 103, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_match_outside_string", + "file": "cmd_cyber.c", + "line": 329, + "failureMode": "cfusa_match_outside_string (general function) does not perform its intended action", + "effect": "Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in cfusa_match_outside_string", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-224", - "function": "cfusa_basename", - "file": "utils.c", - "line": 121, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_match_outside_string", + "file": "cmd_cyber.c", + "line": 349, + "failureMode": "cfusa_match_outside_string (general function) does not perform its intended action", + "effect": "Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in cfusa_match_outside_string", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-225", - "function": "cfusa_extension", - "file": "utils.c", - "line": 127, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_match_outside_string", + "file": "cmd_cyber.c", + "line": 350, + "failureMode": "cfusa_match_outside_string (general function) does not perform its intended action", + "effect": "Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in cfusa_match_outside_string", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-226", - "function": "cfusa_str_contains", - "file": "utils.c", - "line": 134, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "realpath", + "file": "cmd_cyber.c", + "line": 352, + "failureMode": "realpath (general function) does not perform its intended action", + "effect": "Failure of realpath could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in realpath", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-227", - "function": "cfusa_str_starts_with", - "file": "utils.c", - "line": 139, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "TLS_method", + "file": "cmd_cyber.c", + "line": 378, + "failureMode": "TLS_method (general function) does not perform its intended action", + "effect": "Failure of TLS_method could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in TLS_method", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-228", - "function": "cfusa_str_trim", - "file": "utils.c", - "line": 144, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_match_outside_string", + "file": "cmd_cyber.c", + "line": 445, + "failureMode": "cfusa_match_outside_string (general function) does not perform its intended action", + "effect": "Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in cfusa_match_outside_string", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-229", - "function": "cfusa_str_escape_json", - "file": "utils.c", - "line": 155, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_match_outside_string", + "file": "cmd_cyber.c", + "line": 479, + "failureMode": "cfusa_match_outside_string (general function) does not perform its intended action", + "effect": "Failure of cfusa_match_outside_string could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in cfusa_match_outside_string", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-230", - "function": "cfusa_path_join", - "file": "utils.c", - "line": 175, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "access", + "file": "cmd_cyber.c", + "line": 503, + "failureMode": "access (general function) does not perform its intended action", + "effect": "Failure of access could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in access", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-231", - "function": "cfusa_sha256_buf", - "file": "utils.c", - "line": 297, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cfusa_cyber_register_rules", + "file": "cmd_cyber.c", + "line": 564, + "failureMode": "cfusa_cyber_register_rules (general function) does not perform its intended action", + "effect": "Failure of cfusa_cyber_register_rules could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in cfusa_cyber_register_rules", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-232", - "function": "cfusa_sha256_file", - "file": "utils.c", - "line": 309, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "for", + "file": "cmd_cyber.c", + "line": 566, + "failureMode": "for (general function) does not perform its intended action", + "effect": "Failure of for could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in for", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-233", - "function": "cfusa_sha256_buf", - "file": "utils.c", - "line": 338, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_cyber", + "file": "cmd_cyber.c", + "line": 570, + "failureMode": "cmd_cyber (general function) does not perform its intended action", + "effect": "Failure of cmd_cyber could propagate undetected to callers in cmd_cyber.c", + "cause": "Logic error or untested edge case in cmd_cyber", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-234", - "function": "cfusa_timestamp_now", - "file": "utils.c", - "line": 369, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "cmd_safety_case", + "file": "cmd_safety_case.c", + "line": 35, + "failureMode": "cmd_safety_case (safety-critical function) does not perform its intended action", + "effect": "Failure of cmd_safety_case could propagate undetected to callers in cmd_safety_case.c", + "cause": "Unhandled fault or invalid input condition within cmd_safety_case", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-235", - "function": "cfusa_count_c_files", - "file": "utils.c", - "line": 385, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_safety_case.c", + "line": 106, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_safety_case.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-236", - "function": "cfusa_count_lines_in_file", - "file": "utils.c", - "line": 393, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_safety_case.c", + "line": 110, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_safety_case.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-237", - "function": "cfusa_match_outside_string", - "file": "utils.c", - "line": 405, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "snprintf", + "file": "cmd_safety_case.c", + "line": 113, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_safety_case.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-238", - "function": "cfusa_config_defaults", - "file": "config.c", - "line": 7, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "High", - "occurrence": 1, - "detection": 1, - "rpn": 9 + "item": "snprintf", + "file": "cmd_safety_case.c", + "line": 116, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_safety_case.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-239", - "function": "cfusa_config_load", - "file": "config.c", - "line": 91, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Medium", - "occurrence": 1, - "detection": 1, - "rpn": 5 + "item": "snprintf", + "file": "cmd_safety_case.c", + "line": 119, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in cmd_safety_case.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-240", - "function": "extract_str_array_n", - "file": "config.c", - "line": 108, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_safety_case.c", + "line": 223, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_safety_case.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-241", - "function": "extract_str_array_n", - "file": "config.c", - "line": 111, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Low", - "occurrence": 1, - "detection": 1, - "rpn": 3 + "item": "fprintf", + "file": "cmd_safety_case.c", + "line": 317, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_safety_case.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-242", - "function": "cfusa_config_save", - "file": "config.c", - "line": 119, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Medium", - "occurrence": 1, - "detection": 1, - "rpn": 5 + "item": "cmd_metrics", + "file": "cmd_metrics.c", + "line": 288, + "failureMode": "cmd_metrics (general function) does not perform its intended action", + "effect": "Failure of cmd_metrics could propagate undetected to callers in cmd_metrics.c", + "cause": "Logic error or untested edge case in cmd_metrics", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] }, { "id": "FM-243", - "function": "cfusa_config_is_excluded", + "item": "cmd_capabilities", + "file": "cmd_capabilities.c", + "line": 15, + "failureMode": "cmd_capabilities (general function) does not perform its intended action", + "effect": "Failure of cmd_capabilities could propagate undetected to callers in cmd_capabilities.c", + "cause": "Logic error or untested edge case in cmd_capabilities", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-244", + "item": "fprintf", + "file": "cmd_capabilities.c", + "line": 86, + "failureMode": "fprintf (general function) does not perform its intended action", + "effect": "Failure of fprintf could propagate undetected to callers in cmd_capabilities.c", + "cause": "Logic error or untested edge case in fprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-245", + "item": "strstr", + "file": "cmd_lint.c", + "line": 42, + "failureMode": "strstr (general function) does not perform its intended action", + "effect": "Failure of strstr could propagate undetected to callers in cmd_lint.c", + "cause": "Logic error or untested edge case in strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-246", + "item": "fgets", + "file": "cmd_lint.c", + "line": 186, + "failureMode": "fgets (general function) does not perform its intended action", + "effect": "Failure of fgets could propagate undetected to callers in cmd_lint.c", + "cause": "Logic error or untested edge case in fgets", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-247", + "item": "strstr", + "file": "cmd_lint.c", + "line": 220, + "failureMode": "strstr (general function) does not perform its intended action", + "effect": "Failure of strstr could propagate undetected to callers in cmd_lint.c", + "cause": "Logic error or untested edge case in strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-248", + "item": "!strstr", + "file": "cmd_lint.c", + "line": 222, + "failureMode": "!strstr (general function) does not perform its intended action", + "effect": "Failure of !strstr could propagate undetected to callers in cmd_lint.c", + "cause": "Logic error or untested edge case in !strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-249", + "item": "!strstr", + "file": "cmd_lint.c", + "line": 384, + "failureMode": "!strstr (general function) does not perform its intended action", + "effect": "Failure of !strstr could propagate undetected to callers in cmd_lint.c", + "cause": "Logic error or untested edge case in !strstr", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-250", + "item": "cfusa_lint_register_rules", + "file": "cmd_lint.c", + "line": 527, + "failureMode": "cfusa_lint_register_rules (general function) does not perform its intended action", + "effect": "Failure of cfusa_lint_register_rules could propagate undetected to callers in cmd_lint.c", + "cause": "Logic error or untested edge case in cfusa_lint_register_rules", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-251", + "item": "cmd_lint", + "file": "cmd_lint.c", + "line": 535, + "failureMode": "cmd_lint (general function) does not perform its intended action", + "effect": "Failure of cmd_lint could propagate undetected to callers in cmd_lint.c", + "cause": "Logic error or untested edge case in cmd_lint", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-252", + "item": "defined", + "file": "CMakeCCompilerId.c", + "line": 891, + "failureMode": "defined (general function) does not perform its intended action", + "effect": "Failure of defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-253", + "item": "!defined", + "file": "CMakeCCompilerId.c", + "line": 892, + "failureMode": "!defined (general function) does not perform its intended action", + "effect": "Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in !defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-254", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 902, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-255", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 907, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-256", + "item": "defined", + "file": "CMakeCCompilerId.c", + "line": 891, + "failureMode": "defined (general function) does not perform its intended action", + "effect": "Failure of defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-257", + "item": "!defined", + "file": "CMakeCCompilerId.c", + "line": 892, + "failureMode": "!defined (general function) does not perform its intended action", + "effect": "Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in !defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-258", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 902, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-259", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 907, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-260", + "item": "defined", + "file": "CMakeCCompilerId.c", + "line": 891, + "failureMode": "defined (general function) does not perform its intended action", + "effect": "Failure of defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-261", + "item": "!defined", + "file": "CMakeCCompilerId.c", + "line": 892, + "failureMode": "!defined (general function) does not perform its intended action", + "effect": "Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in !defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-262", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 902, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-263", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 907, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-264", + "item": "defined", + "file": "CMakeCCompilerId.c", + "line": 891, + "failureMode": "defined (general function) does not perform its intended action", + "effect": "Failure of defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-265", + "item": "!defined", + "file": "CMakeCCompilerId.c", + "line": 892, + "failureMode": "!defined (general function) does not perform its intended action", + "effect": "Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in !defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-266", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 902, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-267", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 907, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-268", + "item": "defined", + "file": "CMakeCCompilerId.c", + "line": 891, + "failureMode": "defined (general function) does not perform its intended action", + "effect": "Failure of defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-269", + "item": "!defined", + "file": "CMakeCCompilerId.c", + "line": 892, + "failureMode": "!defined (general function) does not perform its intended action", + "effect": "Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in !defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-270", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 902, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-271", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 907, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-272", + "item": "defined", + "file": "CMakeCCompilerId.c", + "line": 891, + "failureMode": "defined (general function) does not perform its intended action", + "effect": "Failure of defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-273", + "item": "!defined", + "file": "CMakeCCompilerId.c", + "line": 892, + "failureMode": "!defined (general function) does not perform its intended action", + "effect": "Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in !defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-274", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 902, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-275", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 907, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-276", + "item": "defined", + "file": "CMakeCCompilerId.c", + "line": 891, + "failureMode": "defined (general function) does not perform its intended action", + "effect": "Failure of defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-277", + "item": "!defined", + "file": "CMakeCCompilerId.c", + "line": 892, + "failureMode": "!defined (general function) does not perform its intended action", + "effect": "Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in !defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-278", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 902, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-279", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 907, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-280", + "item": "defined", + "file": "CMakeCCompilerId.c", + "line": 891, + "failureMode": "defined (general function) does not perform its intended action", + "effect": "Failure of defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-281", + "item": "!defined", + "file": "CMakeCCompilerId.c", + "line": 892, + "failureMode": "!defined (general function) does not perform its intended action", + "effect": "Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in !defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-282", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 902, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-283", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 907, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-284", + "item": "defined", + "file": "CMakeCCompilerId.c", + "line": 891, + "failureMode": "defined (general function) does not perform its intended action", + "effect": "Failure of defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-285", + "item": "!defined", + "file": "CMakeCCompilerId.c", + "line": 892, + "failureMode": "!defined (general function) does not perform its intended action", + "effect": "Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in !defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-286", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 902, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-287", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 907, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-288", + "item": "defined", + "file": "CMakeCCompilerId.c", + "line": 891, + "failureMode": "defined (general function) does not perform its intended action", + "effect": "Failure of defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-289", + "item": "!defined", + "file": "CMakeCCompilerId.c", + "line": 892, + "failureMode": "!defined (general function) does not perform its intended action", + "effect": "Failure of !defined could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in !defined", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-290", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 902, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-291", + "item": "main", + "file": "CMakeCCompilerId.c", + "line": 907, + "failureMode": "main (general function) does not perform its intended action", + "effect": "Failure of main could propagate undetected to callers in CMakeCCompilerId.c", + "cause": "Logic error or untested edge case in main", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-292", + "item": "cfusa_watchdog_kick", + "file": "cfusa_runtime.c", + "line": 26, + "failureMode": "cfusa_watchdog_kick (safety-critical function) does not perform its intended action", + "effect": "Failure of cfusa_watchdog_kick could propagate undetected to callers in cfusa_runtime.c", + "cause": "Unhandled fault or invalid input condition within cfusa_watchdog_kick", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-293", + "item": "cfusa_watchdog_check", + "file": "cfusa_runtime.c", + "line": 33, + "failureMode": "cfusa_watchdog_check (safety-critical function) does not perform its intended action", + "effect": "Failure of cfusa_watchdog_check could propagate undetected to callers in cfusa_runtime.c", + "cause": "Unhandled fault or invalid input condition within cfusa_watchdog_check", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-294", + "item": "cfusa_watchdog_stop", + "file": "cfusa_runtime.c", + "line": 43, + "failureMode": "cfusa_watchdog_stop (safety-critical function) does not perform its intended action", + "effect": "Failure of cfusa_watchdog_stop could propagate undetected to callers in cfusa_runtime.c", + "cause": "Unhandled fault or invalid input condition within cfusa_watchdog_stop", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-295", + "item": "cfusa_watchdog_fired", + "file": "cfusa_runtime.c", + "line": 48, + "failureMode": "cfusa_watchdog_fired (safety-critical function) does not perform its intended action", + "effect": "Failure of cfusa_watchdog_fired could propagate undetected to callers in cfusa_runtime.c", + "cause": "Unhandled fault or invalid input condition within cfusa_watchdog_fired", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-296", + "item": "cfusa_heartbeat_beat", + "file": "cfusa_runtime.c", + "line": 67, + "failureMode": "cfusa_heartbeat_beat (general function) does not perform its intended action", + "effect": "Failure of cfusa_heartbeat_beat could propagate undetected to callers in cfusa_runtime.c", + "cause": "Logic error or untested edge case in cfusa_heartbeat_beat", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-297", + "item": "cfusa_heartbeat_check", + "file": "cfusa_runtime.c", + "line": 74, + "failureMode": "cfusa_heartbeat_check (monitoring/control function) does not perform its intended action", + "effect": "Failure of cfusa_heartbeat_check could propagate undetected to callers in cfusa_runtime.c", + "cause": "Configuration or state inconsistency affecting cfusa_heartbeat_check", + "severity": 5, + "occurrence": 3, + "detection": 4, + "actionPriority": "medium", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-298", + "item": "cfusa_heartbeat_stop", + "file": "cfusa_runtime.c", + "line": 85, + "failureMode": "cfusa_heartbeat_stop (general function) does not perform its intended action", + "effect": "Failure of cfusa_heartbeat_stop could propagate undetected to callers in cfusa_runtime.c", + "cause": "Logic error or untested edge case in cfusa_heartbeat_stop", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-299", + "item": "cfusa_heartbeat_missed", + "file": "cfusa_runtime.c", + "line": 90, + "failureMode": "cfusa_heartbeat_missed (general function) does not perform its intended action", + "effect": "Failure of cfusa_heartbeat_missed could propagate undetected to callers in cfusa_runtime.c", + "cause": "Logic error or untested edge case in cfusa_heartbeat_missed", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-300", + "item": "cfusa_state_get", + "file": "cfusa_runtime.c", + "line": 107, + "failureMode": "cfusa_state_get (general function) does not perform its intended action", + "effect": "Failure of cfusa_state_get could propagate undetected to callers in cfusa_runtime.c", + "cause": "Logic error or untested edge case in cfusa_state_get", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-301", + "item": "cfusa_state_transition", + "file": "cfusa_runtime.c", + "line": 112, + "failureMode": "cfusa_state_transition (general function) does not perform its intended action", + "effect": "Failure of cfusa_state_transition could propagate undetected to callers in cfusa_runtime.c", + "cause": "Logic error or untested edge case in cfusa_state_transition", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-302", + "item": "cfusa_state_name", + "file": "cfusa_runtime.c", + "line": 123, + "failureMode": "cfusa_state_name (general function) does not perform its intended action", + "effect": "Failure of cfusa_state_name could propagate undetected to callers in cfusa_runtime.c", + "cause": "Logic error or untested edge case in cfusa_state_name", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-303", + "item": "cfusa_diag_init", + "file": "cfusa_runtime.c", + "line": 137, + "failureMode": "cfusa_diag_init (monitoring/control function) does not perform its intended action", + "effect": "Failure of cfusa_diag_init could propagate undetected to callers in cfusa_runtime.c", + "cause": "Configuration or state inconsistency affecting cfusa_diag_init", + "severity": 5, + "occurrence": 3, + "detection": 4, + "actionPriority": "medium", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-304", + "item": "cfusa_diag_count", + "file": "cfusa_runtime.c", + "line": 160, + "failureMode": "cfusa_diag_count (general function) does not perform its intended action", + "effect": "Failure of cfusa_diag_count could propagate undetected to callers in cfusa_runtime.c", + "cause": "Logic error or untested edge case in cfusa_diag_count", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-305", + "item": "cfusa_diag_get", + "file": "cfusa_runtime.c", + "line": 165, + "failureMode": "cfusa_diag_get (general function) does not perform its intended action", + "effect": "Failure of cfusa_diag_get could propagate undetected to callers in cfusa_runtime.c", + "cause": "Logic error or untested edge case in cfusa_diag_get", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-306", + "item": "cfusa_diag_clear", + "file": "cfusa_runtime.c", + "line": 174, + "failureMode": "cfusa_diag_clear (general function) does not perform its intended action", + "effect": "Failure of cfusa_diag_clear could propagate undetected to callers in cfusa_runtime.c", + "cause": "Logic error or untested edge case in cfusa_diag_clear", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-307", + "item": "cfusa_diag_level_name", + "file": "cfusa_runtime.c", + "line": 179, + "failureMode": "cfusa_diag_level_name (general function) does not perform its intended action", + "effect": "Failure of cfusa_diag_level_name could propagate undetected to callers in cfusa_runtime.c", + "cause": "Logic error or untested edge case in cfusa_diag_level_name", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-308", + "item": "cfusa_fault_record", + "file": "cfusa_runtime.c", + "line": 223, + "failureMode": "cfusa_fault_record (safety-critical function) does not perform its intended action", + "effect": "Failure of cfusa_fault_record could propagate undetected to callers in cfusa_runtime.c", + "cause": "Unhandled fault or invalid input condition within cfusa_fault_record", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-309", + "item": "cfusa_fault_reset", + "file": "cfusa_runtime.c", + "line": 233, + "failureMode": "cfusa_fault_reset (safety-critical function) does not perform its intended action", + "effect": "Failure of cfusa_fault_reset could propagate undetected to callers in cfusa_runtime.c", + "cause": "Unhandled fault or invalid input condition within cfusa_fault_reset", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-310", + "item": "cfusa_fault_count", + "file": "cfusa_runtime.c", + "line": 240, + "failureMode": "cfusa_fault_count (safety-critical function) does not perform its intended action", + "effect": "Failure of cfusa_fault_count could propagate undetected to callers in cfusa_runtime.c", + "cause": "Unhandled fault or invalid input condition within cfusa_fault_count", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-311", + "item": "cfusa_report_init", + "file": "report.c", + "line": 14, + "failureMode": "cfusa_report_init (monitoring/control function) does not perform its intended action", + "effect": "Failure of cfusa_report_init could propagate undetected to callers in report.c", + "cause": "Configuration or state inconsistency affecting cfusa_report_init", + "severity": 5, + "occurrence": 3, + "detection": 4, + "actionPriority": "medium", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-312", + "item": "cfusa_report_free", + "file": "report.c", + "line": 27, + "failureMode": "cfusa_report_free (general function) does not perform its intended action", + "effect": "Failure of cfusa_report_free could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_report_free", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-313", + "item": "snprintf", + "file": "report.c", + "line": 117, + "failureMode": "snprintf (general function) does not perform its intended action", + "effect": "Failure of snprintf could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in snprintf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-314", + "item": "cfusa_severity_str", + "file": "report.c", + "line": 127, + "failureMode": "cfusa_severity_str (general function) does not perform its intended action", + "effect": "Failure of cfusa_severity_str could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_severity_str", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-315", + "item": "cfusa_format_parse", + "file": "report.c", + "line": 137, + "failureMode": "cfusa_format_parse (general function) does not perform its intended action", + "effect": "Failure of cfusa_format_parse could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_format_parse", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-316", + "item": "cfusa_report_score", + "file": "report.c", + "line": 148, + "failureMode": "cfusa_report_score (general function) does not perform its intended action", + "effect": "Failure of cfusa_report_score could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_report_score", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-317", + "item": "cfusa_report_score", + "file": "report.c", + "line": 256, + "failureMode": "cfusa_report_score (general function) does not perform its intended action", + "effect": "Failure of cfusa_report_score could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_report_score", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-318", + "item": "cfusa_severity_str", + "file": "report.c", + "line": 262, + "failureMode": "cfusa_severity_str (general function) does not perform its intended action", + "effect": "Failure of cfusa_severity_str could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_severity_str", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-319", + "item": "cfusa_report_score", + "file": "report.c", + "line": 307, + "failureMode": "cfusa_report_score (general function) does not perform its intended action", + "effect": "Failure of cfusa_report_score could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_report_score", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-320", + "item": "cfusa_severity_str", + "file": "report.c", + "line": 344, + "failureMode": "cfusa_severity_str (general function) does not perform its intended action", + "effect": "Failure of cfusa_severity_str could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_severity_str", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-321", + "item": "cfusa_severity_str", + "file": "report.c", + "line": 360, + "failureMode": "cfusa_severity_str (general function) does not perform its intended action", + "effect": "Failure of cfusa_severity_str could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_severity_str", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-322", + "item": "cfusa_severity_str", + "file": "report.c", + "line": 375, + "failureMode": "cfusa_severity_str (general function) does not perform its intended action", + "effect": "Failure of cfusa_severity_str could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_severity_str", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-323", + "item": "cfusa_report_score", + "file": "report.c", + "line": 508, + "failureMode": "cfusa_report_score (general function) does not perform its intended action", + "effect": "Failure of cfusa_report_score could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_report_score", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-324", + "item": "cfusa_severity_str", + "file": "report.c", + "line": 523, + "failureMode": "cfusa_severity_str (general function) does not perform its intended action", + "effect": "Failure of cfusa_severity_str could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_severity_str", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-325", + "item": "cfusa_severity_str", + "file": "report.c", + "line": 524, + "failureMode": "cfusa_severity_str (general function) does not perform its intended action", + "effect": "Failure of cfusa_severity_str could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_severity_str", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-326", + "item": "cfusa_report_score", + "file": "report.c", + "line": 550, + "failureMode": "cfusa_report_score (general function) does not perform its intended action", + "effect": "Failure of cfusa_report_score could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_report_score", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-327", + "item": "cfusa_severity_str", + "file": "report.c", + "line": 564, + "failureMode": "cfusa_severity_str (general function) does not perform its intended action", + "effect": "Failure of cfusa_severity_str could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_severity_str", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-328", + "item": "cfusa_report_print", + "file": "report.c", + "line": 571, + "failureMode": "cfusa_report_print (general function) does not perform its intended action", + "effect": "Failure of cfusa_report_print could propagate undetected to callers in report.c", + "cause": "Logic error or untested edge case in cfusa_report_print", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-329", + "item": "cfusa_qb_is_stub_text", + "file": "qualitybar.c", + "line": 44, + "failureMode": "cfusa_qb_is_stub_text (general function) does not perform its intended action", + "effect": "Failure of cfusa_qb_is_stub_text could propagate undetected to callers in qualitybar.c", + "cause": "Logic error or untested edge case in cfusa_qb_is_stub_text", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-330", + "item": "cfusa_qb_rule_b_flagged", + "file": "qualitybar.c", + "line": 59, + "failureMode": "cfusa_qb_rule_b_flagged (general function) does not perform its intended action", + "effect": "Failure of cfusa_qb_rule_b_flagged could propagate undetected to callers in qualitybar.c", + "cause": "Logic error or untested edge case in cfusa_qb_rule_b_flagged", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-331", + "item": "cfusa_qb_attestation_read", + "file": "qualitybar.c", + "line": 100, + "failureMode": "cfusa_qb_attestation_read (general function) does not perform its intended action", + "effect": "Failure of cfusa_qb_attestation_read could propagate undetected to callers in qualitybar.c", + "cause": "Logic error or untested edge case in cfusa_qb_attestation_read", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-332", + "item": "cfusa_qb_attestation_valid", + "file": "qualitybar.c", + "line": 161, + "failureMode": "cfusa_qb_attestation_valid (general function) does not perform its intended action", + "effect": "Failure of cfusa_qb_attestation_valid could propagate undetected to callers in qualitybar.c", + "cause": "Logic error or untested edge case in cfusa_qb_attestation_valid", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-333", + "item": "cfusa_qb_rule_disposed", + "file": "qualitybar.c", + "line": 180, + "failureMode": "cfusa_qb_rule_disposed (general function) does not perform its intended action", + "effect": "Failure of cfusa_qb_rule_disposed could propagate undetected to callers in qualitybar.c", + "cause": "Logic error or untested edge case in cfusa_qb_rule_disposed", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-334", + "item": "cfusa_qb_content_hash", + "file": "qualitybar.c", + "line": 206, + "failureMode": "cfusa_qb_content_hash (general function) does not perform its intended action", + "effect": "Failure of cfusa_qb_content_hash could propagate undetected to callers in qualitybar.c", + "cause": "Logic error or untested edge case in cfusa_qb_content_hash", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-335", + "item": "cfusa_engine_reset", + "file": "engine.c", + "line": 9, + "failureMode": "cfusa_engine_reset (general function) does not perform its intended action", + "effect": "Failure of cfusa_engine_reset could propagate undetected to callers in engine.c", + "cause": "Logic error or untested edge case in cfusa_engine_reset", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-336", + "item": "cfusa_engine_register", + "file": "engine.c", + "line": 14, + "failureMode": "cfusa_engine_register (general function) does not perform its intended action", + "effect": "Failure of cfusa_engine_register could propagate undetected to callers in engine.c", + "cause": "Logic error or untested edge case in cfusa_engine_register", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-337", + "item": "cfusa_engine_rule_count", + "file": "engine.c", + "line": 23, + "failureMode": "cfusa_engine_rule_count (general function) does not perform its intended action", + "effect": "Failure of cfusa_engine_rule_count could propagate undetected to callers in engine.c", + "cause": "Logic error or untested edge case in cfusa_engine_rule_count", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-338", + "item": "cfusa_engine_get_rule", + "file": "engine.c", + "line": 28, + "failureMode": "cfusa_engine_get_rule (general function) does not perform its intended action", + "effect": "Failure of cfusa_engine_get_rule could propagate undetected to callers in engine.c", + "cause": "Logic error or untested edge case in cfusa_engine_get_rule", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-339", + "item": "cfusa_engine_list_rules", + "file": "engine.c", + "line": 34, + "failureMode": "cfusa_engine_list_rules (general function) does not perform its intended action", + "effect": "Failure of cfusa_engine_list_rules could propagate undetected to callers in engine.c", + "cause": "Logic error or untested edge case in cfusa_engine_list_rules", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-340", + "item": "!cfusa_config_is_rule_disabled", + "file": "engine.c", + "line": 65, + "failureMode": "!cfusa_config_is_rule_disabled (monitoring/control function) does not perform its intended action", + "effect": "Failure of !cfusa_config_is_rule_disabled could propagate undetected to callers in engine.c", + "cause": "Configuration or state inconsistency affecting !cfusa_config_is_rule_disabled", + "severity": 5, + "occurrence": 3, + "detection": 4, + "actionPriority": "medium", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-341", + "item": "strcmp", + "file": "utils.c", + "line": 46, + "failureMode": "strcmp (general function) does not perform its intended action", + "effect": "Failure of strcmp could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in strcmp", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-342", + "item": "cfusa_read_file", + "file": "utils.c", + "line": 60, + "failureMode": "cfusa_read_file (general function) does not perform its intended action", + "effect": "Failure of cfusa_read_file could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_read_file", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-343", + "item": "cfusa_fopen_write", + "file": "utils.c", + "line": 78, + "failureMode": "cfusa_fopen_write (general function) does not perform its intended action", + "effect": "Failure of cfusa_fopen_write could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_fopen_write", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-344", + "item": "cfusa_file_exists", + "file": "utils.c", + "line": 87, + "failureMode": "cfusa_file_exists (general function) does not perform its intended action", + "effect": "Failure of cfusa_file_exists could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_file_exists", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-345", + "item": "cfusa_dir_exists", + "file": "utils.c", + "line": 93, + "failureMode": "cfusa_dir_exists (general function) does not perform its intended action", + "effect": "Failure of cfusa_dir_exists could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_dir_exists", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-346", + "item": "cfusa_mkdir_p", + "file": "utils.c", + "line": 99, + "failureMode": "cfusa_mkdir_p (general function) does not perform its intended action", + "effect": "Failure of cfusa_mkdir_p could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_mkdir_p", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-347", + "item": "cfusa_scan_lines", + "file": "utils.c", + "line": 115, + "failureMode": "cfusa_scan_lines (general function) does not perform its intended action", + "effect": "Failure of cfusa_scan_lines could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_scan_lines", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-348", + "item": "cfusa_basename", + "file": "utils.c", + "line": 134, + "failureMode": "cfusa_basename (general function) does not perform its intended action", + "effect": "Failure of cfusa_basename could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_basename", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-349", + "item": "cfusa_extension", + "file": "utils.c", + "line": 140, + "failureMode": "cfusa_extension (general function) does not perform its intended action", + "effect": "Failure of cfusa_extension could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_extension", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-350", + "item": "cfusa_str_contains", + "file": "utils.c", + "line": 147, + "failureMode": "cfusa_str_contains (general function) does not perform its intended action", + "effect": "Failure of cfusa_str_contains could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_str_contains", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-351", + "item": "cfusa_str_starts_with", + "file": "utils.c", + "line": 152, + "failureMode": "cfusa_str_starts_with (general function) does not perform its intended action", + "effect": "Failure of cfusa_str_starts_with could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_str_starts_with", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-352", + "item": "cfusa_str_trim", + "file": "utils.c", + "line": 157, + "failureMode": "cfusa_str_trim (general function) does not perform its intended action", + "effect": "Failure of cfusa_str_trim could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_str_trim", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-353", + "item": "cfusa_str_escape_json", + "file": "utils.c", + "line": 168, + "failureMode": "cfusa_str_escape_json (general function) does not perform its intended action", + "effect": "Failure of cfusa_str_escape_json could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_str_escape_json", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-354", + "item": "cfusa_path_join", + "file": "utils.c", + "line": 188, + "failureMode": "cfusa_path_join (general function) does not perform its intended action", + "effect": "Failure of cfusa_path_join could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_path_join", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-355", + "item": "cfusa_sha256_buf", + "file": "utils.c", + "line": 311, + "failureMode": "cfusa_sha256_buf (general function) does not perform its intended action", + "effect": "Failure of cfusa_sha256_buf could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_sha256_buf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-356", + "item": "cfusa_sha256_file", + "file": "utils.c", + "line": 323, + "failureMode": "cfusa_sha256_file (general function) does not perform its intended action", + "effect": "Failure of cfusa_sha256_file could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_sha256_file", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-357", + "item": "cfusa_sha256_buf", + "file": "utils.c", + "line": 352, + "failureMode": "cfusa_sha256_buf (general function) does not perform its intended action", + "effect": "Failure of cfusa_sha256_buf could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_sha256_buf", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-358", + "item": "cfusa_timestamp_now", + "file": "utils.c", + "line": 383, + "failureMode": "cfusa_timestamp_now (general function) does not perform its intended action", + "effect": "Failure of cfusa_timestamp_now could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_timestamp_now", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-359", + "item": "cfusa_count_c_files", + "file": "utils.c", + "line": 400, + "failureMode": "cfusa_count_c_files (general function) does not perform its intended action", + "effect": "Failure of cfusa_count_c_files could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_count_c_files", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-360", + "item": "cfusa_count_lines_in_file", + "file": "utils.c", + "line": 408, + "failureMode": "cfusa_count_lines_in_file (general function) does not perform its intended action", + "effect": "Failure of cfusa_count_lines_in_file could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_count_lines_in_file", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-361", + "item": "cfusa_match_outside_string", + "file": "utils.c", + "line": 421, + "failureMode": "cfusa_match_outside_string (general function) does not perform its intended action", + "effect": "Failure of cfusa_match_outside_string could propagate undetected to callers in utils.c", + "cause": "Logic error or untested edge case in cfusa_match_outside_string", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-362", + "item": "cfusa_config_defaults", + "file": "config.c", + "line": 8, + "failureMode": "cfusa_config_defaults (safety-critical function) does not perform its intended action", + "effect": "Failure of cfusa_config_defaults could propagate undetected to callers in config.c", + "cause": "Unhandled fault or invalid input condition within cfusa_config_defaults", + "severity": 9, + "occurrence": 4, + "detection": 6, + "actionPriority": "high", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-363", + "item": "cfusa_config_load", + "file": "config.c", + "line": 92, + "failureMode": "cfusa_config_load (monitoring/control function) does not perform its intended action", + "effect": "Failure of cfusa_config_load could propagate undetected to callers in config.c", + "cause": "Configuration or state inconsistency affecting cfusa_config_load", + "severity": 5, + "occurrence": 3, + "detection": 4, + "actionPriority": "medium", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-364", + "item": "extract_str_array_n", + "file": "config.c", + "line": 150, + "failureMode": "extract_str_array_n (general function) does not perform its intended action", + "effect": "Failure of extract_str_array_n could propagate undetected to callers in config.c", + "cause": "Logic error or untested edge case in extract_str_array_n", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-365", + "item": "extract_str_array_n", + "file": "config.c", + "line": 160, + "failureMode": "extract_str_array_n (general function) does not perform its intended action", + "effect": "Failure of extract_str_array_n could propagate undetected to callers in config.c", + "cause": "Logic error or untested edge case in extract_str_array_n", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-366", + "item": "extract_str_array_n", + "file": "config.c", + "line": 170, + "failureMode": "extract_str_array_n (general function) does not perform its intended action", + "effect": "Failure of extract_str_array_n could propagate undetected to callers in config.c", + "cause": "Logic error or untested edge case in extract_str_array_n", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-367", + "item": "extract_str_array_n", + "file": "config.c", + "line": 177, + "failureMode": "extract_str_array_n (general function) does not perform its intended action", + "effect": "Failure of extract_str_array_n could propagate undetected to callers in config.c", + "cause": "Logic error or untested edge case in extract_str_array_n", + "severity": 3, + "occurrence": 2, + "detection": 3, + "actionPriority": "low", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-368", + "item": "cfusa_config_is_rule_disabled", + "file": "config.c", + "line": 186, + "failureMode": "cfusa_config_is_rule_disabled (monitoring/control function) does not perform its intended action", + "effect": "Failure of cfusa_config_is_rule_disabled could propagate undetected to callers in config.c", + "cause": "Configuration or state inconsistency affecting cfusa_config_is_rule_disabled", + "severity": 5, + "occurrence": 3, + "detection": 4, + "actionPriority": "medium", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-369", + "item": "cfusa_config_save", + "file": "config.c", + "line": 193, + "failureMode": "cfusa_config_save (monitoring/control function) does not perform its intended action", + "effect": "Failure of cfusa_config_save could propagate undetected to callers in config.c", + "cause": "Configuration or state inconsistency affecting cfusa_config_save", + "severity": 5, + "occurrence": 3, + "detection": 4, + "actionPriority": "medium", + "mitigations": [], + "requirementIds": [] + }, + { + "id": "FM-370", + "item": "cfusa_config_is_excluded", "file": "config.c", - "line": 153, - "failure_mode": "", - "effect": "", - "cause": "", - "severity": "Medium", - "occurrence": 1, - "detection": 1, - "rpn": 5 + "line": 225, + "failureMode": "cfusa_config_is_excluded (monitoring/control function) does not perform its intended action", + "effect": "Failure of cfusa_config_is_excluded could propagate undetected to callers in config.c", + "cause": "Configuration or state inconsistency affecting cfusa_config_is_excluded", + "severity": 5, + "occurrence": 3, + "detection": 4, + "actionPriority": "medium", + "mitigations": [], + "requirementIds": [] } - ] + ], + "summary": { + "total": 370, "highPriority": 11, + "componentsAnalyzed": 370, "componentsInProject": 370, "coveragePct": 100 + } } diff --git a/include/cfusa/qualitybar.h b/include/cfusa/qualitybar.h new file mode 100644 index 0000000..2148cde --- /dev/null +++ b/include/cfusa/qualitybar.h @@ -0,0 +1,84 @@ +#ifndef CFUSA_QUALITYBAR_H +#define CFUSA_QUALITYBAR_H + +/* + * cfusa "quality bar" — the x-FuSa spec §1.6/§1.6.1/§1.6.2 evidence-artifact + * content-quality baseline, shared by hara/fmea/tara/safety-case/sas. + * + * Two concrete, checkable rules over a generated evidence artifact's + * qualitative (free-text) fields: + * + * Rule A / FUSA-STUB001 (always ERROR, disposition-suppressible only) — + * literal placeholder/template text: cfusa_qb_is_stub_text(). + * + * Rule B / FUSA-STUB002 (WARNING by default, not gating unless + * --strict/--require-attestation) — a single hardcoded qualitative string + * applied to every entry: cfusa_qb_rule_b_flagged(). + * + * Plus the §1.6.2 attestation mechanism that suppresses a Rule B finding + * once a named, independent human asserts they reviewed the content. + */ + +#include + +#define CFUSA_QB_RULE_A "FUSA-STUB001" +#define CFUSA_QB_RULE_B "FUSA-STUB002" + +/* Rule A (MUST, x-FuSa spec §1.6.1) — deny-list scan for literal + * placeholder/instructional text: bracket-wrapped instructional text + * (e.g. "[describe asset]") or the case-insensitive substrings + * "replace with", "example hazard", "tbd", "lorem ipsum", "fill in". + * Returns 1 when `text` matches, 0 otherwise. */ +int cfusa_qb_is_stub_text(const char *text); + +/* Rule B (SHOULD, x-FuSa spec §1.6.1) — distinct-value-ratio check. + * `values` is an array of `n` qualitative-field strings (one per entry). + * Returns 1 (flagged) when n >= 10 and (distinct count / n) < 0.1. */ +int cfusa_qb_rule_b_flagged(const char * const *values, int n); + +/* An artifact-level attestation object (x-FuSa spec §1.6.2). */ +typedef struct { + int present; /* 1 if an attestation object was found at all */ + char status[16]; /* "heuristic" | "reviewed" */ + char implementation_author[128]; + char independent_reviewer[128]; + char reviewed_at[40]; + char content_hash[80]; /* "sha256:" + 64 lowercase hex */ +} cfusa_attestation_t; + +/* Extracts a top-level "attestation": {...} object out of a previously + * generated artifact's raw JSON text (`json`, `len` bytes), if present. + * Returns 1 when an attestation object was found (even if some fields are + * missing — caller/cfusa_qb_attestation_valid() re-validates), 0 otherwise. */ +int cfusa_qb_attestation_read(const char *json, size_t len, cfusa_attestation_t *out); + +/* Validates independence + non-staleness (x-FuSa spec §1.6.2, MUST when + * status: "reviewed"): independent_reviewer must differ from + * implementation_author, and content_hash must match `fresh_hash` (the + * artifact's current substantive-content hash — see cfusa_qb_content_hash()). + * Returns 1 only for a genuinely independent, non-stale "reviewed" + * attestation — i.e. exactly the condition that MUST suppress a Rule B + * finding. Fail-safe: anything absent/malformed/self-attested/stale + * returns 0 (treated as "heuristic"), never 1. */ +int cfusa_qb_attestation_valid(const cfusa_attestation_t *att, const char *fresh_hash); + +/* Rule-level disposition lookup — this repo's existing + * .fusa-dispositions.json convention keys a disposition by ruleId (see + * `cfusa disposition`), not by per-finding fingerprint. Returns 1 when at + * least one disposition entry exists for `rule_id` under `dir`. Rule A is + * suppressible only this way (never via attestation); Rule B is not + * suppressible this way (only via a valid attestation), per §1.6.1. */ +int cfusa_qb_rule_disposed(const char *dir, const char *rule_id); + +/* Computes "sha256:" over a caller-assembled canonical JSON fragment + * (RFC 8785-style: object members in ASCII-lexicographic key order, no + * insignificant whitespace, over the artifact's substantive content only — + * entries/hazards/threats/nodes/checklist/artifacts, excluding the + * `attestation` object itself and `generatedAt`, per x-FuSa spec §1.6.2). + * Because each artifact command constructs (rather than parses) its own + * value tree, emitting members in sorted order while building the fragment + * is sufficient to match a genuine RFC 8785 canonicalizer over the same + * abstract value — no generic JSON parser is required. */ +void cfusa_qb_content_hash(const char *canonical_json, size_t len, char hash_out[80]); + +#endif /* CFUSA_QUALITYBAR_H */ diff --git a/include/cfusa/utils.h b/include/cfusa/utils.h index 6d56e88..15e97f1 100644 --- a/include/cfusa/utils.h +++ b/include/cfusa/utils.h @@ -16,6 +16,12 @@ int cfusa_file_exists(const char *path); int cfusa_dir_exists(const char *path); int cfusa_mkdir_p(const char *path); +/* Opens `path` for writing (truncating) with explicit 0600 permissions — + * unlike fopen(path, "w"), whose actual mode depends on the process umask + * and so may create a world-writable file. Returns NULL (errno set) on + * failure, exactly like fopen(). */ +FILE *cfusa_fopen_write(const char *path); + /* ---- line scanning ---- */ typedef void (*cfusa_line_cb)(const char *path, int lineno, const char *line, void *ctx); diff --git a/include/cfusa/version.h b/include/cfusa/version.h index cfeb18c..18793e0 100644 --- a/include/cfusa/version.h +++ b/include/cfusa/version.h @@ -3,14 +3,16 @@ #define CFUSA_VERSION_MAJOR 0 #define CFUSA_VERSION_MINOR 5 -#define CFUSA_VERSION_PATCH 45 -#define CFUSA_VERSION_STRING "0.5.45" -#define CFUSA_SCHEMA_VERSION "1.11.0" -/* Bumped from 1.10.12 to match the x-FuSa master spec's additive §1.4.1 - * "requirement annotation completeness" MINOR bump (issue #62 item 3). The - * new items are SHOULD-level, and c-FuSa v0.5.41 already implements the - * corresponding --func-coverage gate and dangling-ID detection, so tracking - * the spec version here is accurate rather than aspirational. */ -#define CFUSA_SPEC_VERSION "1.11.0" +#define CFUSA_VERSION_PATCH 46 +#define CFUSA_VERSION_STRING "0.5.46" +#define CFUSA_SCHEMA_VERSION "1.14.0" +/* Bumped from 1.11.0 to 1.14.0: adopts the x-FuSa master spec's §1.2.5/§9.2/ + * §9.3 evidence-artifact schema formalization (hara/fmea/tara/safety-case/ + * sas/sci field-level shapes — SFOP TARA impact, GSN safety-case node + * types, HARA's three cross-referenced collections with MUST fssrRefs) and + * the §1.6/§1.6.1/§1.6.2 content-quality baseline (FUSA-STUB001/002 + * detection, attestation, summary.coveragePct/--min-coverage on fmea/tara). + * See issue #71. */ +#define CFUSA_SPEC_VERSION "1.14.0" #endif /* CFUSA_VERSION_H */ diff --git a/safety-case.json b/safety-case.json new file mode 100644 index 0000000..7164044 --- /dev/null +++ b/safety-case.json @@ -0,0 +1,36 @@ +{ + "schemaVersion": "1.14.0", + "kind": "safety-case", + "tool": "c-FuSa", + "toolVersion": "0.5.46", + "language": "c", + "generatedAt": "2026-07-28T19:47:39Z", + "project": "c-FuSa", + "standard": "iso26262", + "nodes": [ + {"id": "G1", "type": "goal", "text": "c-FuSa v0.5.1 has no unmitigated hazard from .fusa-hara.json and no unresolved ERROR finding from `cfusa check` at the iso26262 analysis boundary"}, + {"id": "St1", "type": "strategy", "text": "Argue over hazard elimination and process confidence separately"}, + {"id": "C1", "type": "context", "text": "Scope: c-FuSa source under \".\", analyzed against iso26262 by c-FuSa v0.5.46"}, + {"id": "A1", "type": "assumption", "text": "The underlying hardware/platform on which c-FuSa runs meets its own safety requirements independently of this software safety case"}, + {"id": "G1.1", "type": "goal", "text": "Every hazard recorded in .fusa-hara.json is eliminated or controlled to its assigned ASIL (ISO 26262-3 Clause 6)"}, + {"id": "G1.2", "type": "goal", "text": "The c-FuSa development process gives justified confidence: static analysis, FMEA/TARA, and tool qualification evidence are current"}, + {"id": "Sn2", "type": "solution", "text": "Static analysis / lint / cyber self-check results", "evidence": "cfusa-self-check.json"}, + {"id": "Sn3", "type": "solution", "text": "Design FMEA", "evidence": "fmea.json"}, + {"id": "Sn4", "type": "solution", "text": "Threat analysis and risk assessment", "evidence": "tara.json"}, + {"id": "Sn5", "type": "solution", "text": "Tool qualification record", "evidence": "qualify-report.json"} + ], + "edges": [ + {"from": "G1", "to": "St1", "type": "supportedBy"}, + {"from": "G1", "to": "C1", "type": "inContextOf"}, + {"from": "St1", "to": "A1", "type": "inContextOf"}, + {"from": "St1", "to": "G1.1", "type": "supportedBy"}, + {"from": "St1", "to": "G1.2", "type": "supportedBy"}, + {"from": "G1.2", "to": "Sn2", "type": "supportedBy"}, + {"from": "G1.2", "to": "Sn3", "type": "supportedBy"}, + {"from": "G1.2", "to": "Sn4", "type": "supportedBy"}, + {"from": "G1.2", "to": "Sn5", "type": "supportedBy"} + ], + "completeness": { + "totalGoals": 3, "goalsWithEvidence": 1, "undeveloped": 1 + } +} diff --git a/safety-case.md b/safety-case.md index e77e19d..8e6f411 100644 --- a/safety-case.md +++ b/safety-case.md @@ -1,52 +1,85 @@ -# c-FuSa Safety Case +# Safety Case — c-FuSa v0.5.1 -**Project:** c-FuSa v0.5.45 -**Standard:** ISO 26262-8:2018 §11 (Tool Classification and Qualification) -**Tool Classification:** TCL-3 (software tool affecting development output) -**Generated:** 2026-06-11 +**Standard:** iso26262 | **Generated:** 2026-07-28T19:47:39Z --- -## 1. Tool Purpose - -c-FuSa (`cfusa`) is a command-line functional safety toolkit for C projects. It enforces coding standards (MISRA-C, CERT-C), computes traceability coverage, generates compliance gap reports for ISO 26262, IEC 61508, ISO 21434, IEC 62443, and DO-178C, and validates HARA documents. - -## 2. Safety Claims - -| ID | Claim | -|----|-------| -| SC-01 | c-FuSa correctly detects function length violations (L001) per the configured `max_function_lines` parameter | -| SC-02 | c-FuSa correctly detects goto statements (L002) per MISRA-C Rule 15.1 | -| SC-03 | c-FuSa correctly detects dynamic memory allocation (L003) per MISRA-C Rule 21.3 | -| SC-04 | c-FuSa HARA commands correctly validate S/E/C risk ratings per ISO 26262-3 Table 4 | -| SC-05 | c-FuSa trace matrix reports accurate requirement coverage statistics | -| SC-06 | c-FuSa qualify command verifies tool binary SHA-256 integrity | -| SC-07 | c-FuSa cyclomatic complexity rule (COMP001) uses V(G) = 1 + decision nodes | -| SC-08 | c-FuSa runtime library components operate correctly under unit test coverage | - -## 3. Evidence - -| Claim | Evidence | Location | -|-------|----------|----------| -| SC-01–SC-08 | Unit test suite (30 test suites, 100% pass) | `tests/` | -| SC-04 | ASIL table unit tests | `tests/test_asil_table.c` | -| SC-05 | Trace coverage tests | `tests/test_trace_req.c` | -| SC-06 | Qualify command tests | `tests/test_safety_commands.c` | -| SC-07 | Complexity rule tests | `tests/test_safety_rules.c` | -| SC-08 | Runtime library tests | `tests/test_runtime.c` | -| All | Tool qualification record | `.cfusa_qualification.json` | - -## 4. Tool Qualification Summary - -c-FuSa self-qualifies using `cfusa qualify`: -- Tests: 30 suites, all passing -- Binary integrity: SHA-256 verified -- Self-check: c-FuSa runs on its own source code - -## 5. Limitations and Assumptions - -1. c-FuSa performs static text analysis. It does not perform semantic analysis or type inference. -2. MISRA-C rule coverage is partial — see `cfusa misra` for gap report. -3. HARA S/E/C validation requires well-formed `.fusa-hara.json` input. -4. Coupling analysis operates on syntactic patterns; full coupling analysis requires a dedicated tool. -5. This tool must be re-qualified after any changes to rule implementations. +## G1 — goal + +> c-FuSa v0.5.1 has no unmitigated hazard from .fusa-hara.json and no unresolved ERROR finding from `cfusa check` at the iso26262 analysis boundary + +## St1 — strategy + +> Argue over hazard elimination and process confidence separately + +## C1 — context + +> Scope: c-FuSa source under ".", analyzed against iso26262 by c-FuSa v0.5.46 + +## A1 — assumption + +> The underlying hardware/platform on which c-FuSa runs meets its own safety requirements independently of this software safety case + +## G1.1 — goal + +> Every hazard recorded in .fusa-hara.json is eliminated or controlled to its assigned ASIL (ISO 26262-3 Clause 6) + +## G1.2 — goal + +> The c-FuSa development process gives justified confidence: static analysis, FMEA/TARA, and tool qualification evidence are current + +## Sn2 — solution + +> Static analysis / lint / cyber self-check results + +Evidence: `cfusa-self-check.json` + +## Sn3 — solution + +> Design FMEA + +Evidence: `fmea.json` + +## Sn4 — solution + +> Threat analysis and risk assessment + +Evidence: `tara.json` + +## Sn5 — solution + +> Tool qualification record + +Evidence: `qualify-report.json` + +--- + +## Argument Structure + +| From | To | Relation | +|---|---|---| +| G1 | St1 | supportedBy | +| G1 | C1 | inContextOf | +| St1 | A1 | inContextOf | +| St1 | G1.1 | supportedBy | +| St1 | G1.2 | supportedBy | +| G1.2 | Sn2 | supportedBy | +| G1.2 | Sn3 | supportedBy | +| G1.2 | Sn4 | supportedBy | +| G1.2 | Sn5 | supportedBy | + +_Completeness: 3 goal(s), 1 with cited evidence, 1 undeveloped._ + +--- + +## Evidence Index + +| File | Present | SHA-256 | +|---|---|---| +| hara.md | absent | — | +| safety-plan.md | absent | — | +| tara.md | present | `dcfdbf0fe1239b5a9f1263b1e328d5d7f7938678f74d937ff382dfb1c846517a` | +| fmea.md | absent | — | +| test-evidence.md | absent | — | +| sas.md | absent | — | +| .fusa.json | present | `740787473985c81748b3962e330731f02ef1359f02bbb5e61a8e402b7c0e9595` | diff --git a/src/qualitybar.c b/src/qualitybar.c new file mode 100644 index 0000000..b9bf696 --- /dev/null +++ b/src/qualitybar.c @@ -0,0 +1,211 @@ +/* + * cfusa "quality bar" — x-FuSa spec §1.6/§1.6.1/§1.6.2 implementation. + * See include/cfusa/qualitybar.h for the contract. + */ +#include "cfusa/qualitybar.h" +#include "cfusa/utils.h" + +#include +#include +#include +#include + +/* ---- Rule A: placeholder-text deny-list (x-FuSa spec §1.6.1 rule A) ---- */ + +static int qb_ci_contains(const char *hay, const char *needle) +{ + size_t hn = strlen(hay), nn = strlen(needle); + if (nn == 0 || nn > hn) return 0; + for (size_t i = 0; i + nn <= hn; i++) { + size_t j = 0; + for (; j < nn; j++) + if (tolower((unsigned char)hay[i + j]) != tolower((unsigned char)needle[j])) + break; + if (j == nn) return 1; + } + return 0; +} + +/* Bracket-wrapped instructional text: \[[A-Za-z][^\]]*\] */ +static int qb_has_bracket_placeholder(const char *s) +{ + const char *p = s; + while ((p = strchr(p, '[')) != NULL) { + const char *q = p + 1; + if (*q && isalpha((unsigned char)*q)) { + const char *close = strchr(q, ']'); + if (close && close > q) return 1; + } + p++; + } + return 0; +} + +int cfusa_qb_is_stub_text(const char *text) +{ + if (!text || !*text) return 0; + + static const char * const deny[] = { + "replace with", "example hazard", "tbd", "lorem ipsum", "fill in", NULL + }; + for (int i = 0; deny[i]; i++) + if (qb_ci_contains(text, deny[i])) return 1; + + return qb_has_bracket_placeholder(text); +} + +/* ---- Rule B: distinct-value-ratio (x-FuSa spec §1.6.1 rule B) ---- */ + +int cfusa_qb_rule_b_flagged(const char * const *values, int n) +{ + if (n < 10) return 0; + + /* O(n^2) distinct count. These artifacts run at most a few hundred + * entries per project, so a hash set is not needed for correctness or + * for practical runtime. */ + int distinct = 0; + for (int i = 0; i < n; i++) { + int dup = 0; + for (int j = 0; j < i; j++) { + if (strcmp(values[i], values[j]) == 0) { dup = 1; break; } + } + if (!dup) distinct++; + } + double ratio = (double)distinct / (double)n; + return ratio < 0.1; +} + +/* ---- Attestation (x-FuSa spec §1.6.2) ---- */ + +static void qb_extract_string_field(const char *block, const char *key, + char *out, size_t out_sz) +{ + out[0] = '\0'; + char pat[64]; + snprintf(pat, sizeof(pat), "\"%s\":", key); + const char *fp = strstr(block, pat); + if (!fp) return; + fp += strlen(pat); + while (*fp == ' ' || *fp == '\t' || *fp == '\n') fp++; + if (*fp != '"') return; + fp++; + size_t k = 0; + while (*fp && *fp != '"' && k < out_sz - 1) { + if (*fp == '\\' && fp[1]) fp++; + out[k++] = *fp++; + } + out[k] = '\0'; +} + +int cfusa_qb_attestation_read(const char *json, size_t len, cfusa_attestation_t *out) +{ + memset(out, 0, sizeof(*out)); + if (!json || len == 0) return 0; + + const char *key = strstr(json, "\"attestation\""); + if (!key) return 0; + const char *brace = strchr(key, '{'); + if (!brace) return 0; + + /* Find the matching close brace, tracking string state so a literal + * '{'/'}' inside a quoted value doesn't miscount depth. */ + int depth = 0; + int in_str = 0; + const char *p = brace; + const char *end = NULL; + const char *doc_end = json + len; + for (; p < doc_end && *p; p++) { + if (in_str) { + if (*p == '\\') { p++; continue; } + if (*p == '"') in_str = 0; + continue; + } + if (*p == '"') { in_str = 1; continue; } + if (*p == '{') depth++; + else if (*p == '}') { depth--; if (depth == 0) { end = p; break; } } + } + if (!end) return 0; + + size_t blocklen = (size_t)(end - brace) + 1; + char *block = malloc(blocklen + 1); + if (!block) return 0; + memcpy(block, brace, blocklen); + block[blocklen] = '\0'; + + qb_extract_string_field(block, "status", out->status, sizeof(out->status)); + qb_extract_string_field(block, "implementationAuthor", + out->implementation_author, sizeof(out->implementation_author)); + qb_extract_string_field(block, "independentReviewer", + out->independent_reviewer, sizeof(out->independent_reviewer)); + qb_extract_string_field(block, "reviewedAt", out->reviewed_at, sizeof(out->reviewed_at)); + qb_extract_string_field(block, "contentHash", out->content_hash, sizeof(out->content_hash)); + + free(block); + out->present = 1; + return 1; +} + +static int qb_str_ieq_trim(const char *a, const char *b) +{ + while (isspace((unsigned char)*a)) a++; + while (isspace((unsigned char)*b)) b++; + size_t la = strlen(a), lb = strlen(b); + while (la && isspace((unsigned char)a[la - 1])) la--; + while (lb && isspace((unsigned char)b[lb - 1])) lb--; + if (la != lb) return 0; + for (size_t i = 0; i < la; i++) + if (tolower((unsigned char)a[i]) != tolower((unsigned char)b[i])) return 0; + return 1; +} + +int cfusa_qb_attestation_valid(const cfusa_attestation_t *att, const char *fresh_hash) +{ + if (!att || !att->present) return 0; /* absent -> heuristic (fail-safe) */ + if (strcmp(att->status, "reviewed") != 0) return 0; /* anything else -> heuristic */ + if (!att->independent_reviewer[0]) return 0; /* MUST when status: reviewed */ + /* Same-identity self-attestation MUST downgrade to heuristic. An empty + * implementationAuthor is not treated as "same identity" — it simply + * means the producer didn't record one (e.g. a heuristic generator that + * omitted it), which is a documentation gap, not a security bypass — + * but is nonetheless untrustworthy without an author to differ from. */ + if (!att->implementation_author[0]) return 0; + if (qb_str_ieq_trim(att->independent_reviewer, att->implementation_author)) return 0; + if (!att->content_hash[0] || !fresh_hash || !fresh_hash[0]) return 0; + if (strcmp(att->content_hash, fresh_hash) != 0) return 0; /* stale -> heuristic */ + return 1; +} + +/* ---- Rule-level disposition lookup ---- */ + +int cfusa_qb_rule_disposed(const char *dir, const char *rule_id) +{ + char path[512]; + cfusa_path_join(path, sizeof(path), dir, ".fusa-dispositions.json"); + size_t len = 0; + char *content = cfusa_read_file(path, &len); + if (!content) { + cfusa_path_join(path, sizeof(path), dir, ".cfusa-dispositions.json"); + content = cfusa_read_file(path, &len); + } + if (!content) return 0; + + int disposed = 0; + char *p = content; + while ((p = strstr(p, "\"rule\":")) != NULL) { + char rule[32] = ""; + sscanf(p, "\"rule\":\"%31[^\"]", rule); + if (strcmp(rule, rule_id) == 0) { disposed = 1; break; } + p += 7; + } + free(content); + return disposed; +} + +/* ---- Canonical content hash ---- */ + +void cfusa_qb_content_hash(const char *canonical_json, size_t len, char hash_out[80]) +{ + char hex[65]; + cfusa_sha256_buf((const unsigned char *)canonical_json, len, hex); + snprintf(hash_out, 80, "sha256:%s", hex); +} diff --git a/src/utils.c b/src/utils.c index a736c12..5150f25 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,3 +1,11 @@ +/* open()/fdopen() are POSIX; required on Linux with -std=c99 (same fix as + * cmd_capabilities.c/cmd_qualify.c/cmd_impact.c/cmd_release.c/ + * cmd_audit_pack.c) — without it, strict ISO C99 glibc headers hide + * fdopen()'s prototype, gcc implicitly declares it returning `int`, and the + * truncated 32-bit "pointer" assigned to a FILE* segfaults on first use. */ +#if defined(__linux__) || defined(__unix__) +# define _POSIX_C_SOURCE 200809L +#endif #include #include #include @@ -6,6 +14,8 @@ #include #include #include +#include +#include #include "cfusa/utils.h" /* ---- file walker ---- */ @@ -73,6 +83,15 @@ char *cfusa_read_file(const char *path, size_t *len_out) return buf; } +FILE *cfusa_fopen_write(const char *path) +{ + int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600); + if (fd < 0) return NULL; + FILE *f = fdopen(fd, "w"); + if (!f) { close(fd); return NULL; } + return f; +} + int cfusa_file_exists(const char *path) { struct stat st; diff --git a/tara.json b/tara.json index 9c0ad9e..fb79a4f 100644 --- a/tara.json +++ b/tara.json @@ -1,24 +1,173 @@ { - "tool": "cfusa tara", + "schemaVersion": "1.14.0", + "kind": "tara-report", + "tool": "c-FuSa", + "toolVersion": "0.5.46", + "language": "c", + "generatedAt": "2026-07-28T19:47:38Z", "project": "c-FuSa", - "version": "0.1.0", - "generated": "2026-06-09T18:38:06Z", - "standard": "ISO 21434:2021 Clause 9", - "assets": [ - {"id":"ASSET-001","description":"[describe asset]","property":"CIA"} - ], + "version": "0.5.1", + "standard": "ISO/SAE 21434:2021 Clause 15", "threats": [ { - "id": "TS-001", - "asset": "ASSET-001", - "threat": "[describe threat]", - "attack_vector": "[local/remote/physical]", - "impact": "[none/low/med/high/severe]", - "feasibility": "[1-4]", - "risk_level": "[LOW/MEDIUM/HIGH/CRITICAL]", - "treatment": "[avoid/reduce/share/accept]", - "cybersecurity_goal": "[goal]", - "requirement_ref": "[SRS-xxx]" + "id": "TARA-001", + "asset": "Data handled by \"strcpy (cmd_qualify.c)", + "threat": "An attacker supplies malformed/untrusted input to \"strcpy, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "high", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "high", + "treatment": "mitigate", + "mitigations": ["Use bounds-checked copy/allocation APIs", "Add static analysis (cfusa analyze/lint) to the CI gate for this file"], + "location": {"file": "cmd_qualify.c", "line": 427} + }, + { + "id": "TARA-002", + "asset": "Data handled by import_reqif (cmd_req.c)", + "threat": "An attacker supplies malformed/untrusted input to import_reqif, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "low", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "medium", + "treatment": "mitigate", + "mitigations": ["Validate file contents against an expected schema before use", "Reject unexpected file sizes/paths"], + "location": {"file": "cmd_req.c", "line": 646} + }, + { + "id": "TARA-003", + "asset": "Data handled by import_polarion_xml (cmd_req.c)", + "threat": "An attacker supplies malformed/untrusted input to import_polarion_xml, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "low", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "medium", + "treatment": "mitigate", + "mitigations": ["Validate file contents against an expected schema before use", "Reject unexpected file sizes/paths"], + "location": {"file": "cmd_req.c", "line": 652} + }, + { + "id": "TARA-004", + "asset": "Data handled by import_reqif (cmd_req.c)", + "threat": "An attacker supplies malformed/untrusted input to import_reqif, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "low", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "medium", + "treatment": "mitigate", + "mitigations": ["Validate file contents against an expected schema before use", "Reject unexpected file sizes/paths"], + "location": {"file": "cmd_req.c", "line": 655} + }, + { + "id": "TARA-005", + "asset": "Data handled by import_codebeamer_xml (cmd_req.c)", + "threat": "An attacker supplies malformed/untrusted input to import_codebeamer_xml, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "low", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "medium", + "treatment": "mitigate", + "mitigations": ["Validate file contents against an expected schema before use", "Reject unexpected file sizes/paths"], + "location": {"file": "cmd_req.c", "line": 660} + }, + { + "id": "TARA-006", + "asset": "Data handled by import_jama_xml (cmd_req.c)", + "threat": "An attacker supplies malformed/untrusted input to import_jama_xml, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "low", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "medium", + "treatment": "mitigate", + "mitigations": ["Validate file contents against an expected schema before use", "Reject unexpected file sizes/paths"], + "location": {"file": "cmd_req.c", "line": 671} + }, + { + "id": "TARA-007", + "asset": "Data handled by malloc (cmd_fix.c)", + "threat": "An attacker supplies malformed/untrusted input to malloc, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "high", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "high", + "treatment": "mitigate", + "mitigations": ["Use bounds-checked copy/allocation APIs", "Add static analysis (cfusa analyze/lint) to the CI gate for this file"], + "location": {"file": "cmd_fix.c", "line": 63} + }, + { + "id": "TARA-008", + "asset": "Data handled by malloc (cmd_fix.c)", + "threat": "An attacker supplies malformed/untrusted input to malloc, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "high", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "high", + "treatment": "mitigate", + "mitigations": ["Use bounds-checked copy/allocation APIs", "Add static analysis (cfusa analyze/lint) to the CI gate for this file"], + "location": {"file": "cmd_fix.c", "line": 99} + }, + { + "id": "TARA-009", + "asset": "Data handled by \"strcpy (cmd_vuln.c)", + "threat": "An attacker supplies malformed/untrusted input to \"strcpy, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "high", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "high", + "treatment": "mitigate", + "mitigations": ["Use bounds-checked copy/allocation APIs", "Add static analysis (cfusa analyze/lint) to the CI gate for this file"], + "location": {"file": "cmd_vuln.c", "line": 32} + }, + { + "id": "TARA-010", + "asset": "Data handled by parse_sec_code (cmd_hara.c)", + "threat": "An attacker supplies malformed/untrusted input to parse_sec_code, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "low", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "medium", + "treatment": "mitigate", + "mitigations": ["Validate file contents against an expected schema before use", "Reject unexpected file sizes/paths"], + "location": {"file": "cmd_hara.c", "line": 650} + }, + { + "id": "TARA-011", + "asset": "Data handled by cfusa_format_parse (report.c)", + "threat": "An attacker supplies malformed/untrusted input to cfusa_format_parse, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "low", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "medium", + "treatment": "mitigate", + "mitigations": ["Validate file contents against an expected schema before use", "Reject unexpected file sizes/paths"], + "location": {"file": "report.c", "line": 137} + }, + { + "id": "TARA-012", + "asset": "Data handled by cfusa_fopen_write (utils.c)", + "threat": "An attacker supplies malformed/untrusted input to cfusa_fopen_write, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "low", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "medium", + "treatment": "mitigate", + "mitigations": ["Validate file contents against an expected schema before use", "Reject unexpected file sizes/paths"], + "location": {"file": "utils.c", "line": 78} + }, + { + "id": "TARA-013", + "asset": "Data handled by cfusa_config_load (config.c)", + "threat": "An attacker supplies malformed/untrusted input to cfusa_config_load, potentially causing incorrect behaviour, a crash, or information disclosure", + "attackVector": "local", + "attackFeasibility": "medium", + "impact": {"safety": "low", "financial": "low", "operational": "medium", "privacy": "low"}, + "risk": "medium", + "treatment": "mitigate", + "mitigations": ["Validate file contents against an expected schema before use", "Reject unexpected file sizes/paths"], + "location": {"file": "config.c", "line": 92} } - ] + ], + "summary": { + "assetsAnalyzed": 13, "assetsInProject": 13, "coveragePct": 100, + "assetInventoryMethod": "Keyword-based scan of public C function names against a network/file/auth/memory-input vocabulary; not a formal asset inventory." + } } diff --git a/tara.md b/tara.md index 4b8a918..cea9f60 100644 --- a/tara.md +++ b/tara.md @@ -1,50 +1,26 @@ -# c-FuSa Threat Analysis and Risk Assessment (TARA) +# Threat Analysis and Risk Assessment (TARA) +## ISO/SAE 21434:2021 Clause 15 — c-FuSa v0.5.1 +Generated: 2026-07-28T19:47:38Z -**Project:** c-FuSa v0.5.45 -**Standard:** ISO 21434:2021 §9 -**Generated:** 2026-06-11 +Assets and threats below were discovered by a keyword-based scan of public functions handling network, file, credential, or raw-memory input (see `assetInventoryMethod` in `tara.json`) — not a formal asset inventory. --- -## 1. Item Definition +| ID | Asset | Threat | Attack Vector | Feasibility | Safety | Financial | Operational | Privacy | Risk | Treatment | +|---|---|---|---|---|---|---|---|---|---|---| +| TARA-001 | Data handled by "strcpy (cmd_qualify.c) | An attacker supplies malformed/untrusted input to "strcpy, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | high | low | medium | low | high | mitigate | +| TARA-002 | Data handled by import_reqif (cmd_req.c) | An attacker supplies malformed/untrusted input to import_reqif, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | low | low | medium | low | medium | mitigate | +| TARA-003 | Data handled by import_polarion_xml (cmd_req.c) | An attacker supplies malformed/untrusted input to import_polarion_xml, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | low | low | medium | low | medium | mitigate | +| TARA-004 | Data handled by import_reqif (cmd_req.c) | An attacker supplies malformed/untrusted input to import_reqif, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | low | low | medium | low | medium | mitigate | +| TARA-005 | Data handled by import_codebeamer_xml (cmd_req.c) | An attacker supplies malformed/untrusted input to import_codebeamer_xml, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | low | low | medium | low | medium | mitigate | +| TARA-006 | Data handled by import_jama_xml (cmd_req.c) | An attacker supplies malformed/untrusted input to import_jama_xml, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | low | low | medium | low | medium | mitigate | +| TARA-007 | Data handled by malloc (cmd_fix.c) | An attacker supplies malformed/untrusted input to malloc, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | high | low | medium | low | high | mitigate | +| TARA-008 | Data handled by malloc (cmd_fix.c) | An attacker supplies malformed/untrusted input to malloc, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | high | low | medium | low | high | mitigate | +| TARA-009 | Data handled by "strcpy (cmd_vuln.c) | An attacker supplies malformed/untrusted input to "strcpy, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | high | low | medium | low | high | mitigate | +| TARA-010 | Data handled by parse_sec_code (cmd_hara.c) | An attacker supplies malformed/untrusted input to parse_sec_code, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | low | low | medium | low | medium | mitigate | +| TARA-011 | Data handled by cfusa_format_parse (report.c) | An attacker supplies malformed/untrusted input to cfusa_format_parse, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | low | low | medium | low | medium | mitigate | +| TARA-012 | Data handled by cfusa_fopen_write (utils.c) | An attacker supplies malformed/untrusted input to cfusa_fopen_write, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | low | low | medium | low | medium | mitigate | +| TARA-013 | Data handled by cfusa_config_load (config.c) | An attacker supplies malformed/untrusted input to cfusa_config_load, potentially causing incorrect behaviour, a crash, or information disclosure | local | medium | low | low | medium | low | medium | mitigate | -c-FuSa is a host-based static analysis and compliance reporting tool. It is not a vehicle-embedded component. It processes source code and configuration files and produces reports and JSON artifacts. - -## 2. Asset Identification - -| Asset ID | Asset | Security Property | Rationale | -|----------|-------|-------------------|-----------| -| A-01 | Source code under analysis | Integrity | Tampered source files could yield false-clean reports | -| A-02 | `.fusa-reqs.json` requirements registry | Integrity | Modified requirements affect traceability coverage | -| A-03 | `.fusa-hara.json` HARA document | Integrity | Tampered HARA affects ISO 26262 compliance evidence | -| A-04 | `cfusa` binary | Integrity | Compromised binary produces incorrect findings | -| A-05 | Check/qualify reports | Integrity | Falsified reports could support incorrect certification claims | -| A-06 | CI/CD pipeline configuration | Integrity | Modified CI could suppress safety checks | - -## 3. Threat Scenarios - -| ID | Asset | Threat | Attack Vector | CAL | -|----|-------|--------|---------------|-----| -| T-01 | A-01 | Adversary modifies source to suppress genuine findings | Supply chain / insider | CAL-2 | -| T-02 | A-02 | Requirements tampered to achieve false 100% coverage | Repository access | CAL-2 | -| T-03 | A-03 | HARA file manipulated to lower ASIL ratings | Repository access | CAL-3 | -| T-04 | A-04 | Binary replaced with version that skips checks | CI/CD compromise | CAL-3 | -| T-05 | A-05 | Report file overwritten with falsified results | Build artifact compromise | CAL-2 | - -## 4. Risk Treatment Decisions - -| Threat | Decision | Mitigation | -|--------|----------|------------| -| T-01 | Reduce | Code review policy; `cfusa sign` SHA-256 signing of reports | -| T-02 | Reduce | `cfusa qualify` binary hash verification; CI enforces qualification | -| T-03 | Reduce | HARA file reviewed and signed; HARA001-005 engine rules flag inconsistencies | -| T-04 | Reduce | `cfusa qualify --binary` verifies binary integrity; CI re-runs qualification | -| T-05 | Reduce | `cfusa sign` signs report files; report integrity checked before use | - -## 5. Cybersecurity Goals - -| CG-ID | Goal | CAL | Links | -|-------|------|-----|-------| -| CG-01 | The cfusa binary integrity must be verifiable prior to use in a safety process | CAL-2 | T-04 | -| CG-02 | Compliance reports must be authenticated before acceptance as certification evidence | CAL-2 | T-05 | -| CG-03 | HARA documents must be protected against unauthorised modification | CAL-3 | T-03 | +--- +_Total assets analysed: 13 (100% of 13 discovered by the scan)_ diff --git a/tests/test_gap_coverage.c b/tests/test_gap_coverage.c index 693a03b..4c0ae7f 100644 --- a/tests/test_gap_coverage.c +++ b/tests/test_gap_coverage.c @@ -369,7 +369,7 @@ void test_fmea_cyber_flag_adds_column(void) size_t n = fread(buf, 1, sizeof(buf) - 1, f); buf[n] = '\0'; fclose(f); - TEST_ASSERT_NOT_NULL(strstr(buf, "cyber_failure_mode")); + TEST_ASSERT_NOT_NULL(strstr(buf, "cyberFailureMode")); } (void)remove(fmea_path); } @@ -397,7 +397,9 @@ void test_fmea_output_dir_flag(void) //cfusa:test REQ-FMEA010 void test_fmea_severity_keywords_detected(void) { - /* Functions with brake/init/normal should produce High/Medium/Low severity */ + /* Functions with brake/init/normal should produce high/medium/low + * actionPriority (x-FuSa spec §9.2: severity is numeric 1-10; + * actionPriority carries the high/medium/low bucket, lowercase). */ char fmea_path[512]; snprintf(fmea_path, sizeof(fmea_path), "%s/fmea.json", GAP_DIR); (void)remove(fmea_path); @@ -412,11 +414,11 @@ void test_fmea_severity_keywords_detected(void) buf[n] = '\0'; fclose(f); /* High severity keywords: brake, watchdog */ - TEST_ASSERT_NOT_NULL(strstr(buf, "High")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"actionPriority\": \"high\"")); /* Medium severity keywords: init, validate */ - TEST_ASSERT_NOT_NULL(strstr(buf, "Medium")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"actionPriority\": \"medium\"")); /* Low severity: normal_func, process_data */ - TEST_ASSERT_NOT_NULL(strstr(buf, "Low")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"actionPriority\": \"low\"")); } (void)remove(fmea_path); } @@ -1087,8 +1089,9 @@ void test_sci_json_format_writes_sha256(void) fclose(f); TEST_ASSERT_NOT_NULL(strstr(buf, "\"schemaVersion\"")); TEST_ASSERT_NOT_NULL(strstr(buf, "\"kind\": \"sci\"")); - TEST_ASSERT_NOT_NULL(strstr(buf, "\"sha256\"")); - TEST_ASSERT_NOT_NULL(strstr(buf, "\"total_files\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"hash\": \"sha256:")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"artifacts\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"totalFiles\"")); } (void)remove(out); } diff --git a/tests/test_safety_rules.c b/tests/test_safety_rules.c index a95bbc2..d8059fc 100644 --- a/tests/test_safety_rules.c +++ b/tests/test_safety_rules.c @@ -77,11 +77,14 @@ void test_hara001_fires_when_no_file(void) void test_hara001_passes_when_file_present(void) { make_file(".fusa-hara.json", - "{\"schemaVersion\":\"1.10.4\",\"kind\":\"hara\"," - "\"hazards\":[{\"id\":\"H-1\",\"severity\":3," - "\"exposure\":3,\"controllability\":2,\"asil\":\"ASIL-C\"," - "\"safety_goal\":\"Prevent unintended acceleration\"," - "\"safe_state\":\"Engine off\",\"ftti_ms\":100}]}"); + "{\"schemaVersion\":\"1.14.0\",\"kind\":\"hara\",\"operationalSituations\":[]," + "\"hazards\":[{\"id\":\"H-1\",\"description\":\"Unintended acceleration\"," + "\"situations\":[],\"risk\":{\"severity\":\"S3\",\"exposure\":\"E3\"," + "\"controllability\":\"C2\",\"asil\":\"ASIL-C\"}," + "\"safetyGoals\":[\"SG-1\"]}]," + "\"safetyGoals\":[{\"id\":\"SG-1\",\"description\":\"Prevent unintended acceleration\"," + "\"hazards\":[\"H-1\"],\"asil\":\"ASIL-C\",\"safeState\":\"Engine off\"," + "\"fssrRefs\":[\"REQ-1\"]}]}"); cfusa_engine_reset(); cfusa_safety_register_rules(); @@ -104,9 +107,12 @@ void test_hara001_passes_when_file_present(void) void test_hara002_fires_on_incomplete_rating(void) { make_file(".fusa-hara.json", - "{\"hazards\":[{\"id\":\"H-1\",\"severity\":0," - "\"exposure\":0,\"controllability\":0,\"asil\":\"QM\"," - "\"safety_goal\":\"Goal\",\"safe_state\":\"Safe\"}]}"); + "{\"operationalSituations\":[]," + "\"hazards\":[{\"id\":\"H-1\",\"description\":\"Test hazard\"," + "\"risk\":{\"severity\":\"S1\",\"exposure\":\"E2\"}," + "\"safetyGoals\":[\"SG-1\"]}]," + "\"safetyGoals\":[{\"id\":\"SG-1\",\"description\":\"Goal\"," + "\"asil\":\"QM\",\"safeState\":\"Safe\",\"fssrRefs\":[\"REQ-1\"]}]}"); cfusa_engine_reset(); cfusa_safety_register_rules(); @@ -129,11 +135,11 @@ void test_hara002_fires_on_incomplete_rating(void) void test_hara003_fires_when_no_safety_goal(void) { make_file(".fusa-hara.json", - "{\"hazards\":[{\"id\":\"H-2\",\"severity\":2," - "\"exposure\":2,\"controllability\":2," - "\"asil\":\"ASIL-A\"," - "\"safety_goal\":\"[derive safety goal]\"," - "\"safe_state\":\"Safe\"}]}"); + "{\"operationalSituations\":[]," + "\"hazards\":[{\"id\":\"H-2\",\"description\":\"Test hazard\"," + "\"risk\":{\"severity\":\"S2\",\"exposure\":\"E2\",\"controllability\":\"C2\"," + "\"asil\":\"ASIL-A\"},\"safetyGoals\":[]}]," + "\"safetyGoals\":[]}"); cfusa_engine_reset(); cfusa_safety_register_rules(); @@ -156,11 +162,12 @@ void test_hara003_fires_when_no_safety_goal(void) void test_hara004_fires_on_tbd_asil(void) { make_file(".fusa-hara.json", - "{\"hazards\":[{\"id\":\"H-3\",\"severity\":2," - "\"exposure\":3,\"controllability\":2," - "\"asil\":\"TBD\"," - "\"safety_goal\":\"Defined goal\"," - "\"safe_state\":\"Safe\"}]}"); + "{\"operationalSituations\":[]," + "\"hazards\":[{\"id\":\"H-3\",\"description\":\"Test hazard\"," + "\"risk\":{\"severity\":\"S2\",\"exposure\":\"E3\",\"controllability\":\"C2\"," + "\"asil\":\"TBD\"},\"safetyGoals\":[\"SG-1\"]}]," + "\"safetyGoals\":[{\"id\":\"SG-1\",\"description\":\"Defined goal\"," + "\"asil\":\"ASIL-B\",\"safeState\":\"Safe\",\"fssrRefs\":[\"REQ-1\"]}]}"); cfusa_engine_reset(); cfusa_safety_register_rules(); diff --git a/tests/test_xfusa_v114.c b/tests/test_xfusa_v114.c new file mode 100644 index 0000000..e139217 --- /dev/null +++ b/tests/test_xfusa_v114.c @@ -0,0 +1,533 @@ +/* + * Tests for x-FuSa spec v1.13.0/v1.14.0 conformance: + * - qualitybar (FUSA-STUB001/FUSA-STUB002 detection + attestation) + * - hara/fmea/tara/safety-case/sas/sci schema conformance + * - summary.coveragePct + --min-coverage (fmea/tara) + * - --strict/--require-attestation gating + */ +#include +#include +#include +#include +#include "../vendor/unity/unity.h" +#include "cfusa/qualitybar.h" +#include "cfusa/utils.h" + +extern int cmd_hara(int argc, char **argv); +extern int cmd_fmea(int argc, char **argv); +extern int cmd_tara(int argc, char **argv); +extern int cmd_safety_case(int argc, char **argv); +extern int cmd_sas(int argc, char **argv); +extern int cmd_sci(int argc, char **argv); + +#define V114_DIR "/tmp/cfusa_v114_testdir" + +void setUp(void) { (void)mkdir(V114_DIR, 0700); } +void tearDown(void) {} + +static void write_file(const char *name, const char *body) +{ + char path[512]; + snprintf(path, sizeof(path), "%s/%s", V114_DIR, name); + FILE *f = cfusa_fopen_write(path); + if (f) { fputs(body, f); fclose(f); } +} + +static char *slurp(const char *name, size_t *len_out) +{ + char path[512]; + snprintf(path, sizeof(path), "%s/%s", V114_DIR, name); + FILE *f = fopen(path, "r"); + if (!f) return NULL; + static char buf[65536]; + size_t n = fread(buf, 1, sizeof(buf) - 1, f); + buf[n] = '\0'; + fclose(f); + if (len_out) *len_out = n; + return buf; +} + +/* ================================================================== */ +/* qualitybar unit tests */ +/* ================================================================== */ + +//cfusa:req REQ-QB001 +//cfusa:test REQ-QB001 +void test_qb_stub_text_bracket_placeholder(void) +{ + TEST_ASSERT_TRUE(cfusa_qb_is_stub_text("[describe asset]")); + TEST_ASSERT_TRUE(cfusa_qb_is_stub_text("Example hazard — replace with project-specific hazard")); + TEST_ASSERT_TRUE(cfusa_qb_is_stub_text("TBD")); + TEST_ASSERT_TRUE(cfusa_qb_is_stub_text("lorem ipsum dolor sit amet")); + TEST_ASSERT_TRUE(cfusa_qb_is_stub_text("please fill in this field")); +} + +//cfusa:req REQ-QB001 +//cfusa:test REQ-QB001 +void test_qb_stub_text_real_content_not_flagged(void) +{ + TEST_ASSERT_FALSE(cfusa_qb_is_stub_text("brake_apply does not perform its intended action")); + TEST_ASSERT_FALSE(cfusa_qb_is_stub_text("")); + TEST_ASSERT_FALSE(cfusa_qb_is_stub_text(NULL)); +} + +//cfusa:req REQ-QB002 +//cfusa:test REQ-QB002 +void test_qb_rule_b_needs_at_least_10_entries(void) +{ + const char *few[5] = {"a","a","a","a","a"}; + TEST_ASSERT_FALSE(cfusa_qb_rule_b_flagged(few, 5)); +} + +//cfusa:req REQ-QB002 +//cfusa:test REQ-QB002 +void test_qb_rule_b_flags_low_distinct_ratio(void) +{ + const char *same[12]; + for (int i = 0; i < 12; i++) same[i] = "identical failure mode text"; + TEST_ASSERT_TRUE(cfusa_qb_rule_b_flagged(same, 12)); +} + +//cfusa:req REQ-QB002 +//cfusa:test REQ-QB002 +void test_qb_rule_b_passes_high_distinct_ratio(void) +{ + const char *vals[] = { + "alpha","bravo","charlie","delta","echo","foxtrot", + "golf","hotel","india","juliet","kilo","lima" + }; + TEST_ASSERT_FALSE(cfusa_qb_rule_b_flagged(vals, 12)); +} + +//cfusa:req REQ-QB003 +//cfusa:test REQ-QB003 +void test_qb_content_hash_is_deterministic_and_prefixed(void) +{ + char h1[80], h2[80]; + cfusa_qb_content_hash("{\"entries\":[]}", strlen("{\"entries\":[]}"), h1); + cfusa_qb_content_hash("{\"entries\":[]}", strlen("{\"entries\":[]}"), h2); + TEST_ASSERT_EQUAL_STRING(h1, h2); + TEST_ASSERT_EQUAL_INT(0, strncmp(h1, "sha256:", 7)); + TEST_ASSERT_EQUAL_INT(71, (int)strlen(h1)); /* "sha256:" + 64 hex */ + + char h3[80]; + cfusa_qb_content_hash("{\"entries\":[1]}", strlen("{\"entries\":[1]}"), h3); + TEST_ASSERT_TRUE(strcmp(h1, h3) != 0); +} + +//cfusa:req REQ-QB004 +//cfusa:test REQ-QB004 +void test_qb_attestation_absent_is_invalid(void) +{ + cfusa_attestation_t att; + memset(&att, 0, sizeof(att)); + TEST_ASSERT_FALSE(cfusa_qb_attestation_valid(&att, "sha256:aa")); +} + +//cfusa:req REQ-QB004 +//cfusa:test REQ-QB004 +void test_qb_attestation_self_attested_is_invalid(void) +{ + cfusa_attestation_t att; + memset(&att, 0, sizeof(att)); + att.present = 1; + strcpy(att.status, "reviewed"); + strcpy(att.implementation_author, "Alice"); + strcpy(att.independent_reviewer, "Alice"); + strcpy(att.content_hash, "sha256:aa"); + TEST_ASSERT_FALSE(cfusa_qb_attestation_valid(&att, "sha256:aa")); +} + +//cfusa:req REQ-QB004 +//cfusa:test REQ-QB004 +void test_qb_attestation_stale_hash_is_invalid(void) +{ + cfusa_attestation_t att; + memset(&att, 0, sizeof(att)); + att.present = 1; + strcpy(att.status, "reviewed"); + strcpy(att.implementation_author, "auto"); + strcpy(att.independent_reviewer, "Jane Doe"); + strcpy(att.content_hash, "sha256:aaaa"); + TEST_ASSERT_FALSE(cfusa_qb_attestation_valid(&att, "sha256:bbbb")); +} + +//cfusa:req REQ-QB004 +//cfusa:test REQ-QB004 +void test_qb_attestation_valid_when_independent_and_fresh(void) +{ + cfusa_attestation_t att; + memset(&att, 0, sizeof(att)); + att.present = 1; + strcpy(att.status, "reviewed"); + strcpy(att.implementation_author, "auto"); + strcpy(att.independent_reviewer, "Jane Doe"); + strcpy(att.content_hash, "sha256:aaaa"); + TEST_ASSERT_TRUE(cfusa_qb_attestation_valid(&att, "sha256:aaaa")); +} + +//cfusa:req REQ-QB005 +//cfusa:test REQ-QB005 +void test_qb_attestation_read_roundtrip(void) +{ + const char *doc = + "{\"kind\":\"fmea-report\",\"attestation\":{\"status\":\"reviewed\"," + "\"implementationAuthor\":\"auto\",\"independentReviewer\":\"Jane Doe\"," + "\"reviewedAt\":\"2026-07-28T00:00:00Z\",\"contentHash\":\"sha256:deadbeef\"}}"; + cfusa_attestation_t att; + int found = cfusa_qb_attestation_read(doc, strlen(doc), &att); + TEST_ASSERT_TRUE(found); + TEST_ASSERT_EQUAL_STRING("reviewed", att.status); + TEST_ASSERT_EQUAL_STRING("auto", att.implementation_author); + TEST_ASSERT_EQUAL_STRING("Jane Doe", att.independent_reviewer); + TEST_ASSERT_EQUAL_STRING("sha256:deadbeef", att.content_hash); +} + +//cfusa:req REQ-QB005 +//cfusa:test REQ-QB005 +void test_qb_attestation_read_absent_returns_zero(void) +{ + cfusa_attestation_t att; + int found = cfusa_qb_attestation_read("{\"kind\":\"fmea-report\"}", 22, &att); + TEST_ASSERT_FALSE(found); +} + +//cfusa:req REQ-QB006 +//cfusa:test REQ-QB006 +void test_qb_rule_disposed_true_when_entry_present(void) +{ + write_file(".fusa-dispositions.json", + "{\"dispositions\":[{\"id\":\"DISP-0001\",\"rule\":\"FUSA-STUB001\"," + "\"action\":\"accept\",\"rationale\":\"reviewed\",\"reviewer\":\"Jane\"}]}"); + TEST_ASSERT_TRUE(cfusa_qb_rule_disposed(V114_DIR, "FUSA-STUB001")); + TEST_ASSERT_FALSE(cfusa_qb_rule_disposed(V114_DIR, "FUSA-STUB002")); + + char path[512]; snprintf(path, sizeof(path), "%s/.fusa-dispositions.json", V114_DIR); + (void)remove(path); +} + +/* ================================================================== */ +/* hara schema conformance */ +/* ================================================================== */ + +//cfusa:req REQ-HARA-SCHEMA001 +//cfusa:test REQ-HARA-SCHEMA001 +void test_hara_init_scaffold_has_three_empty_collections(void) +{ + char *argv[] = {"cfusa", "init", "--dir", V114_DIR, NULL}; + int rc = cmd_hara(4, argv); + TEST_ASSERT_EQUAL(0, rc); + + size_t len; + char *buf = slurp(".fusa-hara.json", &len); + TEST_ASSERT_NOT_NULL(buf); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"operationalSituations\": []")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"hazards\": []")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"safetyGoals\": []")); + /* x-FuSa spec §1.6 rule 1: no placeholder text in a freshly scaffolded file */ + TEST_ASSERT_FALSE(cfusa_qb_is_stub_text(buf)); + + char path[512]; snprintf(path, sizeof(path), "%s/.fusa-hara.json", V114_DIR); + (void)remove(path); +} + +//cfusa:req REQ-HARA-SCHEMA002 +//cfusa:test REQ-HARA-SCHEMA002 +void test_hara_show_json_reports_fssr_gap(void) +{ + write_file(".fusa-hara.json", + "{\"project\":\"p\",\"standard\":\"iso26262\",\"operationalSituations\":" + "[{\"id\":\"OS-1\",\"description\":\"Highway driving at speed\"}]," + "\"hazards\":[{\"id\":\"H-1\",\"description\":\"Unintended acceleration\"," + "\"situations\":[\"OS-1\"],\"risk\":{\"severity\":\"S3\",\"exposure\":\"E3\"," + "\"controllability\":\"C2\",\"asil\":\"ASIL-C\"},\"safetyGoals\":[\"SG-1\"]}]," + "\"safetyGoals\":[{\"id\":\"SG-1\",\"description\":\"Prevent unintended accel\"," + "\"hazards\":[\"H-1\"],\"asil\":\"ASIL-C\",\"fssrRefs\":[]}]}"); + + char *argv[] = {"cfusa", "show", "--dir", V114_DIR, "--format", "json", NULL}; + int rc = cmd_hara(6, argv); + (void)rc; /* not gated by fssrRefs gap alone */ + + char path[512]; snprintf(path, sizeof(path), "%s/.fusa-hara.json", V114_DIR); + (void)remove(path); +} + +//cfusa:req REQ-HARA-SCHEMA003 +//cfusa:test REQ-HARA-SCHEMA003 +void test_hara_show_text_detects_placeholder(void) +{ + write_file(".fusa-hara.json", + "{\"project\":\"p\",\"standard\":\"iso26262\",\"operationalSituations\":[]," + "\"hazards\":[{\"id\":\"H-1\",\"description\":\"[describe hazardous event]\"," + "\"situations\":[],\"risk\":{\"severity\":\"S1\",\"exposure\":\"E1\"," + "\"controllability\":\"C1\",\"asil\":\"QM\"},\"safetyGoals\":[]}]," + "\"safetyGoals\":[]}"); + + char *argv[] = {"cfusa", "show", "--dir", V114_DIR, NULL}; + int rc = cmd_hara(4, argv); + TEST_ASSERT_EQUAL(1, rc); /* FUSA-STUB001 always gates */ + + char path[512]; snprintf(path, sizeof(path), "%s/.fusa-hara.json", V114_DIR); + (void)remove(path); +} + +/* ================================================================== */ +/* fmea schema conformance + coverage + attestation */ +/* ================================================================== */ + +static void write_fmea_source(int n_funcs) +{ + char path[512]; + snprintf(path, sizeof(path), "%s/fmea_v114_src.c", V114_DIR); + FILE *f = cfusa_fopen_write(path); + TEST_ASSERT_NOT_NULL(f); + for (int i = 0; i < n_funcs; i++) + fprintf(f, "int do_thing_%d(int x)\n{\n return x + %d;\n}\n\n", i, i); + fclose(f); +} + +//cfusa:req REQ-FMEA-SCHEMA001 +//cfusa:test REQ-FMEA-SCHEMA001 +void test_fmea_json_has_ratingscale_and_summary(void) +{ + write_fmea_source(3); + char *argv[] = {"cfusa", "--dir", V114_DIR, "--format", "json", NULL}; + int rc = cmd_fmea(5, argv); + TEST_ASSERT_EQUAL(0, rc); + + size_t len; + char *buf = slurp("fmea.json", &len); + TEST_ASSERT_NOT_NULL(buf); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"ratingScale\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"failureMode\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"actionPriority\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"componentsInProject\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"coveragePct\"")); + TEST_ASSERT_NULL(strstr(buf, "[describe")); + + char p1[512]; snprintf(p1, sizeof(p1), "%s/fmea_v114_src.c", V114_DIR); remove(p1); + char p2[512]; snprintf(p2, sizeof(p2), "%s/fmea.json", V114_DIR); remove(p2); +} + +//cfusa:req REQ-FMEA-SCHEMA002 +//cfusa:test REQ-FMEA-SCHEMA002 +void test_fmea_failure_mode_varies_per_function(void) +{ + write_fmea_source(15); + char *argv[] = {"cfusa", "--dir", V114_DIR, "--format", "json", NULL}; + cmd_fmea(5, argv); + + size_t len; + char *buf = slurp("fmea.json", &len); + TEST_ASSERT_NOT_NULL(buf); + TEST_ASSERT_NOT_NULL(strstr(buf, "do_thing_0")); + TEST_ASSERT_NOT_NULL(strstr(buf, "do_thing_14")); + + char p1[512]; snprintf(p1, sizeof(p1), "%s/fmea_v114_src.c", V114_DIR); remove(p1); + char p2[512]; snprintf(p2, sizeof(p2), "%s/fmea.json", V114_DIR); remove(p2); +} + +//cfusa:req REQ-FMEA-COV001 +//cfusa:test REQ-FMEA-COV001 +void test_fmea_min_coverage_gate(void) +{ + write_fmea_source(5); + /* Coverage is 100% of what was found, so a 101% gate must always fail. */ + char *argv[] = {"cfusa", "--dir", V114_DIR, "--format", "json", "--min-coverage", "101", NULL}; + int rc = cmd_fmea(7, argv); + TEST_ASSERT_EQUAL(1, rc); + + char *argv2[] = {"cfusa", "--dir", V114_DIR, "--format", "json", "--min-coverage", "0", NULL}; + int rc2 = cmd_fmea(7, argv2); + TEST_ASSERT_EQUAL(0, rc2); + + char p1[512]; snprintf(p1, sizeof(p1), "%s/fmea_v114_src.c", V114_DIR); remove(p1); + char p2[512]; snprintf(p2, sizeof(p2), "%s/fmea.json", V114_DIR); remove(p2); +} + +//cfusa:req REQ-FMEA-ATTEST001 +//cfusa:test REQ-FMEA-ATTEST001 +void test_fmea_attest_flag_stamps_attestation(void) +{ + write_fmea_source(4); + char *argv[] = {"cfusa", "--dir", V114_DIR, "--format", "json", "--attest", "Jane Doe", NULL}; + int rc = cmd_fmea(7, argv); + TEST_ASSERT_EQUAL(0, rc); + + size_t len; + char *buf = slurp("fmea.json", &len); + TEST_ASSERT_NOT_NULL(buf); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"status\": \"reviewed\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"independentReviewer\": \"Jane Doe\"")); + + char p1[512]; snprintf(p1, sizeof(p1), "%s/fmea_v114_src.c", V114_DIR); remove(p1); + char p2[512]; snprintf(p2, sizeof(p2), "%s/fmea.json", V114_DIR); remove(p2); +} + +/* ================================================================== */ +/* tara schema conformance (SFOP impact) */ +/* ================================================================== */ + +static void write_tara_source(void) +{ + char path[512]; + snprintf(path, sizeof(path), "%s/tara_v114_src.c", V114_DIR); + FILE *f = cfusa_fopen_write(path); + TEST_ASSERT_NOT_NULL(f); + fprintf(f, + "int parse_config(char *buf)\n{\n return 0;\n}\n\n" + "int recv_packet(int fd)\n{\n return fd;\n}\n\n" + "int check_auth_token(char *tok)\n{\n return 1;\n}\n\n" + "void copy_buffer(char *dst, char *src)\n{\n}\n\n"); + fclose(f); +} + +//cfusa:req REQ-TARA-SCHEMA001 +//cfusa:test REQ-TARA-SCHEMA001 +void test_tara_json_has_sfop_impact(void) +{ + write_tara_source(); + char *argv[] = {"cfusa", "--dir", V114_DIR, "--format", "json", NULL}; + int rc = cmd_tara(5, argv); + TEST_ASSERT_EQUAL(0, rc); + + size_t len; + char *buf = slurp("tara.json", &len); + TEST_ASSERT_NOT_NULL(buf); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"threats\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"impact\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"safety\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"financial\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"operational\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"privacy\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"assetInventoryMethod\"")); + TEST_ASSERT_NULL(strstr(buf, "[describe")); + + char p1[512]; snprintf(p1, sizeof(p1), "%s/tara_v114_src.c", V114_DIR); remove(p1); + char p2[512]; snprintf(p2, sizeof(p2), "%s/tara.json", V114_DIR); remove(p2); + char p3[512]; snprintf(p3, sizeof(p3), "%s/tara.md", V114_DIR); remove(p3); +} + +/* ================================================================== */ +/* safety-case GSN schema */ +/* ================================================================== */ + +//cfusa:req REQ-SC-SCHEMA001 +//cfusa:test REQ-SC-SCHEMA001 +void test_safety_case_json_has_gsn_node_types(void) +{ + char *argv[] = {"cfusa", "--dir", V114_DIR, "--format", "json", NULL}; + int rc = cmd_safety_case(5, argv); + TEST_ASSERT_EQUAL(0, rc); + + size_t len; + char *buf = slurp("safety-case.json", &len); + TEST_ASSERT_NOT_NULL(buf); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"nodes\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"edges\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"completeness\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"type\": \"goal\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"type\": \"strategy\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "supportedBy")); + + char p[512]; snprintf(p, sizeof(p), "%s/safety-case.json", V114_DIR); remove(p); +} + +/* ================================================================== */ +/* sas checklist/summary schema */ +/* ================================================================== */ + +//cfusa:req REQ-SAS-SCHEMA001 +//cfusa:test REQ-SAS-SCHEMA001 +void test_sas_json_has_checklist_and_summary(void) +{ + char out[512]; snprintf(out, sizeof(out), "%s/sas.json", V114_DIR); + char *argv[] = {"cfusa", "--dir", V114_DIR, "--format", "json", "--output", out, NULL}; + int rc = cmd_sas(7, argv); + TEST_ASSERT_EQUAL(0, rc); + + FILE *f = fopen(out, "r"); + TEST_ASSERT_NOT_NULL(f); + char buf[16384]; + size_t n = fread(buf, 1, sizeof(buf) - 1, f); + buf[n] = '\0'; + fclose(f); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"checklist\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"summary\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"present\"")); + remove(out); + + /* x-FuSa spec §9.3: sas.json is not a replacement for the sas.md + * companion — a companion MUST also be written. */ + char md[512]; snprintf(md, sizeof(md), "%s/sas.md", V114_DIR); + FILE *mf = fopen(md, "r"); + TEST_ASSERT_NOT_NULL(mf); + if (mf) fclose(mf); + (void)remove(md); +} + +/* ================================================================== */ +/* sci hash-field convention (x-FuSa spec §2.7) */ +/* ================================================================== */ + +//cfusa:req REQ-SCI-SCHEMA001 +//cfusa:test REQ-SCI-SCHEMA001 +void test_sci_json_hash_field_is_prefixed(void) +{ + write_file("sci_v114_src.c", "int sci_v114_probe(void) { return 0; }\n"); + + char out[512]; snprintf(out, sizeof(out), "%s/sci_v114.json", V114_DIR); + char *argv[] = {"cfusa", "--dir", V114_DIR, "--format", "json", "--output", out, NULL}; + int rc = cmd_sci(7, argv); + TEST_ASSERT_EQUAL(0, rc); + + FILE *f = fopen(out, "r"); + TEST_ASSERT_NOT_NULL(f); + char buf[16384]; + size_t n = fread(buf, 1, sizeof(buf) - 1, f); + buf[n] = '\0'; + fclose(f); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"artifacts\"")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"hash\": \"sha256:")); + TEST_ASSERT_NOT_NULL(strstr(buf, "\"version\"")); + remove(out); + char srcpath[512]; snprintf(srcpath, sizeof(srcpath), "%s/sci_v114_src.c", V114_DIR); + remove(srcpath); +} + +int main(void) +{ + UNITY_BEGIN(); + RUN_TEST(test_qb_stub_text_bracket_placeholder); + RUN_TEST(test_qb_stub_text_real_content_not_flagged); + RUN_TEST(test_qb_rule_b_needs_at_least_10_entries); + RUN_TEST(test_qb_rule_b_flags_low_distinct_ratio); + RUN_TEST(test_qb_rule_b_passes_high_distinct_ratio); + RUN_TEST(test_qb_content_hash_is_deterministic_and_prefixed); + RUN_TEST(test_qb_attestation_absent_is_invalid); + RUN_TEST(test_qb_attestation_self_attested_is_invalid); + RUN_TEST(test_qb_attestation_stale_hash_is_invalid); + RUN_TEST(test_qb_attestation_valid_when_independent_and_fresh); + RUN_TEST(test_qb_attestation_read_roundtrip); + RUN_TEST(test_qb_attestation_read_absent_returns_zero); + RUN_TEST(test_qb_rule_disposed_true_when_entry_present); + + RUN_TEST(test_hara_init_scaffold_has_three_empty_collections); + RUN_TEST(test_hara_show_json_reports_fssr_gap); + RUN_TEST(test_hara_show_text_detects_placeholder); + + RUN_TEST(test_fmea_json_has_ratingscale_and_summary); + RUN_TEST(test_fmea_failure_mode_varies_per_function); + RUN_TEST(test_fmea_min_coverage_gate); + RUN_TEST(test_fmea_attest_flag_stamps_attestation); + + RUN_TEST(test_tara_json_has_sfop_impact); + + RUN_TEST(test_safety_case_json_has_gsn_node_types); + + RUN_TEST(test_sas_json_has_checklist_and_summary); + + RUN_TEST(test_sci_json_hash_field_is_prefixed); + + return UNITY_END(); +}