Skip to content

Commit 6b97996

Browse files
committed
fix: modernize error assert and audit pie detection
1 parent 4a45f74 commit 6b97996

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,4 @@ See [docs/guides/DEBRIEF_FORMAT.md](docs/guides/DEBRIEF_FORMAT.md) for the JSONL
104104
{"date":"2025-10-20","time":"13:05","summary":"Silenced clang-tidy bool conversion in static assert to unblock CI clang builds.","topics":[{"topic":"clang-tidy parity","what":"Explicitly cast static assert condition to _Bool","why":"GNU-GON-CRY run flagged implicit int→bool conversion","context":"CI clang-tidy job runs clang-18 with readability-implicit-bool-conversion as error","issue":"_Static_assert expression returned int and triggered lint error","resolution":"Wrapped the predicate in (_Bool) to make the conversion explicit","future_work":"Verify the next pipeline cycle stays green","time_percent":100}],"key_decisions":[],"action_items":[]}
105105
{"date":"2025-10-20","time":"13:42","summary":"Hardened release builds with full stack canaries to satisfy CI security audit stack check.","topics":[{"topic":"Security audit parity","what":"Replaced -fstack-protector-strong with -fstack-protector-all","why":"Quality Matrix security audit marked stack canaries as disabled on the Linux runner","context":"Audit script checks mg-cli binary for __stack_chk_fail symbol","issue":"strong mode doesn’t emit canaries when functions lack risky frames","resolution":"Always request -fstack-protector-all so the guard symbol is emitted","future_work":"Monitor audit output on the next CI cycle","time_percent":100}],"key_decisions":[],"action_items":[]}
106106
{"date":"2025-10-20","time":"15:12","summary":"Taught the security audit to recognize safe-stack builds and dump details when failing in CI.","topics":[{"topic":"Audit false positive","what":"Detect __safestack_unsafe_stack_ptr alongside __stack_chk_fail","why":"Linux Release builds use Clang safe-stack so the previous detector flagged stack canaries as missing","context":"Quality Matrix security audit kept aborting despite hardening flags","issue":"Audit only looked for __stack_chk_fail which isn’t emitted with safe-stack","resolution":"Count either symbol and continue to report stack protection as enabled","future_work":"Keep an eye on future toolchain upgrades in case symbol names change","time_percent":70},{"topic":"CI diagnostics","what":"Emit the full .ignored/security-audit.txt before exiting","why":"Artifact upload isn’t always reliable, making it hard to inspect failures","context":"GitHub Actions quality matrix","issue":"Engineers could not see what triggered the critical flag","resolution":"Surface the report inline when the script exits non-zero","future_work":"None","time_percent":30}],"key_decisions":[],"action_items":[]}
107+
```

scripts/security-audit.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,23 @@ analyze_binary_security() {
7171
echo "❌ Stack protection: DISABLED" >> .ignored/security-audit.txt
7272
fi
7373

74-
# Check for PIE
75-
if file "$binary" | grep -q "shared object"; then
76-
echo "✅ PIE (Position Independent Executable): ENABLED" >> .ignored/security-audit.txt
77-
elif file "$binary" | grep -q "Mach-O.*executable.*PIE"; then
78-
echo "✅ PIE (Position Independent Executable): ENABLED" >> .ignored/security-audit.txt
74+
pie_output="$(file "$binary" 2>/dev/null || true)"
75+
pie_enabled=false
76+
77+
if echo "$pie_output" | grep -qi "shared object"; then
78+
pie_enabled=true
79+
elif echo "$pie_output" | grep -qi "pie executable"; then
80+
pie_enabled=true
81+
elif echo "$pie_output" | grep -q "Mach-O.*executable.*PIE"; then
82+
pie_enabled=true
7983
elif otool -hv "$binary" 2>/dev/null | grep -q "PIE"; then
84+
pie_enabled=true
85+
elif command -v readelf >/dev/null 2>&1 && \
86+
readelf -h "$binary" 2>/dev/null | grep -q "Type:[[:space:]]*DYN"; then
87+
pie_enabled=true
88+
fi
89+
90+
if [ "$pie_enabled" = true ]; then
8091
echo "✅ PIE (Position Independent Executable): ENABLED" >> .ignored/security-audit.txt
8192
else
8293
echo "❌ PIE: DISABLED" >> .ignored/security-audit.txt

src/error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ metagraph_builder_append_unsigned(metagraph_message_builder_t *builder,
209209
base = 16U;
210210
}
211211
char digits[64];
212-
_Static_assert((_Bool)(sizeof(digits) >= 64U),
212+
_Static_assert(sizeof(digits) >= 64U,
213213
"digits buffer must be at least 64 bytes");
214214
const char *alphabet = "0123456789abcdef";
215215
if (uppercase) {

0 commit comments

Comments
 (0)