@@ -118,7 +118,7 @@ def test_version(self):
118118 def test_invalid_file_or_directory (self ):
119119 """Test behaviour with an invalid file/directory"""
120120 with pytest .raises (SystemExit ) as e :
121- main (["cve-bin-tool" , "non-existant " ])
121+ main (["cve-bin-tool" , "non-existent " ])
122122 assert e .value .args [0 ] == ERROR_CODES [FileNotFoundError ]
123123
124124 def test_null_byte_in_filename (self ):
@@ -138,7 +138,7 @@ def test_null_byte_in_filename(self):
138138 assert e .value .args [0 ] == ERROR_CODES [FileNotFoundError ]
139139
140140 def test_invalid_parameter (self ):
141- """Test that invalid parmeters exit with expected error code.
141+ """Test that invalid parameters exit with expected error code.
142142 ArgParse calls sys.exit(2) for all errors"""
143143
144144 # no directory specified
@@ -738,6 +738,64 @@ def test_sbom_detection(self, caplog):
738738 "Using CVE Binary Tool SBOM Auto Detection" ,
739739 ) in caplog .record_tuples
740740
741+ def test_sbom_no_scan_mode (self , caplog ):
742+ """Test SBOM processing in no-scan mode"""
743+ SBOM_PATH = Path (__file__ ).parent .resolve () / "sbom"
744+
745+ with caplog .at_level (logging .INFO ):
746+ main (
747+ [
748+ "cve-bin-tool" ,
749+ "--no-scan" ,
750+ "--sbom" ,
751+ "spdx" ,
752+ "--sbom-file" ,
753+ str (SBOM_PATH / "spdx_test.spdx" ),
754+ ]
755+ )
756+
757+ # Check that no-scan mode message is logged
758+ sbom_no_scan_message_found = False
759+
760+ for _ , _ , log_message in caplog .record_tuples :
761+ if "Processing SBOM in no-scan mode" in log_message :
762+ sbom_no_scan_message_found = True
763+
764+ assert (
765+ sbom_no_scan_message_found
766+ ), "Expected SBOM no-scan mode message not found"
767+
768+ # The no-scan mode message is displayed in the console output, not in logs
769+ # We can see from the captured stdout that it's working correctly
770+
771+ def test_directory_no_scan_mode_sbom_generation (self , caplog ):
772+ """Test directory scanning in no-scan mode with SBOM generation"""
773+ # Create a temporary directory with some test files
774+ test_dir = Path (self .tempdir ) / "test_scan"
775+ test_dir .mkdir ()
776+
777+ # Create a simple test file that would be detected by a checker
778+ test_file = test_dir / "test_file"
779+ test_file .write_text ("test content" )
780+
781+ with caplog .at_level (logging .INFO ):
782+ main (
783+ [
784+ "cve-bin-tool" ,
785+ "--no-scan" ,
786+ str (test_dir ),
787+ "--sbom" ,
788+ "spdx" ,
789+ "--sbom-file" ,
790+ str (test_dir / "output.spdx" ),
791+ ]
792+ )
793+
794+ # Check that the scan completed without errors
795+ # In no-scan mode, we expect the scan to complete and generate an SBOM
796+ # even if no products are found
797+ assert "Total files:" in caplog .text
798+
741799 @pytest .mark .skipif (not LONG_TESTS (), reason = "Skipping long tests" )
742800 def test_console_output_depending_reportlab_existence (self , caplog ):
743801 import subprocess
0 commit comments