| 105 | "vendored/yyjson/safe.c\n"; |
| 106 | |
| 107 | static 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 | |
| 138 | TEST(vendored_integrity_rejects_unmanifested_source) { |
| 139 | char root[1024]; |
no test coverage detected