fix: fmea/tara project-relative paths + coveragePct clamp + wider FMEA templates (v0.40.0) - #68
Closed
SoundMatt wants to merge 2 commits into
Closed
fix: fmea/tara project-relative paths + coveragePct clamp + wider FMEA templates (v0.40.0)#68SoundMatt wants to merge 2 commits into
SoundMatt wants to merge 2 commits into
Conversation
…wider templates x-FuSa spec §4 requires every Finding.Location.File (and the equivalent fmea entries[].file) to be project-relative with forward slashes. Under the common `--dir`-omitted invocation, fmea.Scan's entries[].file and CYBER's own Finding.Location.File (which tara.Scan sources threats[].location/sourceFile directly from) both carried the raw, absolute walked path — reproduced exactly as described against this repo's own source tree (go-FuSa#59). fmea.Scan now relativizes every entry's File against projectRoot; cyber.location now does the same relativization lint/analyze already applied to their own findings (REQ-LOC-REL001), which transitively fixes tara.json too since it had no bug of its own — it only ever inherited an absolute path from the CYBER finding it was built from. x-FuSa spec §9.2 (spec v1.15.0) states coveragePct MUST NOT exceed 100. Both fmea.buildSummary and tara.buildSummary already guaranteed this mathematically via their componentsInProject/assetsInProject >= componentsAnalyzed/assetsAnalyzed fallback, but add an explicit defensive clamp anyway — cheap insurance against a future change to that fallback silently reintroducing the overflow. New regression tests use a fixture with a non-trivial test-source tree (many _test.go files) since a fixture with no such tree can't exercise the exclusion logic the bug depends on. Separately, this repo's own committed fmea.json failed its own new FUSA-STUB002 content-quality gate: deriveAnalysis bucketed every scanned function into one of only 6 fixed template strings, reducing a 461-function codebase to a ~0.013 distinct-value ratio — exactly the "hundreds of FMEA rows sharing identical boilerplate text" pattern §1.6.1 rule B exists to catch (go-FuSa#60). Every template now weaves in the function's own component (a genuine per-function signal) plus, for the dominant no-signal-matched bucket, whether the function has a receiver and how many parameters it takes. Regenerated fmea.json/ fmea.csv: distinct-value ratios are now ~0.28-0.29, well clear of 0.1. Also (x-FuSa spec §1.6 rule 4, SHOULD, non-binding): extracted the vendor/testdata/dot-directory exclusion check duplicated across trace.ScanTags/ScanFuncCoverage/ScanFuncTagCoverage, fmea.CountProjectFunctions, and tara.CountProjectFiles into one shared trace.IsExcludedDir, so the coverage-denominator scanners this issue was actually about stop maintaining an independently-drifting copy. Regenerated tara.json/tara.md for the path fix; tara's own pre-existing FUSA-STUB002 gap (threats[].threat vocabulary, unrelated to this PR) is addressed separately. Signed-off-by: Matt Jones <matt@jellybaby.com> Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
| func TestRunFmea_DirOmitted_EntryFileIsRelative(t *testing.T) { | ||
| dir := t.TempDir() | ||
| src := "package main\n\n//fusa:req REQ-001\nfunc SafetyFunc() error { return nil }\n" | ||
| if err := os.WriteFile(filepath.Join(dir, "main.go"), []byte(src), 0o644); err != nil { |
| func TestRunTara_DirOmitted_ThreatLocationIsRelative(t *testing.T) { | ||
| dir := t.TempDir() | ||
| src := "package main\n\nimport \"crypto/md5\"\n\nfunc Hash(b []byte) [16]byte { return md5.Sum(b) }\n" | ||
| if err := os.WriteFile(filepath.Join(dir, "weak.go"), []byte(src), 0o644); err != nil { |
| // | ||
| //fusa:req REQ-FMEA002 | ||
| func deriveAnalysis(name string, returnsErr, hasGoroutine, hasSafetyReq bool) (modes, effects, causes, mitigations []string, sev Severity) { | ||
| func deriveAnalysis(name, component string, returnsErr, hasGoroutine, hasSafetyReq, hasReceiver bool, paramCount int) (modes, effects, causes, mitigations []string, sev Severity) { |
…nd-coverage-quality Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com> # Conflicts: # CHANGELOG.md # README.md # docs/tool-safety-manual.md # fusa.go
SoundMatt
force-pushed
the
fix/fmea-tara-paths-and-coverage-quality
branch
from
July 28, 2026 22:19
305bdc4 to
61c3faa
Compare
Owner
Author
Merged
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--dir-omitted invocation, violating x-FuSa spec §4's project-relative MUST. Fixed at the root:fmea.Scannow relativizesentries[].file, andcyber.locationnow relativizesFinding.Location.Filethe same way lint/analyze already did — which transitively fixes tara'sthreats[].location/sourceFiletoo, since tara.Scan sources them directly from a CYBER finding.coveragePctMUST NOT exceed 100. Added an explicit defensive clamp in bothfmea.buildSummaryandtara.buildSummary, plus regression tests using a fixture with a non-trivial test-source tree (required to actually exercise the exclusion logic the bug depends on).fmea.jsonfailed its ownFUSA-STUB002content-quality gate (6 fixed templates across 461 functions, ~0.013 distinct-value ratio). WidenedderiveAnalysis's signal set (component, receiver, parameter count) so templates measurably vary by function shape; regeneratedfmea.json/fmea.csv— distinct-value ratios are now ~0.28-0.29.trace.ScanTags/ScanFuncCoverage/ScanFuncTagCoverage,fmea.CountProjectFunctions, andtara.CountProjectFilesinto one sharedtrace.IsExcludedDir.Closes #59, closes #60. Addresses x-FuSa spec v1.15.0 items 2 and 3 from #64 (item 1, attestation carry-forward, is in a separate PR).
Test plan
go build ./...go vet ./...go test -race -count=1 ./...(88.5% total coverage)golangci-lint run ./...(0 issues)go generate ./...(no diff)fmea.json/tara.jsonentries now use relative paths (analyze/analyze.go,weak.go, etc.), never absolutegofusa fmeaagainst this repo no longer emits a FUSA-STUB002 warning--diromitted), coveragePct-clamp regression tests with a non-trivial test-source tree,IsExcludedDirunit tests