@@ -8467,6 +8467,45 @@ TEST(pipeline_semantic_manifest_rejects_non_directory_root) {
84678467 PASS();
84688468}
84698469
8470+ #ifndef _WIN32
8471+ /* A nested directory the process cannot open (permission-denied) must not
8472+ * abort the whole manifest walk: it has no control files to contribute, so
8473+ * it is skipped, and control files in sibling directories still get found.
8474+ * Root-not-a-directory (above) is a different, still fail-closed case. */
8475+ TEST(pipeline_semantic_manifest_skips_unreadable_subdirectory) {
8476+ char tmp[256];
8477+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_manifest_locked_dir_XXXXXX");
8478+ ASSERT_NOT_NULL(cbm_mkdtemp(tmp));
8479+ write_temp_file(tmp, "readable.py", "def Readable():\n return 1\n");
8480+ write_temp_file(tmp, "locked/secret.txt", "should never be opened\n");
8481+ write_temp_file(tmp, "sibling/.gitignore", "*.log\n");
8482+
8483+ char locked_path[512];
8484+ snprintf(locked_path, sizeof(locked_path), "%s/locked", tmp);
8485+ ASSERT_EQ(chmod(locked_path, 0), 0);
8486+
8487+ cbm_file_hash_t *manifest = NULL;
8488+ int manifest_count = -1;
8489+ int rc = cbm_pipeline_build_semantic_manifest("manifest-skip-locked", tmp, NULL, 0, NULL, 0,
8490+ NULL, NULL, &manifest, &manifest_count);
8491+
8492+ bool found_sibling_gitignore = false;
8493+ for (int i = 0; i < manifest_count; i++) {
8494+ if (manifest[i].rel_path && strcmp(manifest[i].rel_path, "sibling/.gitignore") == 0) {
8495+ found_sibling_gitignore = true;
8496+ }
8497+ }
8498+
8499+ chmod(locked_path, 0755);
8500+ cbm_pipeline_free_semantic_manifest(manifest, manifest_count > 0 ? manifest_count : 0);
8501+ th_rmtree(tmp);
8502+
8503+ ASSERT_EQ(rc, 0);
8504+ ASSERT_TRUE(found_sibling_gitignore);
8505+ PASS();
8506+ }
8507+ #endif /* !_WIN32 */
8508+
84708509/* A fully validated staged graph must be able to recover from a definitely
84718510 * non-SQLite destination without deleting evidence or overwriting an earlier
84728511 * quarantine. The replacement happens only after the corrupt bytes are moved. */
@@ -28610,6 +28649,9 @@ SUITE(pipeline_semantic_manifest_repro) {
2861028649 RUN_TEST(pipeline_incremental_successful_publication_preserves_adr);
2861128650 RUN_TEST(pipeline_full_adr_capture_failure_preserves_previous_generation);
2861228651 RUN_TEST(pipeline_semantic_manifest_rejects_non_directory_root);
28652+ #ifndef _WIN32
28653+ RUN_TEST(pipeline_semantic_manifest_skips_unreadable_subdirectory);
28654+ #endif
2861328655 RUN_TEST(pipeline_full_reindex_quarantines_corrupt_destination_without_overwrite);
2861428656 RUN_TEST(pipeline_full_reindex_replaces_legacy_schema_without_quarantine);
2861528657#endif
0 commit comments