@@ -8020,6 +8020,100 @@ TEST(pipeline_ts_config_object_url_http_calls_issue2235) {
80208020 PASS();
80218021}
80228022
8023+ /* Count HTTP_CALLS-style edges whose url_path property contains `keyword`. */
8024+ static int count_edges_with_url_path(cbm_store_t *s, const char *project, const char *keyword) {
8025+ cbm_edge_t *es = NULL;
8026+ int n = 0;
8027+ cbm_store_find_edges_by_url_path(s, project, keyword, &es, &n);
8028+ if (es) {
8029+ cbm_store_free_edges(es, n);
8030+ }
8031+ return n;
8032+ }
8033+
8034+ /* Distilled from PR #1245: detect_url_in_args (parallel resolver, >= 50 files)
8035+ * runs for EVERY resolved call with no callee gating, so a filesystem path
8036+ * with a document/log extension passed to a project-defined open/read/write
8037+ * helper passed normalize_url_arg (second slash, no space) and the route
8038+ * literal guard, minting a Route node + an HTTP_CALLS edge for a file. The
8039+ * callees are project functions on purpose: a bare builtin `open(...)` never
8040+ * resolves to a target and so never reaches emit_service_edge at all. The
8041+ * first path segments avoid the filesystem-root list (etc/var/tmp/...) so
8042+ * only the extension guard can reject them. requests.get('/api/items') is
8043+ * the positive control that must keep its Route + HTTP_CALLS. */
8044+ TEST(pipeline_arg_url_rejects_document_file_paths) {
8045+ char tmp[256];
8046+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_arg_url_docs_XXXXXX");
8047+ if (!cbm_mkdtemp(tmp)) {
8048+ FAIL("tmpdir");
8049+ }
8050+
8051+ write_temp_file(tmp, "src/files.py",
8052+ "import requests\n"
8053+ "def open_file(path):\n"
8054+ " return path\n"
8055+ "def read_file(path):\n"
8056+ " return path\n"
8057+ "def write_file(path):\n"
8058+ " return path\n"
8059+ "def load_docs():\n"
8060+ " open_file('/new/file.txt')\n"
8061+ " read_file('/docs/guide.md')\n"
8062+ " write_file('/data/app.log')\n"
8063+ " read_file('/reports/summary.pdf')\n"
8064+ " open_file('/docs/index.rst')\n"
8065+ "def fetch_items():\n"
8066+ " return requests.get('/api/items')\n");
8067+ for (int i = 0; i < 52; i++) {
8068+ char name[64];
8069+ char body[128];
8070+ snprintf(name, sizeof(name), "src/filler%d.ts", i);
8071+ snprintf(body, sizeof(body), "export function filler%d(): number { return %d; }\n", i, i);
8072+ write_temp_file(tmp, name, body);
8073+ }
8074+
8075+ char *old_workers = getenv("CBM_WORKERS");
8076+ char *saved = old_workers ? strdup(old_workers) : NULL;
8077+ cbm_setenv("CBM_WORKERS", "4", 1);
8078+
8079+ char db_path[512];
8080+ snprintf(db_path, sizeof(db_path), "%s/arg_url_docs.db", tmp);
8081+ cbm_pipeline_t *p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
8082+ ASSERT_NOT_NULL(p);
8083+ ASSERT_EQ(cbm_pipeline_run(p), 0);
8084+ const char *project = cbm_pipeline_project_name(p);
8085+
8086+ cbm_store_t *s = cbm_store_open_path(db_path);
8087+ ASSERT_NOT_NULL(s);
8088+
8089+ /* Positive control first: the genuine HTTP call still mints its route. */
8090+ ASSERT_GTE(count_nodes_named(s, project, "/api/items"), 1);
8091+ ASSERT_GTE(count_edges_with_url_path(s, project, "/api/items"), 1);
8092+ /* No Route node for any filesystem document path... */
8093+ ASSERT_EQ(count_nodes_named(s, project, "/new/file.txt"), 0);
8094+ ASSERT_EQ(count_nodes_named(s, project, "/docs/guide.md"), 0);
8095+ ASSERT_EQ(count_nodes_named(s, project, "/data/app.log"), 0);
8096+ ASSERT_EQ(count_nodes_named(s, project, "/reports/summary.pdf"), 0);
8097+ ASSERT_EQ(count_nodes_named(s, project, "/docs/index.rst"), 0);
8098+ /* ...and no HTTP_CALLS edge carrying one as its url_path either. */
8099+ ASSERT_EQ(count_edges_with_url_path(s, project, "/new/file.txt"), 0);
8100+ ASSERT_EQ(count_edges_with_url_path(s, project, "/docs/guide.md"), 0);
8101+ ASSERT_EQ(count_edges_with_url_path(s, project, "/data/app.log"), 0);
8102+ ASSERT_EQ(count_edges_with_url_path(s, project, "/reports/summary.pdf"), 0);
8103+ ASSERT_EQ(count_edges_with_url_path(s, project, "/docs/index.rst"), 0);
8104+
8105+ cbm_store_close(s);
8106+ cbm_pipeline_free(p);
8107+ if (saved) {
8108+ cbm_setenv("CBM_WORKERS", saved, 1);
8109+ free(saved);
8110+ } else {
8111+ cbm_unsetenv("CBM_WORKERS");
8112+ }
8113+ th_rmtree(tmp);
8114+ PASS();
8115+ }
8116+
80238117/* Native `fetch()` (#856), sequential path (< 50 files → pass_calls.c). A bare
80248118 * unqualified call to the global fetch API has no import and no local
80258119 * definition anywhere in this project, so registry resolution comes back
@@ -17575,6 +17669,7 @@ SUITE(pipeline) {
1757517669 RUN_TEST(pipeline_parallel_rust_cross_only_macro_hidden_gets_synthetic_carrier);
1757617670 RUN_TEST(pipeline_arg_url_rejects_non_http_slash_arguments);
1757717671 RUN_TEST(pipeline_ts_config_object_url_http_calls_issue2235);
17672+ RUN_TEST(pipeline_arg_url_rejects_document_file_paths);
1757817673 RUN_TEST(pipeline_native_fetch_classified_as_http_calls);
1757917674 RUN_TEST(pipeline_swift_nested_url_makes_route_issue1892);
1758017675 RUN_TEST(pipeline_swift_http_call_makes_route_issue1892);
0 commit comments