fix: hara ASIL C0 table, Sx/Ex/Cx format, subcmd errors, init guard (v0.5.29)#39
Merged
Conversation
…n subcmd (v0.5.29) - cmd_hara: extend ASIL table from C1-C3 (3 cols) to C0-C3 (4 cols) matching go-FuSa DetermineASIL — S2/E4/C2 now ASIL-C, S2/E4/C3 now ASIL-D, etc. - cmd_hara asil: accept --severity S2 / --exposure E4 / --controllability C2 prefix format; use -1 sentinel to detect missing params - cmd_hara asil: missing params returns exit 2 (was exit 1) - cmd_hara init: returns exit 2 with "already exists" if .fusa-hara.json exists - cmd_hara: unknown subcommand returns exit 2 (was silent fallthrough to show) - tests/test_hara: update missing-params to expect exit 2; add 5 new tests - tests/test_hara_advanced: update s0/e0/c0 tests to reflect valid boundary values Parity with go-FuSa TestDetermineASIL_Table4, TestRunHara_ASIL, TestRunHara_ASIL_MissingFlags, TestRunHara_InitAlreadyExists, TestRunHara_UnknownSubcommand. Signed-off-by: Matt Jones <matt@jellybaby.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
| case 's': s = atoi(optarg); break; | ||
| case 'e': e = atoi(optarg); break; | ||
| case 'c': c = atoi(optarg); break; | ||
| case 's': { const char *v = optarg; if (v[0]=='S'||v[0]=='s') v++; s = atoi(v); break; } |
| case 'e': e = atoi(optarg); break; | ||
| case 'c': c = atoi(optarg); break; | ||
| 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': c = atoi(optarg); break; | ||
| 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; } |
| void test_hara_init_already_exists_returns_2(void) | ||
| { | ||
| /* First init should succeed */ | ||
| char *argv1[] = {"cfusa", "init", "--dir", HARA_TEST_DIR, NULL}; |
| cmd_hara(4, argv1); | ||
|
|
||
| /* Second init → exit 2 */ | ||
| char *argv2[] = {"cfusa", "init", "--dir", HARA_TEST_DIR, NULL}; |
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
cfusa haraASIL table: extended from 3-column (C1–C3) to 4-column (C0–C3) to match go-FuSa'sDetermineASIL. S0/E0 = QM, C0 = valid class.cfusa hara asil: accepts--severity S2 --exposure E4 --controllability C2prefix formatcfusa hara asil: missing params → exit 2 (was exit 1)cfusa hara init: guards against overwriting existing.fusa-hara.json→ exit 2cfusa hara <unknown>: unknown subcommand → exit 2 (was silent fallthrough to show)Parity
go-FuSa:
TestDetermineASIL_Table4,TestRunHara_ASIL,TestRunHara_ASIL_MissingFlags,TestRunHara_InitAlreadyExists,TestRunHara_UnknownSubcommandTest plan
cfusa hara asil --severity S2 --exposure E4 --controllability C2prints ASIL-Ccfusa hara asil --severity S2 --exposure E4 --controllability C0prints ASIL-Acfusa hara asil --severity S2exits 2cfusa hara initon existing file exits 2cfusa hara nopeexits 2