Skip to content

Commit 8a4bef2

Browse files
authored
Merge branch 'main' into fix/tools-list-pagination-971
2 parents dff70f5 + 3747344 commit 8a4bef2

2 files changed

Lines changed: 35 additions & 10 deletions

File tree

‎.github/workflows/_smoke.yml‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,20 @@ jobs:
248248
run: |
249249
& "C:\Program Files\Windows Defender\MpCmdRun.exe" -SignatureUpdate 2>$null
250250
$result = & "C:\Program Files\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File "$PWD\codebase-memory-mcp.exe" -DisableRemediation
251+
$code = $LASTEXITCODE
251252
Write-Host $result
252-
if ($LASTEXITCODE -ne 0) { Write-Host "BLOCKED: Windows Defender flagged binary!"; exit 1 }
253-
Write-Host "=== Windows Defender: clean ==="
253+
# MpCmdRun -Scan exit codes: 0 = clean, 2 = threat found. Any OTHER non-zero
254+
# means the scan engine could not run at all (e.g. hr=0x800106ba: the Defender
255+
# antimalware service is unavailable on the runner) — that is NOT a detection.
256+
# Fail soft on an engine failure so a transient runner-side AV outage can't
257+
# false-fail a release; only a real detection (exit 2) hard-blocks.
258+
if ($code -eq 2) {
259+
Write-Host "BLOCKED: Windows Defender flagged binary!"; exit 1
260+
} elseif ($code -ne 0) {
261+
Write-Host "::warning::Windows Defender scan could not run (exit $code) - skipping AV gate on this runner"
262+
} else {
263+
Write-Host "=== Windows Defender: clean ==="
264+
}
254265
255266
smoke-linux-portable:
256267
needs: setup-matrix

‎src/mcp/mcp.c‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4373,20 +4373,34 @@ static yyjson_doc *enrich_node_properties(yyjson_mut_doc *doc, yyjson_mut_val *o
43734373
* the search path (attach_result_source) route through it, so a result whose
43744374
* indexed path escapes the project root — via a `..` segment, or a symlink /
43754375
* Windows junction picked up during discovery — is never read back out. */
4376+
/* Canonicalize `path` (resolve symlinks/junctions and `..`) into `out`
4377+
* (>= CBM_SZ_4K bytes); returns true on success. Isolating the per-OS resolver
4378+
* keeps cbm_path_within_root's control flow unconditional: the previous `#ifdef`
4379+
* opened the `if (...) {` brace in one branch and a different one in the other,
4380+
* sharing a single close brace — legal C, but it splits the function's braces
4381+
* across preprocessor branches, which defeats source-level tooling that parses
4382+
* without the preprocessor (and left this function unindexed in the graph). */
4383+
static bool resolve_canonical_path(const char *path, char *out, size_t out_sz) {
4384+
#ifdef _WIN32
4385+
if (!_fullpath(out, path, out_sz)) {
4386+
return false;
4387+
}
4388+
cbm_normalize_path_sep(out);
4389+
return true;
4390+
#else
4391+
(void)out_sz;
4392+
return realpath(path, out) != NULL;
4393+
#endif
4394+
}
4395+
43764396
bool cbm_path_within_root(const char *root_path, const char *abs_path) {
43774397
if (!root_path || !abs_path) {
43784398
return false;
43794399
}
43804400
char real_root[CBM_SZ_4K];
43814401
char real_file[CBM_SZ_4K];
4382-
#ifdef _WIN32
4383-
if (_fullpath(real_root, root_path, sizeof(real_root)) &&
4384-
_fullpath(real_file, abs_path, sizeof(real_file))) {
4385-
cbm_normalize_path_sep(real_root);
4386-
cbm_normalize_path_sep(real_file);
4387-
#else
4388-
if (realpath(root_path, real_root) && realpath(abs_path, real_file)) {
4389-
#endif
4402+
if (resolve_canonical_path(root_path, real_root, sizeof(real_root)) &&
4403+
resolve_canonical_path(abs_path, real_file, sizeof(real_file))) {
43904404
size_t root_len = strlen(real_root);
43914405
if (strncmp(real_file, real_root, root_len) == 0 &&
43924406
(real_file[root_len] == '/' || real_file[root_len] == '\0')) {

0 commit comments

Comments
 (0)