refactor(core/prodtest): move syslog prodtest command to prodtest project
What changed, and why it matters
This commit is a simple code move: it takes the 'log-filter' production-test command out of the general syslog file and puts it into the dedicated prodtest project file. The actual behavior of the command does not change. There is no user-facing feature change and no security fix or vulnerability introduced.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is a pure refactor. The prodtest_set_log_filter CLI command and its PRODTEST_CLI_CMD registration are removed from core/embed/sys/dbg/syslog.c and added to a new file core/embed/projects/prodtest/cmd/prodtest_syslog.c. The build scripts (SConscript.prodtest, SConscript.prodtest_emu, and build.rs) are updated to compile the new file. The command remains guarded by USE_DBG_CONSOLE and TREZOR_PRODTEST and still calls syslog_set_filter with the same argument validation and error handling.
Changed components
core/embed/projects/prodtest/cmd/prodtest_syslog.ccore/embed/sys/dbg/syslog.ccore/SConscript.prodtestcore/SConscript.prodtest_emucore/embed/projects/prodtest/build.rsInspect captured patch +64 / −32
diff --git a/core/SConscript.prodtest b/core/SConscript.prodtest
index b19db13f..21c99e2e 100644
--- a/core/SConscript.prodtest
+++ b/core/SConscript.prodtest
@@ -211,6 +211,7 @@ SOURCE_PRODTEST = [
'embed/projects/prodtest/cmd/prodtest_tamper.c',
'embed/projects/prodtest/cmd/prodtest_sbu.c',
'embed/projects/prodtest/cmd/prodtest_secure_channel.c',
+ 'embed/projects/prodtest/cmd/prodtest_syslog.c',
'embed/projects/prodtest/cmd/prodtest_telemetry.c',
'embed/projects/prodtest/cmd/prodtest_touch.c',
'embed/projects/prodtest/cmd/prodtest_tropic.c',
diff --git a/core/SConscript.prodtest_emu b/core/SConscript.prodtest_emu
index c2f13029..ba049e93 100644
--- a/core/SConscript.prodtest_emu
+++ b/core/SConscript.prodtest_emu
@@ -184,6 +184,7 @@ SOURCE_PRODTEST = [
'embed/projects/prodtest/cmd/prodtest_tamper.c',
'embed/projects/prodtest/cmd/prodtest_sbu.c',
'embed/projects/prodtest/cmd/prodtest_secure_channel.c',
+ 'embed/projects/prodtest/cmd/prodtest_syslog.c',
'embed/projects/prodtest/cmd/prodtest_telemetry.c',
'embed/projects/prodtest/cmd/prodtest_touch.c',
'embed/projects/prodtest/cmd/prodtest_tropic.c',
diff --git a/core/embed/projects/prodtest/build.rs b/core/embed/projects/prodtest/build.rs
index 31c38560..40e19e7f 100644
--- a/core/embed/projects/prodtest/build.rs
+++ b/core/embed/projects/prodtest/build.rs
@@ -44,6 +44,7 @@ fn main() -> Result<()> {
"prodtest_tamper.c",
"prodtest_sbu.c",
"prodtest_secure_channel.c",
+ "prodtest_syslog.c",
"prodtest_telemetry.c",
"prodtest_touch.c",
"prodtest_tropic.c",
diff --git a/core/embed/projects/prodtest/cmd/prodtest_syslog.c b/core/embed/projects/prodtest/cmd/prodtest_syslog.c
new file mode 100644
index 00000000..895d289f
--- /dev/null
+++ b/core/embed/projects/prodtest/cmd/prodtest_syslog.c
@@ -0,0 +1,61 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef USE_DBG_CONSOLE
+
+#include <trezor_rtl.h>
+
+#include <rtl/cli.h>
+#include <sys/logging.h>
+#include <sys/syslog.h>
+
+#include "prodtest_error_codes.h"
+
+static void prodtest_set_log_filter(cli_t* cli) {
+ const char* filter = cli_arg(cli, "filter");
+ size_t filter_len = strlen(filter);
+
+ if (filter_len == 0) {
+ cli_error_arg(cli, "Expecting filter string.");
+ return;
+ }
+
+ if (cli_arg_count(cli) > 1) {
+ cli_error_arg_count(cli);
+ return;
+ }
+
+ if (!syslog_set_filter(filter, filter_len)) {
+ cli_error(cli, PRODTEST_ERR_SYSLOG_FILTER_SET, "Failed to set log filter.");
+ return;
+ }
+
+ cli_ok(cli, "");
+}
+
+// clang-format off
+
+PRODTEST_CLI_CMD(
+ .name = "log-filter",
+ .func = prodtest_set_log_filter,
+ .info = "Set logging filter",
+ .args = "<filter>"
+);
+
+#endif // USE_DBG_CONSOLE
diff --git a/core/embed/sys/dbg/syslog.c b/core/embed/sys/dbg/syslog.c
index 49fa7415..d1828afa 100644
--- a/core/embed/sys/dbg/syslog.c
+++ b/core/embed/sys/dbg/syslog.c
@@ -266,35 +266,3 @@ void syslog_tsh_error(ts_t status, const char* file, int line) {
syslog_printf(&source, LOG_LEVEL_ERR, "%s at %s:%d", ts_string(status), file,
line);
}
-
-#ifdef TREZOR_PRODTEST
-
-#include <rtl/cli.h>
-
-#include "prodtest_error_codes.h"
-
-static void prodtest_set_log_filter(cli_t* cli) {
- const char* filter = cli_arg(cli, "filter");
- size_t filter_len = strlen(filter);
-
- if (filter_len == 0) {
- cli_error_arg(cli, "Expecting filter string.");
- return;
- }
-
- if (cli_arg_count(cli) > 1) {
- cli_error_arg_count(cli);
- return;
- }
-
- if (!syslog_set_filter(filter, filter_len)) {
- cli_error(cli, PRODTEST_ERR_SYSLOG_FILTER_SET, "Failed to set log filter.");
- }
-
- cli_ok(cli, "");
-}
-
-PRODTEST_CLI_CMD(.name = "log-filter", .func = prodtest_set_log_filter,
- .info = "Set logging filter", .args = "<filter>");
-
-#endif // TREZOR_PRODTEST
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.