MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / security_make_vendored_fixture

Function security_make_vendored_fixture

tests/test_security.c:107–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105 "vendored/yyjson/safe.c\n";
106
107static int security_make_vendored_fixture(char *root, size_t root_size,
108 const char *extra_relative_path,
109 const char *extra_content) {
110 if (!root || root_size == 0U || !extra_relative_path || !extra_content)
111 return -1;
112
113 int n = snprintf(root, root_size, "%s/cbm_vendored_security_XXXXXX", cbm_tmpdir());
114 if (n < 0 || (size_t)n >= root_size || !cbm_mkdtemp(root))
115 return -1;
116
117 char *script = security_read_file("scripts/security-vendored.sh");
118 if (!script) {
119 th_cleanup(root);
120 return -1;
121 }
122
123 int rc = 0;
124 if (th_write_file(TH_PATH(root, "scripts/security-vendored.sh"), script) != 0 ||
125 th_write_file(TH_PATH(root, "scripts/vendored-checksums.txt"),
126 security_vendored_fixture_manifest) != 0 ||
127 th_write_file(TH_PATH(root, "vendored/yyjson/safe.c"), "") != 0 ||
128 th_write_file(TH_PATH(root, extra_relative_path), extra_content) != 0) {
129 rc = -1;
130 }
131 free(script);
132
133 if (rc != 0)
134 th_cleanup(root);
135 return rc;
136}
137
138TEST(vendored_integrity_rejects_unmanifested_source) {
139 char root[1024];

Callers 1

test_security.cFile · 0.85

Calls 5

cbm_tmpdirFunction · 0.85
cbm_mkdtempFunction · 0.85
security_read_fileFunction · 0.85
th_cleanupFunction · 0.85
th_write_fileFunction · 0.85

Tested by

no test coverage detected