fix(chip-db): correct device labels and add integrity canary

This commit is contained in:
Moussa Ouallaf 2026-07-17 02:45:59 +02:00
commit e7e22fc0cc
5 changed files with 284 additions and 92 deletions

View file

@ -47,8 +47,8 @@ TARGET = tr4mpass
all: .build-flags $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(TARGET): .chip-db-canary $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -Iinclude -c -o $@ $<
@ -62,9 +62,36 @@ $(TARGET): $(OBJS)
clean:
find src -name '*.o' -delete
<<<<<<< HEAD
rm -f $(TARGET) $(TEST_TARGET) $(MOCK_TARGET) .build-flags
=======
rm -f $(TARGET) $(TEST_TARGET) $(MOCK_TARGET) $(CHIP_DB_CANARY_BIN)
>>>>>>> agent/wf_f342a9f1-9c7-2
find tests -name '*.o' -delete 2>/dev/null || true
# ------------------------------------------------------------------ #
# Chip DB integrity canary (T5, issue #53). #
# #
# Rebuilt and re-run on every $(TARGET) build. If any well-known #
# row in include/device/chip_db_table*.h diverges from tests/ #
# chip_db_canary.c's expected (name, marketing, checkm8) tuple, the #
# probe exits non-zero and the whole build fails -- guarding against #
# a repeat of the 0x8947/0x8960 mislabel bug where the CLI announced #
# the wrong device family. Bypass with STRICT_CHIP_DB=0 only when a #
# distro-packaged chip table has legitimately diverged. #
# ------------------------------------------------------------------ #
STRICT_CHIP_DB ?= 1
CHIP_DB_CANARY_BIN = tests/chip_db_canary.bin
.chip-db-canary: tests/chip_db_canary.c include/device/chip_db_table.h \
include/device/chip_db_table_rop.h include/device/chip_db.h
@$(CC) -Wall -Wextra -std=c99 -D_GNU_SOURCE -O2 -Iinclude \
-DSTRICT_CHIP_DB=$(STRICT_CHIP_DB) \
tests/chip_db_canary.c -o $(CHIP_DB_CANARY_BIN)
@./$(CHIP_DB_CANARY_BIN)
.PHONY: all clean test test-mocks .chip-db-canary
# ------------------------------------------------------------------ #
# Test target: compile only hardware-independent units #
# No mocks, no real library linkage required for the SUT code. #
@ -150,5 +177,8 @@ test-mocks: $(MOCK_TARGET)
$(MOCK_TARGET): $(MOCK_ALL_SRCS)
$(CC) $(MOCK_CFLAGS) -o $@ $^ $(MOCK_LDFLAGS)
<<<<<<< HEAD
.PHONY: all clean test test-mocks .build-flags
=======
>>>>>>> agent/wf_f342a9f1-9c7-2