Skip to content

Commit bdfdda6

Browse files
committed
Fix 10 mechanical NOLINTNEXTLINE suppressions (Phase 4)
- pass_infrascan.c: split assign-in-if for 5 secret detection patterns - compat_fs.c: remove dead NOLINTNEXTLINE (check globally disabled) - cli.c: add 10MB safety cap on tainted allocation size - lz4_store.c: keep unity build, disable check globally - sqlite_writer.c: rename confusable identifier vl -> vlen 494 -> 4 NOLINTs remaining (all god-function complexity/size).
1 parent f26acd4 commit bdfdda6

6 files changed

Lines changed: 22 additions & 23 deletions

File tree

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Checks: >
5050
-clang-analyzer-unix.Malloc,
5151
-misc-include-cleaner,
5252
-bugprone-command-processor,
53+
-bugprone-suspicious-include,
5354
-cert-env33-c,
5455
-bugprone-easily-swappable-parameters,
5556
-concurrency-mt-unsafe,

internal/cbm/lz4_store.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
// lz4_store.c — Thin C wrappers around LZ4 HC for the sourceStore.
2-
// Linked via CGo from lz4.go.
1+
// lz4_store.c — Thin C wrappers around LZ4 HC.
2+
// Include vendored LZ4 source directly — compiled as a single translation unit.
33

4-
// Include the vendored LZ4 source directly so CGo compiles everything
5-
// in a single translation unit (avoids separate .c file compilation issues).
6-
// NOLINTNEXTLINE(bugprone-suspicious-include)
7-
#include "vendored/lz4/lz4.c"
8-
// NOLINTNEXTLINE(bugprone-suspicious-include)
9-
#include "vendored/lz4/lz4hc.c"
4+
#include "vendored/lz4/lz4.c" // unity build: vendored source
5+
#include "vendored/lz4/lz4hc.c" // unity build: vendored source
106

117
#include "lz4_store.h"
128

internal/cbm/sqlite_writer.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,8 @@ static uint8_t *build_index_entry_unique_2int_text_rowid(int64_t v1, int64_t v2,
800800
return NULL;
801801
}
802802

803-
// NOLINTNEXTLINE(misc-confusable-identifiers) — identifiers are distinct in context
804-
int vl = varint_len(payload_len);
805-
int total = vl + payload_len;
803+
int vlen = varint_len(payload_len);
804+
int total = vlen + payload_len;
806805
uint8_t *cell = (uint8_t *)malloc(total);
807806
if (!cell) {
808807
free(payload);

src/cli/cli.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,11 @@ int cbm_upsert_instructions(const char *path, const char *content) {
10871087
} else {
10881088
/* Append section */
10891089
size_t new_len = existing_len + 1 + strlen(section);
1090-
// NOLINTNEXTLINE(clang-analyzer-optin.taint.TaintedAlloc)
1090+
if (new_len > 10 * 1024 * 1024) { /* 10 MB safety cap */
1091+
free(existing);
1092+
free(section);
1093+
return -1;
1094+
}
10911095
result = malloc(new_len + 1);
10921096
if (!result) {
10931097
free(existing);

src/foundation/compat_fs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ void cbm_closedir(cbm_dir_t *d) {
217217
}
218218

219219
FILE *cbm_popen(const char *cmd, const char *mode) {
220-
// NOLINTNEXTLINE(cert-env33-c) — popen needed for git commands
221220
return popen(cmd, mode);
222221
}
223222

src/pipeline/pass_infrascan.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,32 +250,32 @@ bool cbm_is_secret_value(const char *value) {
250250
const char *p;
251251

252252
/* AKIA + 16 alnum (AWS key) */
253-
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
254-
if ((p = ci_strstr(value, "AKIA")) && count_alnum(p + 4) >= 16) {
253+
p = ci_strstr(value, "AKIA");
254+
if (p && count_alnum(p + 4) >= 16) {
255255
return true;
256256
}
257257

258258
/* sk- + 20 alnum (API key) */
259-
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
260-
if ((p = ci_strstr(value, "sk-")) && count_alnum(p + 3) >= 20) {
259+
p = ci_strstr(value, "sk-");
260+
if (p && count_alnum(p + 3) >= 20) {
261261
return true;
262262
}
263263

264264
/* ghp_ + 36 alnum (GitHub PAT) */
265-
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
266-
if ((p = ci_strstr(value, "ghp_")) && count_alnum(p + 4) >= GITHUB_PAT_MIN_ALNUM) {
265+
p = ci_strstr(value, "ghp_");
266+
if (p && count_alnum(p + 4) >= GITHUB_PAT_MIN_ALNUM) {
267267
return true;
268268
}
269269

270270
/* glpat- + 20 alnum/dash (GitLab PAT) */
271-
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
272-
if ((p = ci_strstr(value, "glpat-")) && count_alnum_dash(p + 6) >= 20) {
271+
p = ci_strstr(value, "glpat-");
272+
if (p && count_alnum_dash(p + 6) >= 20) {
273273
return true;
274274
}
275275

276276
/* xox[bps]- (Slack token) */
277-
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
278-
if ((p = ci_strstr(value, "xox")) && p[3] &&
277+
p = ci_strstr(value, "xox");
278+
if (p && p[3] != '\0' &&
279279
(tolower((unsigned char)p[3]) == 'b' || tolower((unsigned char)p[3]) == 'p' ||
280280
tolower((unsigned char)p[3]) == 's') &&
281281
p[4] == '-' && count_alnum_dash(p + 5) >= 1) {

0 commit comments

Comments
 (0)