diff --git a/src/plugins/markdown-report/sarif_gen.ml b/src/plugins/markdown-report/sarif_gen.ml index fce40cc7d22fe0d29b370a9f02f018cc3406be8f..3758cd60f88a63fc9c7fa5399a311aec09efb9de 100644 --- a/src/plugins/markdown-report/sarif_gen.ml +++ b/src/plugins/markdown-report/sarif_gen.ml @@ -60,7 +60,19 @@ module Analysis_cmdline = let command_line () = Array.to_list Sys.argv -let update_cmdline () = Analysis_cmdline.add (command_line()) +let update_cmdline = + let already_updated = ref false in + fun () -> + if not (!already_updated) then begin + (* This function must be run after the loading stage, so that + the Analysis_cmdline state contains the list of previous launches + if any. However, `-then` restart the boot sequence from the loading + included, meaning that the hook will be replayed _also_ after each + `-then`. Using a _non-projectified_ boolean ref ensures that we add + the command line only once per run. *) + already_updated := true; + Analysis_cmdline.add (command_line()) + end let () = Cmdline.run_after_loading_stage update_cmdline diff --git a/src/plugins/markdown-report/tests/sarif/oracle/cwe125.sarif b/src/plugins/markdown-report/tests/sarif/oracle/cwe125.sarif index 3c9e422059821ea9c926da5d88f029e0ddf8a331..5855585658f0d7aee1f680420db13842a321ca1f 100644 --- a/src/plugins/markdown-report/tests/sarif/oracle/cwe125.sarif +++ b/src/plugins/markdown-report/tests/sarif/oracle/cwe125.sarif @@ -34,17 +34,6 @@ "exitCode": 0, "executionSuccessful": true }, - { - "commandLine": - "frama-c -check -load tests/sarif/result/cwe125_eva.sav -then -mdr-out tests/sarif/result/cwe125.sarif -mdr-gen sarif -mdr-no-print-libc -mdr-sarif-deterministic", - "arguments": [ - "-check", "-load", "tests/sarif/result/cwe125_eva.sav", "-then", - "-mdr-out", "tests/sarif/result/cwe125.sarif", "-mdr-gen", - "sarif", "-mdr-no-print-libc", "-mdr-sarif-deterministic" - ], - "exitCode": 0, - "executionSuccessful": true - }, { "commandLine": "frama-c -check -load tests/sarif/result/cwe125_eva.sav -then -mdr-out tests/sarif/result/cwe125.sarif -mdr-gen sarif -mdr-no-print-libc -mdr-sarif-deterministic",