Skip to content

Commit 26b6b8c

Browse files
hyperpolymathclaude
andcommitted
zig-api: export uapi_safe_path_default C ABI symbol from process.zig
Adds uapi_safe_path_default(path_ptr, path_len) as a C-ABI export of the existing safePathDefault() function, enabling pre-built libzig_api consumers (e.g. lol-gateway) to call the proven-backed path gate without a direct Zig module import. Adds matching declaration to generated/abi/zig_api.h. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6663956 commit 26b6b8c

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

zig-api/ffi/zig/src/process.zig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ pub fn safePathDefault(path: []const u8) bool {
108108
return !result.value;
109109
}
110110

111+
/// C ABI export of safePathDefault for consumers that link libzig_api as a
112+
/// pre-built static/shared library and cannot import process.zig directly.
113+
///
114+
/// `path_ptr` — pointer to the path bytes (need not be null-terminated).
115+
/// `path_len` — byte length of the path.
116+
///
117+
/// Returns 1 (true) when the path is safe, 0 (false) when denied.
118+
/// Matches the declaration in generated/abi/zig_api.h: uapi_safe_path_default.
119+
pub export fn uapi_safe_path_default(path_ptr: [*]const u8, path_len: usize) callconv(.c) u8 {
120+
const path = path_ptr[0..path_len];
121+
return if (safePathDefault(path)) 1 else 0;
122+
}
123+
111124
// =============================================================================
112125
// ExecOutput — captured stdout / stderr from a subprocess
113126
// =============================================================================

zig-api/generated/abi/zig_api.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,25 @@ void uapi_teardown(void);
117117
#define UAPI_METHOD_OPTIONS 5
118118
#define UAPI_METHOD_PATCH 6
119119

120+
/* ============================================================================
121+
* Path safety (ffi/zig/src/process.zig)
122+
* ========================================================================== */
123+
124+
/**
125+
* Check whether a path is safe to open.
126+
*
127+
* Applies two gates:
128+
* 1. Allowlist prefix check (see process.zig DEFAULT_ALLOWLIST).
129+
* 2. proven_path_has_traversal — formally-verified traversal detection.
130+
*
131+
* `path_ptr` — pointer to path bytes (need not be null-terminated).
132+
* `path_len` — byte length of the path.
133+
*
134+
* Returns 1 when the path is safe, 0 when denied.
135+
* Fails closed: returns 0 on any proven internal error.
136+
*/
137+
uint8_t uapi_safe_path_default(const uint8_t *path_ptr, uint32_t path_len);
138+
120139
/* ============================================================================
121140
* Gnosis API server (ffi/zig/src/gnosis.zig)
122141
* ========================================================================== */

0 commit comments

Comments
 (0)