Skip to content

fix: slsa L1-L4 level format, header, iec62443 stderr parity (v0.5.28)#38

Merged
SoundMatt merged 1 commit into
mainfrom
fix/capabilities-slsa
Jun 13, 2026
Merged

fix: slsa L1-L4 level format, header, iec62443 stderr parity (v0.5.28)#38
SoundMatt merged 1 commit into
mainfrom
fix/capabilities-slsa

Conversation

@SoundMatt

Copy link
Copy Markdown
Owner

Summary

  • cfusa slsa --level L1/L2/L3/L4: accept Lx prefix format — atoi("L1") was returning 0, causing exit 2 even for valid levels
  • cfusa slsa text output: header changed from "SLSA v1.0 Gap Report" → "SLSA Supply-Chain Gap Report"
  • cfusa slsa --output <file>: print "SLSA gap report written to <file>" to stderr after writing
  • cfusa iec62443 --output <file>: print "IEC 62443 gap report written to <file>" to stderr after writing
  • 8 new tests: level format, bad level, output file, bad output path for both commands

Parity

go-FuSa: TestRunSLSA_AllLevels, TestRunSLSA_BadLevel, TestRunSLSA_OutputFile, TestRunSLSA_BadOutputPath, TestRunIEC62443_AllSLs, TestRunIEC62443_BadSL, TestRunIEC62443_OutputFile, TestRunIEC62443_BadOutputPath

Test plan

  • All 34 test suites pass (verified locally: 100% pass)
  • cfusa slsa --level L1 exits 0 or 1 (not 2)
  • cfusa slsa --level L5 exits 2
  • cfusa slsa --output /tmp/s.json creates file and prints to stderr
  • cfusa slsa --output /no/such/dir/s.json exits 3
  • cfusa iec62443 --sl SL-1 exits 0 or 1
  • cfusa iec62443 --sl SL-5 exits 2
  • cfusa iec62443 --output /tmp/i.json creates file and prints to stderr

….5.28)

- cmd_slsa: accept --level L1/L2/L3/L4 prefix format (atoi("L1") was 0)
- cmd_slsa: update text header to "SLSA Supply-Chain Gap Report"
- cmd_slsa: print confirmation to stderr when --output is used
- cmd_iec62443: print "IEC 62443 gap report written to" to stderr on --output
- tests: add 8 new tests covering level format, bad level, output file,
  bad output path for both slsa and iec62443
- .fusa-reqs.json: add REQ-SLSA-LEVEL001, REQ-SLSA-OUT001,
  REQ-IEC62443-SL001, REQ-IEC62443-OUT001

Parity with go-FuSa TestRunSLSA_AllLevels, TestRunSLSA_BadLevel,
TestRunSLSA_OutputFile, TestRunSLSA_BadOutputPath,
TestRunIEC62443_AllSLs, TestRunIEC62443_BadSL,
TestRunIEC62443_OutputFile, TestRunIEC62443_BadOutputPath.

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>
Comment thread cmd/cfusa/cmd_iec62443.c

if (output && out != stdout) fclose(out);
if (output && out != stdout) {
fclose(out);
Comment thread cmd/cfusa/cmd_slsa.c

if (output && out != stdout) fclose(out);
if (output && out != stdout) {
fclose(out);
Comment thread tests/test_cli_commands.c
//cfusa:test REQ-SLSA-LEVEL001
void test_slsa_level_l1_accepted(void)
{
char *argv[] = {"cfusa", "--dir", CLI_TEST_DIR, "--level", "L1", NULL};
Comment thread tests/test_cli_commands.c
//cfusa:test REQ-SLSA-LEVEL001
void test_slsa_bad_level_returns_2(void)
{
char *argv[] = {"cfusa", "--dir", CLI_TEST_DIR, "--level", "L5", NULL};
Comment thread tests/test_cli_commands.c
void test_slsa_output_writes_file(void)
{
remove(SLSA_OUT_TEST_FILE);
char *argv[] = {"cfusa", "--dir", CLI_TEST_DIR, "--format", "json",
Comment thread tests/test_cli_commands.c
//cfusa:test REQ-SLSA-OUT001
void test_slsa_bad_output_returns_3(void)
{
char *argv[] = {"cfusa", "--dir", CLI_TEST_DIR,
Comment thread tests/test_cli_commands.c
//cfusa:test REQ-IEC62443-SL001
void test_iec62443_sl_format_accepted(void)
{
char *argv[] = {"cfusa", "--dir", CLI_TEST_DIR, "--sl", "SL-1", NULL};
Comment thread tests/test_cli_commands.c
//cfusa:test REQ-IEC62443-SL001
void test_iec62443_bad_sl_returns_2(void)
{
char *argv[] = {"cfusa", "--dir", CLI_TEST_DIR, "--sl", "SL-5", NULL};
Comment thread tests/test_cli_commands.c
void test_iec62443_output_writes_file(void)
{
remove(IEC62443_OUT_TEST_FILE);
char *argv[] = {"cfusa", "--dir", CLI_TEST_DIR, "--format", "json",
Comment thread tests/test_cli_commands.c
//cfusa:test REQ-IEC62443-OUT001
void test_iec62443_bad_output_returns_3(void)
{
char *argv[] = {"cfusa", "--dir", CLI_TEST_DIR,
@SoundMatt SoundMatt merged commit e536b11 into main Jun 13, 2026
10 checks passed
@SoundMatt SoundMatt deleted the fix/capabilities-slsa branch June 13, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants