about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-10-09 05:59:16 +0000
committerPjotr <wrk@bosa.lan>2026-10-09 05:59:16 +0000
commit167eee5551a8d60490797bccec2baa833e1ae2e5 (patch)
treeb9d620fd95034c199e54b90cc9a61416300e5b6c
parentcf32f16a1c7bcc850c21051bcd4b27e90f7182cf (diff)
downloadgn-guile-main.tar.gz
data: require a public, non-confidential PublishFreeze for BXD publish data HEAD main
get-bxd-publish-dataid-name-value-dict queried PublishData by
PublishData.Id alone, with no check at all on InbredSetId or on
PublishFreeze.public/confidentiality. It is reachable directly from
GET /dataset/bxd-publish/dataid/values/{id}.json, bypassing the
InbredSetId=1 scoping that get-dataid-from-publishxrefid applies on
the other BXD routes, so any PublishData.Id could be read regardless
of group or confidentiality.

Join through PublishXRef to PublishFreeze and require
public>0 AND confidentiality<1 in that function and in
get-bxd-publish-values-list (same query, unused elsewhere). Also add
the same PublishFreeze check to get-dataid-from-publishxrefid and
get-bxd-publish-list, which were already scoped to InbredSetId=1, for
defense in depth.

Checked with a plain Guile reader pass only (parens balance, 8
top-level forms); this project's guix.scm/manifest.scm need a channel
package (gemma-gn2) not available here, so modules were not resolved
and the SQL was not run.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
-rw-r--r--gn/data/dataset.scm31
1 files changed, 24 insertions, 7 deletions
diff --git a/gn/data/dataset.scm b/gn/data/dataset.scm
index afe75ba..6c2e6af 100644
--- a/gn/data/dataset.scm
+++ b/gn/data/dataset.scm
@@ -31,25 +31,38 @@
   (assoc-ref (get-dataset db probesetfreeze-id) "Name"))
 
 (define (get-dataid-from-publishxrefid id)
-  "Get the internal dataid from publishxref - which is the same as used in the GN2 web interface"
+  "Get the internal dataid from publishxref - which is the same as used in the GN2 web interface. Only matches a PublishXRef backed by a public, non-confidential PublishFreeze."
   (call-with-db
    (lambda (db)
-     (let [(query (string-append "SELECT Id,PhenotypeId,DataId FROM PublishXRef WHERE Id=" id " AND InbredSetId=1 LIMIT 1"))]
+     (let [(query (string-append "SELECT PublishXRef.Id,PublishXRef.PhenotypeId,PublishXRef.DataId "
+                                  "FROM PublishXRef, PublishFreeze "
+                                  "WHERE PublishXRef.Id=" id " AND PublishXRef.InbredSetId=1 "
+                                  "AND PublishFreeze.InbredSetId=PublishXRef.InbredSetId "
+                                  "AND PublishFreeze.public>0 AND PublishFreeze.confidentiality<1 LIMIT 1"))]
        (dbi-query db query)
        (pk (int-to-string (assoc-ref (get-row db) "DataId")))))))
 
 (define (get-bxd-publish-list)
+  "List PublishXRef records for BXD (InbredSetId=1) that are backed by a public, non-confidential PublishFreeze."
   (call-with-db
    (lambda (db)
-     (let [(query "SELECT Id,PhenotypeId,DataId FROM PublishXRef WHERE InbredSetId=1")]
+     (let [(query (string-append "SELECT PublishXRef.Id,PublishXRef.PhenotypeId,PublishXRef.DataId "
+                                  "FROM PublishXRef, PublishFreeze "
+                                  "WHERE PublishXRef.InbredSetId=1 "
+                                  "AND PublishFreeze.InbredSetId=PublishXRef.InbredSetId "
+                                  "AND PublishFreeze.public>0 AND PublishFreeze.confidentiality<1"))]
        (dbi-query db query)
        (get-rows db '())))))
 
 (define* (get-bxd-publish-values-list dataid #:optional used-for-mapping?)
-  "Returns dict of name values , e.g. [{\"Name\":\"C57BL/6J\",\"value\":9.136},{\"Name\":\"DBA/2J\",\"value\":4.401},{\"Name\":\"BXD9\",\"value\":4.36}, ... used-for-mapping? skips the founders and maybe other unmappable inds. Note, currently unused."
+  "Returns dict of name values , e.g. [{\"Name\":\"C57BL/6J\",\"value\":9.136},{\"Name\":\"DBA/2J\",\"value\":4.401},{\"Name\":\"BXD9\",\"value\":4.36}, ... used-for-mapping? skips the founders and maybe other unmappable inds. Note, currently unused. Only matches data backed by a public, non-confidential PublishFreeze."
   (call-with-db
    (lambda (db)
-     (let [(query (string-append "SELECT Strain.Name, PublishData.value FROM Strain, PublishData WHERE PublishData.Id=" dataid " and Strain.Id=StrainID;"))]
+     (let [(query (string-append "SELECT Strain.Name, PublishData.value FROM Strain, PublishData, PublishXRef, PublishFreeze "
+                                  "WHERE PublishData.Id=" dataid " AND PublishXRef.DataId=PublishData.Id "
+                                  "AND PublishFreeze.InbredSetId=PublishXRef.InbredSetId "
+                                  "AND PublishFreeze.public>0 AND PublishFreeze.confidentiality<1 "
+                                  "AND Strain.Id=StrainID;"))]
        (dbi-query db query)
        (if used-for-mapping?
            (remove null? (pk (get-rows-apply db
@@ -62,10 +75,14 @@
            )))))
 
 (define* (get-bxd-publish-dataid-name-value-dict dataid #:optional used-for-mapping?)
-  "Returns dict of name values, e.g. (((\"C57BL/6J\" . 9.136) (\"DBA/2J\" . 4.401) (\"BXD9\" . 4.36) ... used-for-mapping? skips the founders and maybe other unmappable inds."
+  "Returns dict of name values, e.g. (((\"C57BL/6J\" . 9.136) (\"DBA/2J\" . 4.401) (\"BXD9\" . 4.36) ... used-for-mapping? skips the founders and maybe other unmappable inds. Only matches data backed by a public, non-confidential PublishFreeze."
   (call-with-db
    (lambda (db)
-     (let [(query (string-append "SELECT Strain.Name, PublishData.value FROM Strain, PublishData WHERE PublishData.Id=" dataid " and Strain.Id=StrainID;"))]
+     (let [(query (string-append "SELECT Strain.Name, PublishData.value FROM Strain, PublishData, PublishXRef, PublishFreeze "
+                                  "WHERE PublishData.Id=" dataid " AND PublishXRef.DataId=PublishData.Id "
+                                  "AND PublishFreeze.InbredSetId=PublishXRef.InbredSetId "
+                                  "AND PublishFreeze.public>0 AND PublishFreeze.confidentiality<1 "
+                                  "AND Strain.Id=StrainID;"))]
        (dbi-query db query)
        (if used-for-mapping?
            (remove null? (pk (get-rows-apply db