summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-08-24 13:01:26 +0100
committerMark Brown <broonie@kernel.org>2026-08-24 13:01:28 +0100
commite2dfade5a188b84ba17632b3cdad3f67a4fa1fcd (patch)
tree39f646f07f1a0e04ddeaabfa7e3f56075bd1999a /scripts
parente4cf78655f61ec6d7d6e8b138222c94aa0259640 (diff)
parent8992f32c57607bdfaf5de2a2cd26b3b71f3a9d55 (diff)
downloadlinux-next-e2dfade5a188b84ba17632b3cdad3f67a4fa1fcd.tar.gz
linux-next-e2dfade5a188b84ba17632b3cdad3f67a4fa1fcd.zip
Merge branch 'char-misc-next' of https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
Diffstat (limited to 'scripts')
-rw-r--r--scripts/sbom/sbom/cmd_graph/savedcmd_parser/savedcmd_parser.py2
-rw-r--r--scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py25
2 files changed, 26 insertions, 1 deletions
diff --git a/scripts/sbom/sbom/cmd_graph/savedcmd_parser/savedcmd_parser.py b/scripts/sbom/sbom/cmd_graph/savedcmd_parser/savedcmd_parser.py
index 6a7ea4787aa1..d2ca842a7849 100644
--- a/scripts/sbom/sbom/cmd_graph/savedcmd_parser/savedcmd_parser.py
+++ b/scripts/sbom/sbom/cmd_graph/savedcmd_parser/savedcmd_parser.py
@@ -57,7 +57,7 @@ def parse_inputs_from_commands(
try:
inputs = matched_parser(single_command)
input_files.extend(inputs)
- except (CmdParsingError, IndexError) as e:
+ except (CmdParsingError, IndexError, ValueError) as e:
log_error_or_warning(
"Skipped parsing command {single_command} because of command parsing error: {error_message}",
single_command=single_command,
diff --git a/scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py b/scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py
index a061a748e1bf..d7776f072e03 100644
--- a/scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py
+++ b/scripts/sbom/tests/cmd_graph/test_savedcmd_parser.py
@@ -19,6 +19,31 @@ class TestSavedCmdParser(unittest.TestCase):
errors = sbom_logging._error_logger._message_counts # type: ignore
self.assertEqual(errors, {})
+ # Error handling tests
+ def test_malformed_shell_quoting(self):
+ command = 'gcc "unterminated'
+ with patch.object(sbom_logging, "warning") as warning:
+ parsed = parse_inputs_from_commands(command, fail_on_unknown_build_command=False)
+
+ self.assertEqual(parsed, [])
+ warning.assert_called_once_with(
+ "Skipped parsing command {single_command} because of command parsing error: {error_message}",
+ single_command=command,
+ error_message="No closing quotation",
+ )
+
+ def test_missing_positional_argument(self):
+ command = "objcopy"
+ with patch.object(sbom_logging, "warning") as warning:
+ parsed = parse_inputs_from_commands(command, fail_on_unknown_build_command=False)
+
+ self.assertEqual(parsed, [])
+ warning.assert_called_once_with(
+ "Skipped parsing command {single_command} because of command parsing error: {error_message}",
+ single_command=command,
+ error_message="list index out of range",
+ )
+
# Compound command tests
def test_dd_cat(self):
cmd = "(dd if=arch/x86/boot/setup.bin bs=4k conv=sync status=none; cat arch/x86/boot/vmlinux.bin) >arch/x86/boot/bzImage"